Newbie TKinter question

Ged gedb at rushcoding.co.uk
Sun Dec 1 06:57:43 EST 2002


I'm just learning how to make windows with TKinter, and I have a bit
of a puzzler with the following code:

-----------------------------------------------------------------------------
from Tkinter import * # Interface to Tk widgets
class Application(Frame):
    
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
        self.name = StringVar()
        self.createWidgets()
        
        
    def createWidgets(self):
        self.quitButton = Button ( self, text="Quit",
command=self.quit )
        self.quitButton.grid()
        
        self.nameEntry = Entry( self, textvariable=self.name)
        self.nameEntry.grid()
        
        #This is the problem line
        #self.name.set("Done")
        
app = Application() # Instantiate the application class
app.master.title("Sample application")
app.mainloop() # Wait for events
--------------------------------------------------------------------------

This code works fine.

However, when I comment the code self.name.set("Done") then the window
fails to close properly when use the the x icon on the window itself. 
The quite button on the dialogue works fine.

I'm using



More information about the Python-list mailing list