"Python" User graphical interface GUI Wxpython III

Source: Internet
Author: User

Wxpython-More components

The components I've written may not be very detailed, and not the most complete, and if you want to use these components better, take a look at tutorials and other examples. Relatively simple, recommended http://download.csdn.net/album/detail/459 Sinsing Wpython Tutorial

check box checkbox

check boxes need to be built for each individual option, often constructed by: checkbox (Parent,id,label,pos,size)

The Evt_checkbox in the event refers to the event that occurs when the Bind checkbox is ticked or canceled

The class methods commonly used in a checkbox are:

IsChecked () returns TRUE or False

Set/getvalue () set/Get state, also true or false

Set/getlabel () Sets/Gets the text of the check box

Radio Box RadioButton

Construction method: RadioButton (Parent,id,label,pos,size,style=rb_group or none)

The Construction method and check box for a radio box are similar, but there is a style that is used to group. A single box group can have a number of radio boxes, but only one radio box is selected for a group. Make style=wx. Rb_group to make this box the first member of a new group, and the members that are built later will all be members of the group until a new one is opened with a rb_group.

Evt_radiobutton refers to an event that occurs when a bind RadioButton is selected

RadioButton commonly used class methods and check boxes are similar:

The Set/getvalue () value is also true/false

Set/getlabel ()

Advanced Single Box Radiobox

Elected more than a long, add radiobutton a bit cumbersome, so you can use Radiobox to construct. In addition, in appearance, Radiobox will add a thin line to the periphery of all options to split the options of different groups. In addition, Rbox also has some methods of unified management options, more convenient.

Construction method: Radiobox (Parent,id,label,pos,size,list,n,ra_specify_rows/ra_specify_cols). Others are similar, mainly a few points, the label is written in the box above the text rather than the text of the option, List gives the text of all options, n is a natural number, with the following parameter is rows or cols to indicate that the Rbox has a few rows and a few columns.

Unlike the other components, the POS and size are required in the above parameters, otherwise the error will be reported, and rows and cols will be selected to write as well, and the program automatically adjusts the other according to the number of rows or columns indicated. Size refers to the extent of the box and is not affected by how many options are available.

A little bit more complicated, just to show an example:

classMyFrame (Frame):def __init__(self,pos,size): Frame.__init__(self,none,-1,pos=pos,size=size) Totalpanel= Panel (self,-1) Totalsizer=Boxsizer (VERTICAL) Onesizer=Boxsizer (horizontal) self.rb= Radiobox (Totalpanel,-1,"Radiobox", (0,0), (200,100), ["Choicea","Choiceb","CHOICEC","choiced"],2, Ra_specify_rows) onesizer.add (self.rb) totalsizer.add (Onesizer,flag=align_center) Totalpanel.setsizer (Totalsizer)defTest (self,event):Printself.radio1.IsEnabled ()if __name__=='__main__': App=App () myframe= MyFrame ((200,200), (300,300) ) Myframe.show () app. Mainloop ()

Interface:

  

Evt_radiobox is a Radiobox event that refers to an event that has any of the options selected in box.

Its class methods are also rich:

GetCount () returns the total number of options in the box

Get/setitemlabel (n) Returns/sets the label of the item that is indexed as n in the given initialization list

FindString (...) Returns the index of the option for the associated label and returns 1 if no related string is found

GetSelection () returns the index of the selected item

SetSelection (n) make an option with index n selected

Getstringselection () returns the label of the selected item

Enableitem (N,flag) makes the option index n invalid or valid, flag is True/false

  

Drop-down options

The drop-down option is also a relatively common component, constructed by: Choice (parent,id,pos,size,list). As with Rbox, POS and size are also required, and list provides lists of options.

The class method also has Getstringselection (), GetSelection (), GetCount () and so on, no longer repeating. Just a little bit of a brain tonic.

Other selection structure There is a list box listbox, check list box Checklistbox and so on, not much to say, want to use can check the tutorial

Progress bar

The gauge can be used to add a progress bar to WX. Common construction Methods: Gauge (Parent,id,range=100,pos,size,style=ga_horizontal)

Range refers to the value of an end point specified when the progress bar is loaded, and the program will confirm that the current progress bar should be more than full. The style specifies whether the load is loaded horizontally or vertically, and is loaded vertically ga_vertical

Unlike some other components, it is not enough to construct the progress bar in the window alone, so the progress bar is static. The progress bar should be combined with a process through SetValue (..). method to update the loading of the progress bar. For example, the following example

Count = 0 while count<=100:    self.gauge.SetValue (count)    + = 1     Time.sleep (0.1)

When running to the above statement, the 1% progress bar is updated every 0.1 seconds, so the progress bar can be read after 10 seconds.

The precision Bar also has a Evt_idle event, as if the progress bar is not being read forward, it will trigger. But I think this is not very scientific, do not know what to do with it.

"Python" User graphical interface GUI Wxpython III

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.