You need to specify a wizard for the second button. Otherwise, it will be packed in the first window. This is necessary not only for Button , but also for other widgets and objects other than gui, such as StringVar .
Quick fix: add a new frame as the first argument to your Button in Demo2 .
Perhaps better: You currently have Demo2 inheriting from tk.Frame , but I think it makes sense if you change Demo2 to something like this,
class Demo2(tk.Toplevel): def __init__(self): tk.Toplevel.__init__(self) self.title("Demo 2") self.button = tk.Button(self, text="Button 2", # specified self as master width=25, command=self.close_window) self.button.pack() def close_window(self): self.destroy()
Just like a suggestion, you should only import tkinter once. Select one of the first two import statements.
Jared Apr 20 '13 at 1:28 2013-04-20 01:28
source share