Wednesday, March 20, 2013

Define command to destroy window of Python

Define command to destroy window of Python
Define command to destroy window of Python


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

def quit():
    global tkTop
    tkTop.destroy()

tkTop = tkinter.Tk()
tkTop.geometry('300x200')

tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=quit)
tkButtonQuit.pack()

tkinter.mainloop()