Good Afternoon,
I've been attempting to implement the script from this page: Tkinter: Mouse drag a window without borders, eg. overridedirect(1)
To work with my tkinter top Level window. This is how my tkinter window is initialized:
def __init__(self, master=None):
tkinter.Tk.__init__(self, master)
I then hide the root window and start up a top level window. Which i'm doing so that I can currently minimize and re-open the top level window.
#Hide Root
self.attributes("-alpha",0.0)
self.attributes("-topmost", True)
#Top Level Window
top_level = tkinter.Toplevel(self)
top_level.geometry("600x300")
top_level.overrideredirect(True)
top_level.config(bg="#1e1e1e")
Now I try and get the window to move using this chunk of code here from the page listed above. (I've changed some of the variables to match my window)
top_level.bind("<ButtonPress-1>", top_level.StartMove)
top_level.bind("<ButtonRelease-1>", top_level.StopMove)
top_level.bind("<B1-Motion>", top_level.OnMotion)
def StartMove(top_level, event):
top_level.x = event.x
top_level.y = event.y
def StopMove(top_level, event):
top_level.x = None
top_level.y = None
def OnMotion(top_level, event):
deltax = event.x - top_level.x
deltay = event.y - top_level.y
x = top_level.winfo_x() + deltax
y = top_level.winfo_y() + deltay
top_level.geometry("+%s+%s" % (x, y))
This is the error that I receive:
Traceback (most recent call last):
File "E:/Programs/TestGUI/script_gui.py", line 2, in <module>
import authenticator
File "E:\Programs\TestGUI\authenticator.py", line 148, in <module>
root = Win()
File "E:\Programs\TestGUI\authenticator.py", line 127, in __init__
top_level.bind("<ButtonPress-1>", top_level.StartMove)
AttributeError: 'Toplevel' object has no attribute 'StartMove'
Any help would be greatly appreciated as this is one of the last things I need to do to finish this project.
Thanks