Application of the Python gui (wxpython)

Source: Internet
Author: User

Start by implementing a simple Notepad

Import Wxapp = WX. APP() win = WX. Frame(None, title ="Simple Editor", size = (410,335)) bkg = WX. Panel(Win)#背景组件Loadbutton = WX. Button(Win, label ="Open", pos = (225,5), size = ( the, -)) Savebutton = WX. Button(Win, label ="Save", pos = (315,5), size = ( the, -) filename = wx. Textctrl(Win, pos = (5,5), size = ( About, -)) contents = WX. Textctrl(Win, pos = (5, *), size = (390,260), style = WX. TE_multiline | Wx. HScroll)#水平和垂直滚动条Win. Show() app. Mainloop()

Simple memo program for automating smart layouts

ImportWx def load(event):FILE = open (filename. GetValue ()) contents. SetValue (File.read ())#读入到contents中File.close () def save(event):FILE = open (filename. GetValue (),' W ') File.write (contents. GetValue ()) file.close () app = WX. APP () win = WX. Frame (None, title ="Simple Editor", size = (410,335)) bkg = 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 =1, flag = WX. EXPAND | Wx. Left | Wx. BOTTOM | Wx. Right, Border =5) bkg. Setsizer (VBox) win. Show () app. Mainloop ()

Application of the Python gui (wxpython)

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.