Python graphical interface

Source: Internet
Author: User

A brief description of how to use Tkinter for GUI programming.

 fromTkinterImport*ImportTkinter.messagebox as MessageBox" "in the GUI, each button, Label, input box, and so on, is a widget. Frame is a widget that can accommodate other widgets, and all widgets are grouped together as a tree. The pack () method adds the widget to the parent container and implements the layout. Pack () is the simplest layout, and grid () allows for more complex layouts. In the Createwidgets () method, we create a label, two button, and a text box. When quit is clicked, triggering self.quit () causes the program to exit when Hello is clicked, triggering Self.hello (), displaying the message interface" "classApplication (Frame):def __init__(self,master=None): Frame.__init__(Self,master) Self.pack () self.createwidgets ()defcreatewidgets (self): Self.nameinput=Entry (self) self.nameInput.pack () Self.hellolabel=label (self,text='Hello World') Self.helloLabel.pack () Self.hellobutton=button (self,text='Hello', command=Self.hello) self.helloButton.pack () Self.quitbutton=button (self,text='Quit', command=self.quit) self.quitButton.pack ()defHello (self): name=self.nameinput.get ()or ' World'Messagebox.showinfo ('Message','Hello%s'%name)if __name__=='__main__': App=application ()" "Set Window caption" "App.master.title='liuruiqing'    " "Main program Loop" "App.mainloop ()

Python 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.