Tkinter of Python GUI development

Source: Internet
Author: User
Tags for in range

TK Inter

First window

 from Import *
Tk (). Mainloop ()

The current thread calls Mainloop () and changes into the event loop, and the code behind is blocked.

If you want to create multiple windows

 from Import *fromimport * for in range (5):    Thread (Target= Tk (). Mainloop). Start ()print 2333sys.stdout.flush ()#2333

Create button

The Relxx property represents the relative value of the size of the main window 0~1

 from Import *top=Tk () b=button (top,text='click') b.place ( Relx=0, rely=0.5, relwidth=1, relheight=0.1) Top.mainloop ()

Event handling

 fromTkinterImport*Top=Tk () b=button (top,text='Click') B.place (Relx=0, rely=0.5, Relwidth=1, relheight=0.1)deffoo (event): Btn=Event.widget btn['text']='clicked!'B.bind ('<Button>', foo) Top.mainloop ()

You can also directly bind the callback method when you create the button (top, Command=foo) event callback when there is no event object, cannot operate the trigger button, is not recommended to use.

Tkinter of Python GUI development

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.