File: controls.txt

package info (click to toggle)
python-wpy 0.53-0.1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 832 kB
  • ctags: 1,991
  • sloc: python: 8,624; makefile: 57; sh: 24
file content (44 lines) | stat: -rw-r--r-- 2,293 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Controls

Controls are user interaction windows such as buttons and list boxes.  All controls
should be placed in Dialog Boxes, which are designed for that purpose.  It is also
possible to put controls in a View.

Creation of controls is a two-step process.  First construct the control and then
call Create() to notify the GUI to make it visible.

	b = CPushButton(parent, "OK")
	b.Create()

The basic rule is that the constructor will create a control in Python, but the
underlying GUI will not be aware of it until Create() is called.  So you may
delete or reuse controls until Create() is called.

The control will be assigned a size based on its text size, list length, or other
properties as determined by the arguments to the constructor.  That is, the control
has a self.wpySizeX and self.wpySizeY in pixels which is appropriate for the GUI
being used.  Use these sizes to do layout, and to determine the necessary size for
the container dialog box or view.  This will make your code independent of the GUI
platform being used.  For example, if a dialog box has a message control and a single
button control, construct the controls in dialog.__init__().  Set the dialog box size
to 1.2 times the message size and then add 2 times the button height.  Then the
dialog box will have an appropriate size no matter what the screen resolution
or the native control sizes may be.  Then call Create() for the controls in
OnInitDialog().  You can not call Create() earlier because the parent dialog does
not exist yet, and controls must have a parent when they are created.

Under Windows, you can tab between controls in dialog boxes provided you
set the tab control style.  To control tabbing, use
  wpyStyle = wpyStyle | wpycon.WS_TABSTOP    # Turn tabbing on
  wpyStyle = wpyStyle & ~wpycon.WS_TABSTOP   # Turn tabbing off
after control construction and before control creation.  Only CEdit
controls have tabbing by default.

Control colors are set by default, and some of them inherit the color of
their parent.
To change the color of a control, set control.wpyBrush to a background brush
and/or set control.wpyTextColor to the text color.  For example,
    o = wpy.CLabel(self, "Fit:")
    o.wpyBrush = wpy.CBrush((255, 255, 255)).Create()
    o.wpyTextColor = (255, 0, 0)
    o.Create()