Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- class WindowDraggable():
- def __init__(self, root):
- self.root = root
- root.bind('<ButtonPress-2>', self.StartMove)
- root.bind('<ButtonRelease-2>', self.StopMove)
- root.bind('<B2-Motion>', self.OnMotion)
- def StartMove(self, event):
- self.x = event.x
- self.y = event.y
- def StopMove(self, event):
- self.x = None
- self.y = None
- def OnMotion(self,event):
- x = (event.x_root - self.x - self.root.winfo_rootx() + self.root.winfo_rootx())
- y = (event.y_root - self.y - self.root.winfo_rooty() + self.root.winfo_rooty())
- root.geometry("+%s+%s" % (x, y))
- WindowDraggable(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement