here2share

# Tk_decode_google_urls.py

Oct 12th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. # Tk_decode_google_urls.py
  2.  
  3. from Tkinter import *
  4. import urllib
  5. import webbrowser
  6.  
  7. root = Tk()
  8. label = LabelFrame(root, text=' decode google urls ', height=200, width=800, bg="aqua")
  9. label.pack(fill=X)
  10. label.pack_propagate(False)
  11.  
  12. def decodeurl():
  13.     v = ''
  14.     s = s2 = root.clipboard_get()
  15.     for z in ['&url=','?imgurl=']:
  16.         if z in s:
  17.             s = s[s.index(z)+len(z):]
  18.             for z in ['.jpeg','.jpg']:
  19.                 if z in s:
  20.                     s = s[:s.index(z)]+z
  21.                     v = urllib.unquote(s)
  22.                     ### webbrowser.open(z)
  23.             break
  24.     if not s:
  25.         v = urllib.unquote(s2)
  26.     url.set(v)
  27.     root.clipboard_clear()
  28.     root.clipboard_append(v)
  29.     root.update()
  30. #
  31. def ypad(y=0):
  32.     if y == -1:
  33.         pass
  34.     elif y in ['text']:
  35.         root.ypad+=30
  36.     elif y:
  37.         root.ypad=y+2
  38.     else:
  39.         root.ypad+=21
  40.     return root.ypad
  41. #
  42.  
  43. btn = Button(label, text='Decode Url', command=decodeurl)
  44. btn.pack()
  45. btn.place(x=5,y=ypad(1))
  46.  
  47. url = StringVar()
  48. ent = Entry(label,textvariable=url)
  49. ent.pack()
  50. ent.place(x=5,y=ypad('text'),width=760)
  51.  
  52. root.mainloop()
Add Comment
Please, Sign In to add comment