Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_decode_google_urls.py
- from Tkinter import *
- import urllib
- import webbrowser
- root = Tk()
- label = LabelFrame(root, text=' decode google urls ', height=200, width=800, bg="aqua")
- label.pack(fill=X)
- label.pack_propagate(False)
- def decodeurl():
- v = ''
- s = s2 = root.clipboard_get()
- for z in ['&url=','?imgurl=']:
- if z in s:
- s = s[s.index(z)+len(z):]
- for z in ['.jpeg','.jpg']:
- if z in s:
- s = s[:s.index(z)]+z
- v = urllib.unquote(s)
- ### webbrowser.open(z)
- break
- if not s:
- v = urllib.unquote(s2)
- url.set(v)
- root.clipboard_clear()
- root.clipboard_append(v)
- root.update()
- #
- def ypad(y=0):
- if y == -1:
- pass
- elif y in ['text']:
- root.ypad+=30
- elif y:
- root.ypad=y+2
- else:
- root.ypad+=21
- return root.ypad
- #
- btn = Button(label, text='Decode Url', command=decodeurl)
- btn.pack()
- btn.place(x=5,y=ypad(1))
- url = StringVar()
- ent = Entry(label,textvariable=url)
- ent.pack()
- ent.place(x=5,y=ypad('text'),width=760)
- root.mainloop()
Add Comment
Please, Sign In to add comment