First knowledge of Wxpython

Source: Internet
Author: User

Wxpython is a wxwidgets cross-platform GUI component written in C + +

Installing Wxpython

Pip Install Wxpython

ImportWXdefLoad (Event): File= open (filename. GetValue (), encoding='UTF8') contents. SetValue (File.read ()) File.close ()defSave (Event): File= open (filename. GetValue (),'W', encoding='UTF8') File.write (contents. GetValue ()) File.close () app= WX. APP ()#responsible for all initialization behind the scenes, if, WX. APP () is not available, then use WX. Pysimpleapp () instead, but is about to be deprecated#app = wx. Pysimpleapp ()Win = WX. Frame (None, title='GUI Test', Size= (410, 335))#The size of the entire windowbkg=WX. Panel (Win) Loadbutton= WX. Button (bkg, label='Open') Loadbutton.bind (WX. Evt_button, load) Savebutton= WX. Button (bkg, label='Save') Savebutton.bind (WX. evt_button,save) filename=WX. Textctrl (bkg) Contents= WX. Textctrl (bkg, Style=wx.te_multiline |WX. HScroll) Hbox=WX. Boxsizer () Hbox. ADD (filename, proportion=1, flag=WX. EXPAND) Hbox. ADD (Loadbutton, proportion=0, Flag=wx. Left, border=5) Hbox. ADD (Savebutton, proportion=0, Flag=wx. Left, border=5) VBox=WX. Boxsizer (WX. VERTICAL) VBox. ADD (Hbox, proportion=0, Flag=wx. EXPAND | Wx. All, border=5) VBox. ADD (contents, proportion=0, Flag=wx. EXPAND | Wx. Left | Wx. BOTTOM | Wx. Right, border=5.) bkg. Setsizer (VBox) win. Show ()#Hold windowApp. Mainloop ()#the window will remain hidden until it is hold.
Demo

End

First knowledge of Wxpython

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.