Advertisement
here2share

# Tk_drag_img.py

Aug 8th, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.82 KB | None | 0 0
  1. # Tk_drag_img.py
  2.  
  3. from Tkinter import *
  4. from cStringIO import StringIO
  5. from PIL import ImageTk, Image
  6. import base64
  7.  
  8. py_gif_b64='''\
  9. R0lGODlhQABAAPcAAAAAAAAPMwAXNwAaOAAYQwAbQQAdQQAbTwAeSwAWUQMmQgAjSwEnSwYuTwoo
  10. SggtSAwrSAAlVAAgWQAmWAAqVgAuVwAuXQcuWAw1TQs5Xhk0SQAsYwAxZAA1YQA0bAA6bAA/dyw/
  11. UAxAbgxGeh5BYRxHbRRKdBRNfi5IXC5OaCJQdCNUfzdTajlQYj1UaTJWdDZge0BXaUZZaE1dakJa
  12. cEBffElhc0lieUlmfU9leQZJgBRVjB5bjypehzNXhzFbgTlchiZjljhkhzRplixtozNwozF1qzp4
  13. q0BehERmhENli0dshUZvjktylk1wkE92kltvgVBwiVp1g1lyiVl1il95j1B3l1V3klh6lmB2iWt7
  14. lUWDuUaIvEqCskmGul6Col2FqVSLtVONvVqMtl+NsWaInmmAlGyGnHOGlHGHmXGKnnqJk3mMm3uR
  15. lX2Qn2SGpmqIoW+Pp2yOrGeRuXGLoneOoHaPo3STp3eSrXyRonWZuX2gvmOWwW2aw2meynOfwnGh
  16. yXuhw3yly3iqz3ypz3Sl0HCp1pt+Ha6ED6SAE6yDGqeRF7OEBbqTCriTFr6fEKyJLaODMKWWJqWS
  17. M7WTI7aWN62iJrqlKrekOJiOR5uRTKSTRqaXVa2bV7mZR7mdVKmeZ62da62ec7Cfd7ujRrCmXrGt
  18. W7yoWq6jaqyicbWga7OpbbqpbbSrebmueMGXC8SaFcSZJcOcNcqjGtSoHc2pJ8yrOcG1P9iuKdG4
  19. LdC5PtmwPNq5MN29PcurScqtWtG8S9uwS9G8X921Xsmvbc2yd9C9cN/AUNHAfeHKRePMUuDDYOTP
  20. ZODFcubPdOLIfoKPmIGZq4qcrIGasYedsYOgs4eiv5euvoSjwIapx4KozYSrzI6wzoaw1Iux1Y+1
  21. 1oq12JSyz5K00Ji305i72qC706C92Z3B3JnA4aTC26vF3KXI5K/Q6s/CjtTOgdvGjtLHmtPNltTP
  22. odTQreXRgunXk+nZp+/ki+zimu/lqQAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAABAAEAA
  23. AAj/AP8JHEiwoEGB16qdiVMmzh1p1KhNi1bnzBk809Ic3MixI0czNKhUK5du3bl06cqpVGlOnTpz
  24. 5M60cOOxps2BaSDI+faNGzdx38B92zYunE+f4cQdNTdFg52bUA+mMTCHULdAe7JtA1SIkCBtgsIS
  25. 8hookLay274I0Bi17b8GFgqN+XFmWpQvgPj48ZNXr19Affj0yetHhQK3UeEs+CBGBbSBV4SImSyG
  26. Dx/KYsLwGZN5cpcAZhDflENgAgG2AxEE2SJmi+stXMQc6UK7y5HbRwgcFl3zzYTfjwl2kLCDyBYj
  27. Ro4kx32EyG0iQwoEyMPbo5XfE1ALnODBwwcdO8IH/9kRpHx5HkF6iCAQAEP1jlh+W4AR/N+ZCRs+
  28. 6Peuvz//Dx2Yxp577230hQUfnCACGNhY84YIGXwgggggiKBfB/oh6MEEFkRAwIcCEFigQW+ssEIQ
  29. K4jgww8liGDiixNeiOAH+VGwwAIftjfiQXGUMEQRQwzxYnpDCCFkihd+YAEHHFhgwQQIgCjijgPF
  30. QcILLwjxgwo9/PCCl1i+oIIJImA4o5MdQklAiFQWBA0ba8S5RhppoNEGGmiwkQYdU2DIJJpoYkfA
  31. AFO2CVUaC8gHYAdocvDboIW6NcUUL6DQggssXMrCppyG6SmWKpSG4AQdMFoBBRQ8GcEC7qWCCies
  32. oP8CCiquhOLRFBgIoIQe5KCUjjnnoIMOT910sw0hgCRr2RhkdDGECE9y4J2Tp1KwqgLucWIMPdzW
  33. Q487nIDC0QsFMCAOOy+xRI43xnaDbF+XieHFbLiNwKGSS6JZwbXuZYJMPQADzO0pmxz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VkDoxfH/e0x0ita/2G
  61. C1jQIhbNKAgx6FyJsVPpFOQ8bamdFucX2wIXdKZHQX5BiVh4Qt2GIoYwmHYyw6LMGTnfhQkp4Yto
  62. t6ISlJAF5qduDGYYw/NmPXbObWGLWlTiGac4xSpIkXpPgLwgyNhWsY9tbGKjNee6oH0lfvELT1Ri
  63. +auX+SmUzfNkN+PYwzgG7Xchi+57ghjR/70rCKfPc24pO87L8MUwfLH08It/ILkPqjEaTf9hFBX8
  64. 7n9/QXLP//73f0cBAQA7'''
  65.  
  66. f = StringIO(base64.decodestring(py_gif_b64))
  67. logo = Image.open(f)
  68.  
  69. root = Tk()
  70. canvas = Canvas(root,width=400,height=400)
  71. canvas.pack()
  72. logo = ImageTk.PhotoImage(logo)
  73.  
  74. mouse = canvas.create_image((50,50),image=logo)
  75.  
  76. class Cv():
  77.     x,y=50,50
  78. cv=Cv()
  79.  
  80. def click(event):
  81.     x, y = (event.x, event.y)
  82.     if x > cv.x and y > cv.y and x < cv.x+80 and y < cv.y+80:
  83.         canvas.coords(mouse,(x,y))
  84.         cv.x,cv.y=x-40,y-40
  85.  
  86. canvas.bind('<B1-Motion>',click)
  87.  
  88. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement