button state change in tknter

Solutions on MaxInterview for button state change in tknter by the best coders in the world

showing results for - "button state change in tknter"
Leah
09 Feb 2020
1from tkinter import *
2fenster = Tk()
3fenster.title("Window")
4
5def switch():
6    if(b1['state']==NORMAL):
7        b1["state"] = DISABLED
8        b2["text"]="enable"
9    elif (b1['state']==DISABLED):
10        b1["state"]=NORMAL
11        b2["text"]="disable"
12
13#--Buttons
14b1=Button(fenster, text="Button")
15b1.config(height = 5, width = 7)
16b1.grid(row=0, column=0)    
17b2 = Button(text="disable", command=switch)
18b2.grid(row=0,column=1)
19fenster.mainloop()