In this chapter, we showed you how to use many of wxPython's most basic and commonly used controls. The generic version is somewhat more consistent across platforms.

■ For the display of static text labels, you can use the wx.StaticText class. There is also a version implemented completely in wxPython, called wx.lib.stattext.GenStaticText.

■ If you need a control that allows the user to enter text, the class to use is wx.TextCtrl. It allows both single and multi-line entry, as well as password masking and other effects. If the native widget supports it, you can use wx.TextCtrl to have styled text. Styles are instances of the class wx.Text-Attr, and also use wx.Font to encapsulate font information. On all systems, you can use the class, which is a wxPython wrapper around the open-source Scintilla text component, to achieve color and font styles in an editable text component.

■ To create a button, use the wx.Button class, which also has a generic counterpart, wx.lib.buttons.GenButton. A button can have a bitmap instead of a text label (wx.BitmapButton), or have its state toggle between pressed and unpressed (wx.ToggleButton). There are generic equivalents to both bitmap and toggle buttons, which have a fuller range of features than the standard versions.

■ There are a few ways to select or display numerical values. You can use the wx.Slider class to display a vertical or horizontal slider. The wx.SpinCtrl displays a text control with up and down buttons to change a numerical value. The wx.Gauge control displays a progress bar indicator of a number.

■ You can choose from among a series of controls for letting the user pick from a list of options. The best control to use is based on the number of options, whether the user can select more than one, and the amount of screen space you want to use. Checkboxes are managed with the wx.Check-Box class. There are two ways to get radio buttons: wx.RadioButton gives a single radio button, while wx.RadioBox gives a group of buttons displayed together. There are several list display widgets that are used similarly. A list box is created with wx.ListBox, and you can add checkboxes by using wx.CheckListBox. For a more compact pull-down, use wx.Choice. wx.Combo-Box combines the features of a list and a text control.

Now that we've covered the basics of common widgets, in the next chapter we'll discuss the different kinds of frames that you can use to contain them.

Was this article helpful?

0 0

Post a comment