Newbie Tkinter: how to quit window? (Win98, IDLE, Python 2.0b)

Kirby Urner urner at alumni.princeton.edu
Thu Sep 21 18:25:01 CEST 2000


Kirby Urner <urner at alumni.princeton.edu> wrote:

Here's a workaround that gets me the behavior I want, i.e.
hitting Quit both returns to IDLE _and_ kills the window.

# simple graphing

from Tkinter import *

class graph:

    def __init__(self):
        self.root = ""
        
    def drawgraph(self):
        self.root = Tk()        
        canvas = Canvas(self.root,height=400,width=400, bg='white')
        canvas.pack()
        Button(self.root,text='Quit',command=self.quit).pack()
        self.root.mainloop()

    def quit(self):
        self.root.quit()
        self.root.destroy()

Kirby



More information about the Python-list mailing list