[Learning record] face Wxpython's long-distance running (100 meters: Wxpython installation, related documents, WX. App,wx. Frame)

Source: Internet
Author: User

By the teacher request, already had to carry on the development of the graphical interface, because the program ontology uses Python to write, so naturally the first time to develop the graphical interface to choose the Wxpython,wxpython is a very good GUI graphics library, writing is relatively simple and convenient.

Direct pip install Wxpython can be installed.

Demo program and other official related documents: https://extras.wxpython.org/wxPython4/extras/

Official Document: Https://docs.wxpython.org/wx.1moduleindex.html

Here's the point: first of all, the usual Hello world.

Import Wxapp=' Hello World ') win. Show () app. Mainloop ()

Run this code, the following window will pop up

The first is the most important wx. App category, official documents are as follows:

The general meaning is: each reference that uses WX must have a unique WX. App instance, and all UI objects are created after the instance of Wx.app is created. Wx. The creation of the app ensures that all GUI platforms and other content related to Wxpython are fully initialized. Wx. App.mainloop () is another important statement that is used to receive GUI events (event)

The second is WX. Frame class:

The frame class is the kind of box that we usually see that has a caption box, which can hold the window class but not dialog and frame. The constructor is as follows

frame (parentid =id_anytitle= " pos=defaultposition ,size=defaultsize style=default_frame_stylename =framenamestr)

The parent is used to specify the parents class, the ID is an integer, the contents of the title are displayed to the title, POS is the initial position, the size is the window (x, y), the style has a fixed value, the name does not tube.

< Span class= "p" > < span class= "n" > The common values of style are as follows:

< Span class= "p" > < span class= "n" > wx. Default_frame_style: Default value equals WX. Minimize_box|wx. Maximize_box|wx. Resize_border|wx. System_menu|wx. Caption|wx. Close_box|wx. clip_children 

Wx. Iconize: The initial minimized form appears

Related events for frame:

Evt_close: This event occurs when a frame is being closed, either by clicking the Red Fork or by calling WX. Window.close

Evt_iconize: Minimized window

Evt_menu_open: When a menu is opened

Evt_menu_close: When a menu has just been closed

Evt_menu_highlight: A highlight event for a menu, self. Bind (WX. Evt_menu_highlight, Action function, Self.gg.GetMenuItems () [0]), is a wx that needs to be monitored. The MenuItem object.

Evt_menu_highlight_all: You need to bind self as follows. Bind (WX. Evt_menu_highlight_all, action function, WX. MenuBar Class), responds when the mouse hovers over any menu, fails to respond to evt_menu_highlight events when evt_menu_highlight_all occurs

Main interface:

Createstatusbar (Self, number=1, style=stb_default_style, id=0, name=statusbarnamestr ):

Create the bottom status bar, number control the status bar has a few columns, style reference WX. The style mentioned in StatusBar returns the WX created. StatusBar instances

Createtoolbar (Self, style=tb_default_style, id=id_any, name=toolbarnamestr ):

Create a toolbar on the left or top, and return the created WX. Toolbar instances

Getclientareaorigin, Getmenubar,getstatusbar,getstatusbarpane,gettoolbar:

Is the return of the related property or parameter.

Pushstatustext (self,text,number=0):

Add text to the status bar, text is a string, number marks the status bar

setmenubar ( self , menuBar setstatusbar ( self , statusBar setstatusbarpane ( self , n setstatustext self , text , number=0 ), setstatuswidths ( self , widths setstatuswidths ( self , widths :

Set related properties or add the menu status bar.

So here's the first part about Wxpython. Update Next issue

[Learning record] face Wxpython's long-distance running (100 meters: Wxpython installation, related documents, WX. App,wx. Frame)

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.