| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
Widget
This is the common widget base class, which provides most of the wrapping functionality.
Widgets are manipulated (mostly) through attributes - and these can
all be set by XML attributes. Derived widgets will have other
attributes. Please see their New Attributes sections. The types
of the attributes are pretty straightforward, but note that Position
and Color attribute types will also accept fife.Point and
fife.Color values.
These attributes are convenience/shorthand versions of above mentioned attributes and assignment will reflect the associated attributes values. E.g. the following is equivalent:
# Set X position, leave Y alone widget.x = 10 # Same here posi = widget.position widget.position = (10, posi[1])
Here they are.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
ATTRIBUTES = [Attr('name'), PointAttr('position'), PointAttr('
|
|||
DEFAULT_NAME = '__unnamed__'
|
|||
DEFAULT_HEXPAND = 0
|
|||
DEFAULT_VEXPAND = 0
|
|||
DEFAULT_MAX_SIZE = 500000, 500000
|
|||
DEFAULT_SIZE = -1,-1
|
|||
DEFAULT_MIN_SIZE = 0, 0
|
|||
DEFAULT_HELPTEXT = u""
|
|||
DEFAULT_POSITION = 0, 0
|
|||
DEFAULT_FONT = "default"
|
|||
DEFAULT_BORDER_SIZE = 0
|
|||
DEFAULT_POSITION_TECHNIQUE = "explicit"
|
|||
DEFAULT_COMMENT = u""
|
|||
HIDE_SHOW_ERROR = "
|
|||
base_color = ColorProperty("BaseColor")
|
|||
background_color = ColorProperty("BackgroundColor")
|
|||
foreground_color = ColorProperty("ForegroundColor")
|
|||
selection_color = ColorProperty("SelectionColor")
|
|||
style = property(_getStyle, _setStyle)
|
|||
parent = property(_getParent, _setParent)
|
|||
name = property(_getName, _setName)
|
|||
x = property(_getX, _setX)
|
|||
y = property(_getY, _setY)
|
|||
width = property(_getWidth, _setWidth)
|
|||
height = property(_getHeight, _setHeight)
|
|||
min_width = property(_getMinWidth, _setMinWidth)
|
|||
min_height = property(_getMinHeight, _setMinHeight)
|
|||
max_width = property(_getMaxWidth, _setMaxWidth)
|
|||
max_height = property(_getMaxHeight, _setMaxHeight)
|
|||
size = property(_getSize, _setSize)
|
|||
position = property(_getPosition, _setPosition)
|
|||
font = property(_getFont, _setFont)
|
|||
border_size = property(_getBorderSize, _setBorderSize)
|
|||
is_focusable = property(_isFocusable, _setFocusable)
|
|||
|
|||
|
Inherited from |
|||
|
|||
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
Execute a dialog synchronously. As argument a dictionary mapping widget names to return values is expected. Events from these widgets will cause this function to return with the associated return value. This function will not return until such an event occurs. The widget will be shown before execution and hidden afterwards. You can only execute root widgets. Note: This feature is not tested well, and the API will probably change. Otherwise have fun:
# Okay this a very condensed example :-)
return pychan.loadXML("contents/gui/dialog.xml").execute({ 'okButton' : True, 'closeButton' : False })
|
Requests focus. The widget must be focusable in order for this to work. See the is_focusable property. |
Matches the widget against a list of key-value pairs. Only if all keys are attributes and their value is the same it returns True. |
Add a callback to be executed when the widget event occurs on this widget. The callback must be either a callable or None. The old event handler (if any) will be overridden by the callback. If None is given, the event will be disabled. You can query isCaptured wether this widgets events are currently captured. It might be useful to check out tools.callbackWithArguments.
|
Execute the Layout engine. Automatically called by show. In case you want to relayout a visible widget. This function will automatically perform the layout adaption from the top-most layouted widget. To make this clear consider this arrangement:
VBox 1
- Container
- VBox 2
- HBox
- Label
If you call adaptLayout on the Label the layout from the VBox 2 will get recalculated, while the VBox 1 stays untouched. @param recurse Pass False here to force the layout to start from this widget. |
This method is called just before the widget is shown. You can override this in derived widgets to add finalization behaviour. NOTE:
|
This method is called just before the widget is hidden. You can override this in derived widgets to add finalization behaviour. |
Find all contained child widgets by attribute values. Usage: closeButtons = root_widget.findChildren(name='close') buttons = root_widget.findChildren(__class__=pychan.widgets.Button) |
Create a dictionary of child widgets with the keys being their name. This will contain only Widgets which have a name different from "__unnamed__" (which is the default). @param include_unnamed Defaults to false. If this is true unnamed widgets are added, too. The values are lists of widgets, so not only unique names are handled correctly. Usage:
children = widget.getNamedChildren()
for widget in children.get("info",[])
print widget.name , " == info"
|
Find the first contained child widgets by attribute values. Usage: closeButton = root_widget.findChild(name='close') |
Find first contained child widget by its name. Note that this is the fast version of findChild(name="...") and that you don't have to call this explicitly, it is used if possible. |
This function adds a widget as child widget and is only implemented in container widgets. You'll need to call adaptLayout if the container is already shown, to adapt the layout to the new widget. This doesn't happen automatically. |
This function inserts a widget a given index in the child list. See addChild and insertChildBefore |
Inserts a child widget before a given widget. If the widget isn't found, the widget is appended to the children list. See addChild and insertChild |
Add multiple widgets as children. Only implemented for container widgets. See also addChild Usage:
container.addChildren( widget1, widget2, ... )
# or you can use this on a list
container.addChildren( [widget1,widget2,...] )
|
This function removes a direct child widget and is only implemented in container widgets. You'll need to call adaptLayout if the container is already shown, to adapt the layout to the removed widget. This doesn't happen automatically. |
Remove a list of direct child widgets. All widgets have to be direct child widgets. To 'clear' a container take a look at removeAllChildren. See also removeChild. Usage:
container.removeChildren( widget1, widget2, ... )
# or you can use this on a list
container.removeChildren( [widget1,widget2,...] )
|
This function will remove all direct child widgets. This will work even for non-container widgets. |
Convenience function to map widget events to functions in a batch. Subsequent calls of mapEvents will merge events with different widget
names and override the previously set callback. You can also pass
|
Set the initial data on a widget, what this means depends on the
Widget. In case the widget does not accept initial data, a |
Set the user-mutable data on a widget, what this means depends on the
Widget. In case the widget does not accept data, a |
Get the user-mutable data of a widget, what this means depends on the
Widget. In case the widget does not have user mutable data, a |
Distribute initial (not mutable by the user) data from a dictionary over the widgets in the hierachy using the keys as names and the values as the data (which is set via setInitialData). If more than one widget matches - the data is set on ALL matching widgets. By default a missing widget is just ignored. Use it like this:
guiElement.distributeInitialData({
'myTextField' : 'Hello World!',
'myListBox' : ["1","2","3"]
})
|
Distribute data from a dictionary over the widgets in the hierachy using the keys as names and the values as the data (which is set via setData). This will only accept unique matches. Use it like this:
guiElement.distributeData({
'myTextField' : 'Hello World!',
'myListBox' : ["1","2","3"]
})
|
Collect data from a widget hierachy by names into a dictionary. This can only handle UNIQUE widget names (in the hierachy) and will raise a RuntimeError if the number of matching widgets is not equal to one. Usage: data = guiElement.collectDataAsDict(['myTextField','myListBox']) print "You entered:",data['myTextField']," and selected ",data['myListBox'] |
Collect data from a widget hierachy by names. This can only handle UNIQUE widget names (in the hierachy) and will raise a RuntimeError if the number of matching widgets is not equal to one. This function takes an arbitrary number of widget names and returns a list of the collected data in the same order. In case only one argument is given, it will return just the data, with out putting it into a list. Usage:
# Multiple element extraction:
text, selected = guiElement.collectData('myTextField','myListBox')
print "You entered:",text," and selected item nr",selected
# Single elements are handled gracefully, too:
test = guiElement.collectData('testElement')
|
This function will print a list of all currently named child-widgets to the standard output. This is useful for debugging purposes. |
Try to shrink the widget, so that it fits closely around its content. Do not call directly. |
Try to expand any spacer in the widget within the current size. Do not call directly. |
Recursively call resizeToContent. Uses deepApply. Do not call directly. |
Recursively call expandContent. Uses deepApply. Do not call directly. |
str(x)
|
repr(x)
|
|
|||
ATTRIBUTES
|
HIDE_SHOW_ERROR
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Sat Feb 11 00:00:29 2012 | http://epydoc.sourceforge.net |