"Go" python3.3 graphical interface

Source: Internet
Author: User

Python is graphically implemented by invoking the Tkinter library. Windows in Python are more content-sized and automatically scaled.

    • Example 1: Create a simple window:
    • Import *    # introduces the Tkinter library root = Tk ()    ## main Window's member function, and the main window works to start accepting mouse and keyboard actions. 

    • Example 2: Add some controls, such as Label,button
    • From tkinter Import *root = Tk (classname= ' aaa ') label = label (root) label[' text "] = ' This is a label. ' Label.pack ()    #和控件的布局排版有关的设置root. Mainloop ()
      • Label1 = lable (root) #参数为root表明这个控件是root主窗口的成员控件
      • label1[' text '] = ' This is a label ' #设置标签的text属性值
  • Example 3: Event of a control, handled by a function
  • From TkinterImport *Def On_click (): Button[ ' text "=  ' it is Changed. root = Tk (Classname= ' aaa  ") button = button (root) button[ ' text "=  ' change it "button[command "= On_click #  event correlation function button.pack () Root.mainloop ()       
      • A variable is a relationship that is associated at run time rather than before and after the code, so button[' text ' = ' It is changed. ' does not report undefined errors.

"Go" python3.3 graphical interface

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.