First of all, this is my current code, essential parts of it:
class WindowDraggable():
x = 1
y = 1
def __init__(self,label):
label.bind('<ButtonPress-1>',self.StartMove);
label.bind('<ButtonRelease-1>',self.StopMove);
label.bind('<B1-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):
deltaX = event.x - self.x
deltaY = event.y - self.y
self.x = root.winfo_x() + deltaX
self.y = root.winfo_y() + deltaY
root.geometry("+%sx+%s" % (self.x,self.y))
#root is my window:
root = Tk()
#This is how I assign the class to label
WindowDraggable(label)
#All imports
from Tkinter import *
from PIL import Image, ImageTk
import sys
import re
What I am trying to accomplish is; Make the window draggable by a handle, in this case label
. I can't really describe how it behaves now, but it does move the window, simply not following the mouse.
Please bear with me as I am a total newcomer to Python. Any help is appreciated :) A rewrite of the class is okay, I know it's really badly written.