Button controls
No function button
The Text property of the button displays the
No matter how the form is resized, it is always centered in the top-most upstream of the form
Click Trigger Event
The command property of the Button invokes the method to execute the event
For example, there is a method
def A (): print (' clicked button ')
Click the button 3 times and execute 3 times a method
set the width and height width,height properties of a button
Method One
Tkinter. Button (form, text= ' Hello button ', width=10,height=1). Pack ()
or (note that the first line has no. pack ())
When
T1=tkinter. button (form, text= ' button ')
Method Two
t1[' width ']=20t1[' height ']=2
T1.pack ()
Method Three
T1.configure (width = 30,height = 3) t1.pack ()
Button Status State property
The default is NORMAL, and there is a state that active does not currently know what effect
Disable
Tkinter. Button (form, text= ' Hello button ', Width=10,height=1,state=tkinter. DISABLED). Pack ()
foreground and background color of the button
FG: foreground color (font colors)
Tkinter. Button (form, text= ' Hello button ', width=10,height=1,fg= ' red '). Pack ()
bg: Background color
Tkinter. Button (form, text= ' Hello button ', width=10,height=1,bg= ' Blue '). Pack ()
Where the text appears on the button
Property anchor
Its value has these 8 directions
N (North), S (south), W (west), E (East) and NE,NW,SE,SW,
Already Northwest direction for example
Tkinter. Button (form, text= ' Hello button ', width=20,height=5,anchor= ' NW '). Pack ()
Button style
Property relief
Tkinter. Button (form, text= ' Hello button ', Relief=flat). Pack ()
The test did not succeed ...????
(6) Python tkinter-button