Entry
Cloning and destroying windows in Tkinter
Jul 5th, 2000 09:59
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 81, Python Snippet Support Team
"""
Packages: gui.tkinter
"""
""" cloner.py
19 Jun 99: Aha, finally I have found a way to come up with my own
dialog(-like) windows and get rid of them too. The quit method is not
suitable for this at all, but self.master.destroy works kinda good... ;)
"""
from Tkinter import *
class CloneWindow (Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.cloneButton = Button(self, text="Clone", command=self.clone)
self.cloneButton.pack()
self.quitButton = Button(self, text="Quit", command=self.master.destroy)
self.quitButton.pack()
def clone(self):
new = Toplevel()
myclass = self.__class__
myclass(new)
cloneWindow = CloneWindow()
cloneWindow.mainloop()