Class Dialog
object --+
|
Boost.Python.instance --+
|
Dialog
- Known Subclasses:
-
This class provides fine control over the widgets within the a dialog
returned by the createDialog() function call.
Note that there is no public constructor provided. The convenience
function createDialog() is the only way to get hold of a Dialog
object.
In a dialog, the following widgets can be used: push button, toggle
button, text field, and menu.
The list of event types that will be used when registering python
callback functions is the following:
An example to illustrate a typical way to use methods of this class in
a Python script is as follows:
def myCallbackFunction1( dialog, widgetName, eventType ):
print 'Callback function name: myCallbackFunction1'
print 'Widget name:', widgetName
widgets = [ ( 'TextField', 'Show', 'Show', 'Academy Awards' ) ]
widgets.append( ('ToggleButton', 'Vote', 'Vote', True ) )
widgets.append( ('Menu', 'Meal', 'Meal', ( ['Meat', 'Salad'], 1 ) ) )
widgets.append( ('ToggleButton', 'Buy', 'I buy it', False ) )
xml = ui.makeXmlFromWidgetList( widgets, ["OK", "Cancel"] )
dialog = ui.createDialog( 'Oscar', xml, 75, 50 )
dialog.addCallback( 'Vote',
ui.EventType.ACTIVATE,
myCallbackFunction1 )
closeButton = dialog.launch()
print 'Close button clicked:', closeButton
result = dialog.getValues()
print 'Result:', result
|
|
__init__(...)
Raises an exception This class cannot be instantiated from Python |
|
|
|
|
|
|
|
addCallback(...)
Adds a Python function as an event callback to a specific widget of
the Dialog. |
|
|
|
|
disableNextClose(...)
Disable the Dialog from closing the next time a close button is
pushed. |
|
|
|
|
|
|
|
|
str
|
getStrippedText(self,
widgetName)
Gets the value of a dialog text field (or any other widget that holds
a string value) and strips whitespace characters on both ends. |
|
|
|
type
|
getValue(...)
Returns:
The value of the specified widget by name. |
|
|
dict
|
getValues(...)
Returns:
A python dictionary containing current values associated with all the
widgets of the Dialog. |
|
|
|
|
hideWidget(...)
Hide a widget/label so that it is invisible. |
|
|
bool
|
isDisplayed(...)
Query the visibility of a widget/label. |
|
|
bool
|
isEnabled(...)
Query if a widget/label has been enabled or disabled. |
|
|
str
|
launch(...)
Launches the dialog and returns when the dialog is closed. |
|
|
|
|
removeCallback(...)
Removes a Python callback function associated with a widget and an
event type. |
|
|
|
|
setValue(...)
Set the value of the specified widget by name. |
|
|
|
|
setValues(...)
Set the values of many widgets in the Dialog by
passing in a python dictionary containing the widget names as keys
and the widget values as values. |
|
|
|
|
|
|
|
showWidget(...)
Display a widget/label so that it is visible. |
|
|
|
Inherited from Boost.Python.instance:
__new__
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__reduce_ex__,
__repr__,
__setattr__,
__sizeof__,
__str__,
__subclasshook__
|
|
Inherited from object:
__class__
|
__init__(...)
(Constructor)
|
|
Raises an exception This class cannot be instantiated from Python
- Overrides:
object.__init__
|
|
helper for pickle
- Overrides:
object.__reduce__
- (inherited documentation)
|
|
Adds a Python function as an event callback to a specific widget of
the Dialog. It is possible to register callbacks for all
types of widgets.
- Parameters:
- Raises:
UiError - If the widget does not exist.
|
|
Show or hide a particular widget/label in the Dialog.
- Parameters:
widgetName (str) - The name of the widget to show or hide.
display (bool) - Whether to show or hide the widget.
- Raises:
UiError - If the widget does not exist.
|
|
Enable or disable a particular widget/label in the Dialog.
- Parameters:
widgetName (str) - The name of the widget to enable or disable.
enable (bool) - Whether to enable or disable the widget.
- Raises:
UiError - If the widget does not exist.
|
getStrippedText(self,
widgetName)
|
|
Gets the value of a dialog text field (or any other widget that holds
a string value) and strips whitespace characters on both ends.
- Parameters:
widgetName - The name of the widget to get the string value from.
- Returns:
str
- The stripped text string.
|
- Parameters:
widgetName (str) - The name of the widget.
- Returns: type
- The value of the specified widget by name. The type of the
returned value depends on the widget type. The value returned is
the current value of the widget when the method is called.
|
- Returns:
dict
- A python dictionary containing current values associated with all
the widgets of the Dialog. Each key in the dictionary will be the
name of a widget and the value of the key is the value of the
widget.
|
|
Hide a widget/label so that it is invisible.
- Parameters:
widgetName (str) - The name of the widget to hide.
- Raises:
UiError - If the widget does not exist.
|
|
Query the visibility of a widget/label.
- Parameters:
widgetName (str) - The name of the widget.
- Returns:
bool
True if the widget is visible.
- Raises:
UiError - If the widget does not exist.
|
|
Query if a widget/label has been enabled or disabled.
- Parameters:
widgetName (str) - The name of the widget.
- Returns:
bool
True if the widget is enabled.
|
|
Launches the dialog and returns when the dialog is closed.
- Returns:
str
- The name of the close button that was clicked.
|
|
Removes a Python callback function associated with a widget and an
event type. If there is no Python callback function attached to the
specified widget/event, nothing happens.
- Parameters:
widgetName (str) - The name of the widget.
eventType (EventType) - The type of event that will trigger the callback.
cb (callable) - A Python callback function previously added with addCallback.
- Raises:
UiError - If the widget does not exist.
|
|
Set the value of the specified widget by name. The type of the given
value depends on the widget type.
The following example sets the list of value for the menu
"Menu_Category" to Music, Special Effect, and Popularity. Also,
it sets the default choice on the menu to be Music (with index 0 being
the first selection of the menu).
Example:
value = (['Music', 'Special Effect', 'Popularity'], 0)
dialog.setValue( 'Menu_Category', value )
- Parameters:
widgetName (str) - The name of the widget.
value - The value to set.
invokeCallback (bool) - Indicates whether registered callbacks on the widget will be
called as a result of the value change. Defaults to
True.
|
|
Set the values of many widgets in the Dialog by
passing in a python dictionary containing the widget names as keys and
the widget values as values.
- Parameters:
values (dict) - The values to set.
invokeCallback (bool) - Indicates whether registered callbacks on the widget will be
called as a result of the value change. Defaults to
True.
|
setWidgetResourceName(...)
|
|
Sets the name of the UI resource that was used to build the specifed
widget in this Dialog. A widget needs this information to find its
tooltip in the tooltip resources installed with Toxik.
- Parameters:
widgetName (str) - The name of the widget.
resName (str) - The name of the resource file used to build the widget. The full
path or just the filename can be specified with or without its
extension.
- Raises:
UiError - If the widget does not exist.
|
|
Display a widget/label so that it is visible.
- Parameters:
widgetName (str) - The name of the widget to show.
- Raises:
UiError - If the widget does not exist.
|