The libavg.widget module contains high-level user interface elements such as buttons and list boxes. Widgets are fully skinnable (using the Skin class and an xml configuration file) and multitouch-enabled. Sample code for all widgets can be found in the widget.py sample.
Note
The widget module is experimental. Functionality and interface are still in flux and subject to change.
Bases: libavg.widget.button.Button
A Button that is created from image files. Internally, it creates two or three ImageNode s and uses them as constructor parameters for Button.
Bases: libavg.widget.button.ToggleButton
A ToggleButton that is created from image files. Internally, it creates image nodes for the src parameters and uses them as constructor parameters for ToggleButton.
Bases: libavg.widget.button._ButtonBase
A button that shows different user-supplied nodes depending on its state. Possible button states are up, down and disabled. The nodes are attached as children to the Button on construction. For a simple button, image nodes can be passed. Uses the TapRecognizer to detect clicks.
Parameters: |
|
---|
Messages:
True if the button accepts input. If the button is disabled, it shows the disabledNode.
Bases: libavg.widget.button.ToggleButton
This is a classic checkbox with text to the right.
Bases: libavg.widget.base._StretchNodeBase
A node that stretches its graphics to fill the size given horizontally. It is used as base component for scrollbars and buttons. The base bitmap is split into three parts: left, center and right. The left and right parts are endsExtent wide and generated from the corresponding parts of the source bitmap. The center part is generated from a one pixel wide slice of the source bitmap and stretched to fill the space left between the left and right parts.
Parameters: |
|
---|
Bases: libavg.widget.base._StretchNodeBase
A node that stretches its graphics to fill the size given horizontally and vertically. It is used as base component for scrollareas. Similar to HStretchNode, the base bitmap is split and partial bitmaps are extracted. Four corner bitmaps of size endsExtent stay the same size, four one-pixel-slice bitmaps fill the sides, and a single one-pixel bitmap is used to fill the center area.
Parameters: |
|
---|
Bases: libavg.avg.DivNode
Implements an onscreen keyboard that turns mouse clicks or touches into key presses. The keyboard is completely configurable. Keyboard graphics are determined by the two image files in bgSrc and downSrc. Keys can be defined as rectangles anywhere on these images. Works for both single-touch and multitouch devices. Generates events when keys are pressed or released. An additional enlarged image of the key being pressed can be rendered above a pending touch as well by using feedbackSrc.
Needs offscreen rendering support on the machine to generate individual key images from the image files supplied.
Parameters: |
|
---|
Messages:
Keyboard emits messages on every key press and release: To get these messages, call Publisher.subscribe().
- DOWN(keycode)¶
Emitted whenever a key (command or char) is pressed.
- UP(keycode)¶
Emitted whenever a key (command or char) is released.
- CHAR(char)¶
Emitted whenever a character is generated. This is generally when a char key is released and takes into account shift/altgr status.
Resets any sticky keys (shift, altgr) to their default state.
Creates key definitions for a row of uniform keys. Useful for creating the keyDefs parameter of the Keyboard constructor. All the keys get no repeat functionality.
Parameters: |
|
---|
Bases: libavg.avg.DivNode
A composite control that incorporates a Slider, a play/pause button and text widgets that display the time. By itself, the MediaControl is independent of a media node. The controlling application is responsible for keeping track of media node and MediaControl state and syncing the two.
Messages:
- PLAY_CLICKED()¶
Emitted when the play/pause toggle is switched to play.
- PAUSE_CLICKED()¶
Emitted when the play/pause toggle is switched to pause.
- SEEK_PRESSED()¶
Emitted when the user starts dragging the seek thumb.
- SEEK_MOTION(curTime)¶
Emitted when the user moves the seek thumb.
- SEEK_RELEASED()¶
Emitted when the user releases the seek thumb.
Duration of the medium in milliseconds.
Current media time in milliseconds.
Switches to play mode by toggling the button.
Switches to pause mode by toggling the button.
Bases: libavg.avg.DivNode
A horizontal bar-shaped UI element that indicates the progression of an operation.
Tuple giving minimum and maximum value.
Bases: libavg.avg.DivNode
A rectangular area that allows a user to choose a view into arbitrary content. The content can be larger than the ScrollArea, in which case scroll bars can be used to allow the user to choose which part to view. Dragging the content to determine the viewport is also supported. A ScrollArea uses ScrollPane and ScrollBar objects internally.
Messages:
The size of the contentNode.
The position of the content within the area.
Bases: libavg.widget.slider.SliderBase
A vertical or horizontal scroll bar.
Messages:
Minimum and maximum values for the thumb.
Bases: libavg.avg.DivNode
A rectangular view into arbitrary content. No user interaction is implemented.
A Skin determines the appearance of any user interface elements that use it. Skin configuration is determined by an xml file. This xml file determines the bitmaps to use and the sizes of various components. It also determines the fonts used by the elements. Skinnable user interface elements include TextButton, Slider, ScrollBar, ProgressBar, ScrollArea, CheckBox and MediaControl. In addition, the fonts defined can be accessed by the application.
The default skin xml file is located at src/python/data/SimpleSkin.xml. It provides a good basis from which to create your own skin.
Parameters: |
|
---|
A dictionary of FontStyle objects created from the xml configuration file.
Bases: libavg.widget.slider.SliderBase
Sliders are horizontal or vertical bar with a draggable thumb that can be used to set a value. In contrast to a scroll bar, the slider’s thumb has no range.
Messages:
Minimum and maximum values for the thumb.
Bases: libavg.avg.DivNode
A DivNode that keeps a map of child nodes and shows only one of the map members at any time.
Parameters: | nodeMap (map) – A map id->node that contains the nodes to switch between. |
---|
Can be used to set the nodeMap after construction if no node map was set before.
The id of the visible child node.
Bases: libavg.widget.button.Button
A Button that is created using the given Skin and a text.
The string displayed on the button.
Bases: libavg.widget.slider.Slider
Works like a ProgressBar with an additional slider thumb.
Bases: libavg.widget.button._ButtonBase
A button that can be used to toggle between checked and unchecked states. Classical GUI checkboxes are an example of this kind of button.
A ToggleButton has a total of six visual states. In addition to the distinction between checked and unchecked, a button can be enabled or disabled. Buttons also change their appearance as soon as they are touched, leading to two further states. For each visual state, a node is passed as constructor parameter. The constructor attaches the nodes to the ToggleButton.
Uses the TapRecognizer to detect clicks.
Parameters: |
|
---|
Messages:
To get these messages, call Publisher.subscribe().
- Button.PRESSED()¶
Called when a tap on the button is initiated.
- Button.RELEASED()¶
Called when a tap on the button ends. Emitted for both successful and aborted taps.
- Button.TOGGLED()¶
Called when the button changes from unchecked to checked or vice-versa.
The state of the toggle.
Determines whether the button accepts input.
Bases: libavg.widget.base._StretchNodeBase
A node that stretches its graphics to fill the size given vertically. It is used as base component for scrollbars. The base bitmap is split into three parts: top, center and bottom. The top and bottom parts are endsExtent wide and generated from the corresponding parts of the source bitmap. The center part is generated from a one pixel high slice of the source bitmap and stretched to fill the space left between the top and bottom parts.
Parameters: |
|
---|