Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_web_text_only.py
- urlrep="http://webcache.googleusercontent.com/search?q=cache:###&num=1&hl=en&gl=ca&strip=1&vwsrc=0"
- try:
- # Python2
- from Tkinter import *
- from urllib2 import urlopen
- except ImportError:
- # Python3
- from tkinter import *
- from urllib.request import urlopen
- import webbrowser
- import time
- root=Tk()
- root.geometry('1280x64+0+0')
- root.title('Open URL as Text-Only')
- topFrame=LabelFrame(root,text="",height=40)
- topFrame.pack(fill=X)
- topFrame.pack_propagate(False)
- Frame2=LabelFrame(root,height=30,borderwidth=0,bg="aqua")
- Frame2.pack(fill=X)
- Frame2.pack_propagate(False)
- ffff=Listbox(topFrame,selectmode=EXTENDED) # Bingo! Multiple links can be chosen, using the Shift and Control keyboard modifiers
- ffff.pack(fill=BOTH,expand=YES,side=LEFT)
- #
- def from_clipboard():
- html = root.clipboard_get()
- url.set(html)
- root.update()
- opentab(html)
- #
- def text_only():
- html=ent.get()
- opentab(html)
- #
- def opentab(html):
- if "%2F%2F" in html:
- html=html.split("2F%2F")[-1]
- html=html.split("&usg=")[0]
- html=html.replace('%2F','/')
- webbrowser.open(urlrep.replace('###',html))
- time.sleep(0.5)
- #
- btn=Button(Frame2,text="Enter URL",width=16,command=text_only)
- btn.pack(side=LEFT)
- url=StringVar()
- ent=Entry(Frame2,width="180",textvariable=url)
- ent.pack(side=LEFT)
- cpb=Button(Frame2,text="Clipboard",command=from_clipboard)
- cpb.pack(side=RIGHT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement