faqts : Computers : Programming : Languages : Python : Snippets : Tkinter

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 8 people (63%) answered Yes
Recently 4 of 7 people (57%) answered Yes

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()