<>Button introduce

* Button:Tkinter The button assembly is used to Python Add button to application , Text or image can be placed on the button , Button can be used to monitor user behavior , Be able to work with one
Python Function correlation , When the button is pressed , This function is called automatically .
* This time mainly introduces Button After the control is clicked text,state Operation of attribute change
* text: Text content of the button
* state: Set button component status , Optional NORMAL,ACTIVE, DISABLED. default NORMAL.
<> Examples

* Create a clickable button Button(root, text=" Click me to test ", command=click_me) #
Button copy is : Click me to test , Call after clicking click_me function
* Create a non clickable button Button(root, text=" I can't be clicked ", state=DISABLED) #
Button copy is : I can't be clicked , The status is non clickable ( Ash setting )
* Click the button to change the copy , And modify the status to : Cannot point from tkinter import * root = Tk() root.geometry(
'200x200') root.resizable(width=False, height=False) root.title('Button Test')
def click_me(): """ modify btn Control text Properties and state""" btn["text"] = " Cannot point " btn['state'] =
DISABLED Label(root, text="button test").pack() #
btn After being clicked , call click_me function , take btn The copy is amended to read : Cannot point , Change the status to DISABLED( Ash setting state , Not clickable ) btn = Button(root,
text=" Click me to test ", command=click_me) btn.pack() btn1 = Button(root, text=" I can't be clicked ",
state=DISABLED) btn1.pack() root.mainloop()
* Change the button copy after the button is clicked , state , After performing a function operation , Button status reset import time from tkinter import * root = Tk()
root.geometry('200x200') root.resizable(width=False, height=False) root.title(
'Button Test') def click_me(): """ modify btn Control text Properties and state,3 Seconds later , Restore the original state """ btn["text"
] = " Cannot point " btn['state'] = DISABLED time.sleep(3) btn["text"] = " Click me to test " btn['state'
] = NORMAL Label(root, text="button test").pack() #
btn After being clicked , call click_me function , take btn The copy is amended to read : Cannot point , Change the status to DISABLED( Ash setting state , Not clickable ),3 Seconds later , Restore the original state btn =
Button(root, text=" Click me to test ", command=click_me) btn.pack() btn1 = Button(root, text=
" I can't be clicked ", state=DISABLED) btn1.pack() root.mainloop()

Technology