I have a Toplevel class DesignWindow
which hold a 10x10 array of buttons, when I call it in the way discussed here: Tkinter; Toplevel in a new class it creates the window within the last.
What have I done wrong? The only difference is that my 'root' window (with the menu) is a tk.Frame instead of the tk.Tk in the quoted question.
class MainWindow(tk.Frame):
"""Draw the main window"""
def __init__(self, parent):
tk.Frame.__init__(self, parent, background='grey')
self.parent = parent
self.menuscreen = MenuScreen(self)
self.grid()
self.menuscreen.design.grid(column=0, row=0)
class MenuScreen(tk.Frame):
"""Create the menu screen"""
def __init__(self, parent):
self.design = tk.Button(command=self.create_design_window, text="Design")
def create_design_window(self):
self.design_window = DesignWindow(self)
class DesignWindow(tk.Toplevel):
"""Frame for design mode"""
def __init__(self, main):
tk.Toplevel.__init__(self)
EDIT Generation of the Buttons:
self.btn = [[0 for x in range(10)] for x in range(10)]
for column in range(10):
for row in range(10):
self.btn[column][row] = tk.Button(main)
self.btn[column][row].grid(column=column, row=row)