
February 18th, 2004, 04:47 PM
|
 |
Mini me.
|
|
Join Date: Nov 2003
Location: Cambridge, UK
|
|
This example is similar to the last but uses a wait loop on a child window. The advantage in this code is that the main window remains open even though the child is destroyed and then rebuilt.
Code:
from Tkinter import *
again = False
class App:
def __init__(self, master):
global again
self.master = master
again = False
self.quit_button = Button(self.master, text="QUIT", fg="red", command=self.quit)
self.quit_button.pack(side=LEFT)
self.rep_button = Button(self.master, text="Repeat", command=self.repeat)
self.rep_button.pack(side=LEFT)
def wait(self):
self.master.wait_window()
def quit(self):
self.master.destroy()
def repeat(self):
global again
again = True
self.quit()
root = Tk()
while True:
mywin = Toplevel()
app = App(mywin)
app.wait()
if not again:
break
root.mainloop()
One of these examples should apply to your problem  .
Grim
|