Here we will learn how to assign an action to button.
To assign action, command option needs to be used. A value (method / function) assigned to command will be triggered on button click.
below is the code to destroy the main window on click, GUI will look like as above image
command = action to perform
to destroy current window, window_name.destroy needs to assign to command option.
#project to destroy window
try:
from Tkinter import *
except:
from tkinter import *
mw = Tk()
mw.geometry("500x100+50+50")
mw.title("AETies : Automation Expert Technologies")
label = Label(mw, text='Please click on button to close window')
label.pack(side=LEFT)
btn = Button(mw, text='click here', command=mw.destroy)
btn.pack(side=LEFT)
mw.mainloop()
Comments
Post a Comment