Mar-27-2018, 08:41 AM
I'm a newbie at python and coding in general. I am messing around with Tkinter, trying to understand it. Before I go any further can someone tell me if it's ok practice to create a class to initialise Toplevel() windows?
This is my code, please pull it to pieces:
Can someone explain what is happening here where I pas in master and then define self.master as master. Is it even ALLOWED to be a master?
This is my code, please pull it to pieces:
from tkinter import * class TopLevelWindow(): def __init__(self, master, width, height): self.master = master self.master.geometry("%sx%s+100+100" % (width, height)) self.master.title("Toplevel Window") root = Tk() top1 = Toplevel() top2 = Toplevel() TopLevelWindow(top1, "300", "300") TopLevelWindow(top2, "500", "250") root.mainloop()This code works but I really don't know what is happening, I just throw a few keywords together until it worked.
Can someone explain what is happening here where I pas in master and then define self.master as master. Is it even ALLOWED to be a master?
def __init__(self, master, width, height): self.master = master