(6) Python tkinter-button

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.