API¶
Classes¶
-
class
humblewx.
Dialog
¶ -
__init__
(controller_class, parent, variables={}, **kwargs)¶ This constructs a
wx.Dialog
and fills it with content according to the GUI description found in this class’ docstring.Parameters: - controller_class – The class that should be used as a controller in this dialog. It will be initialized automatically.
- parent – The parent window to this dialog. Passed as first argument to the
__init__
method of thewx.Dialog
. - variables – Variables that can be accessed by name from the XML definition. Should be a mapping from strings to Python values.
- **kwargs – Additional parameters that are passed to the
__init__
method of thewx.Dialog
.
-
Configuration¶
-
humblewx.
COMPONENT_MODULES
¶ Default: [wx]
This is a list of modules where
humblewx
will search for components.By default, only
wx
components can be found. Extend or change this list to allowhumblewx
to find components defined in other modules.
GUI Description Language¶
GUI descriptions are defined in XML.
Nodes in the XML correspond to either components or sizers. Attributes correspond to arguments passed to the constructors. For example:
<Button label="Hello World" />
Will result in the following Python code:
wx.Button(..., label="Hello World")
Attribute values¶
Often components need arguments that are not strings. Attribute values in the XML are interpreted in the following order:
-
Variable
Example:
<Button label="$(name)" />
If the attribute value matches the variable pattern
$(..)
, the Python value will be fetched from the variables dictionary passed toDialog
.
-
Boolean
Example:
<Button label="True" /> <Button label="False" />
If the attribute value matches eihter
True
orFalse
, the Python value will be the corresponding boolean.
-
String
Example:
<Button label="Hello World" />
All other attribute values will be returned as Python strings.
Special nodes¶
-
BoxSizerVertical
This is the quivalent of the following Python code:
wx.BoxSizer(wx.VERTICAL)
-
BoxSizerHorizontal
This is the quivalent of the following Python code:
wx.BoxSizer(wx.HORIZONTAL)
-
FlexGridSizer
This creates a
wx.FlexGridSizer
. It supports the following attributes:-
rows
Default: 0
The number of rows this sizer should have.
-
columns
Default: 0
The number of columns this sizer should have.
-
growableColumns
A comma separated list of integers saying which columns should be growable. (Argument to
AddGrowableCol
.)
-
growableRows
A comma separated list of integers saying which row should be growable. (Argument to
AddGrowableRow
.)
-
-
StaticBoxSizerVertical
This creates a static box and a corresponding sizer used to lay out child components. All attributes are passed to the
wx.StaticBox
. The sizer is created like this:wx.StaticBoxSizer(..., wx.VERTICAL)
-
Spacer
This can only be used within a sizer.
-
StretchSpacer
This can only be used within a sizer.