| Home | Trees | Indices | Help |
|
|---|
|
|
User Interface module.
This module provides convenience functions and a {Dialog} class to create dialogs that have the Toxik look and feel.
This module also provides access to the current workspace of the Toxik application when imported in the embedded Python interpreter.
The functions in this series create a top level window and a root container (if needed), then create a dialog box and bring it up.
When the dialog is dismissed by the user, the function returns a dictionary of values for all significant widgets. The key is the name of the widget and the value represents the state or data stored by the widget.
In addition to the widgets explicitely created by the caller, there is a key "CloseButtonClicked". The value of this key is the name of the push button that was clicked to close the dialog.
Note: If one wishes to create and launch a Dialog with more control over the widgets in the dialog, such as adding callback functions, please refer to the section on the Dialog class.
Widgets for which data is returned are:
True or
False)
| Classes | |
| Cursor | |
|
BrowserScheme This class holds a set of string constants that define the various browser schemes present in Toxik, in other words, the types of entity that can be browsed. |
|
|
CursorGuard Cursor guard to change the current cursor to an alternate cursor, automatically reverting to previous cursor when going out of scope. |
|
|
Dialog This class provides fine control over the widgets within the a dialog returned by the createDialog() function call. |
|
| EventType | |
| UiError | |
|
Workspace The workspace provides access to the context of the interactive application and thus only makes sense when scripts are executed in the embedded interpreter. |
|
| Functions | |||
|
|||
| Dialog |
|
||
str
|
|
||
str
|
|
||
dict
|
|
||
str
|
|
||
dict
|
|
||
| Variables | |
__package__ =
|
|
| Function Details |
Pops-up a message box with an OK button and optionally a
Cancel button. If the Cancel button is clicked,
|
Create and return an instance of a Dialog object. This function uses the same parameters as showDialog(), except that instead of passing an xml file, we pass it an xmlString. Using the Dialog object returned, a user can use methods of the Dialog class to have finer control over the Dialog. Note that this is a special function in this series in that it only returns the instance of Dialog object created but not actually launching the dialog. However, this is also the only function a user can use to obtain the actual Dialog object. |
Generates an xml string to create a simple layout of widgets. The layout is the same as created by the function showSimpleDialog(). Please refer to it for a description. Label widgets created by this utility are named "Label_<label>", where <label> is the text for the label. This is important to consider when some actions, like hide/show and enable/disable are to be performed on labels. In the example below, the textfield widget is named 'PhoneField' and
the auto-generated widget for the label is named 'Label_Phone'. To
respectively hide the textfield and the label, one would call:
Example:
widgets = [ ('TextField', 'PhoneField', 'Phone', '1-800-CallMe') ]
xml = ui.makeXmlFromWidgetList( widgets )
dialog = ui.createDialog( 'MyDialog', xml, 75, 50 )
dialog.launch()
|
Shows a Toxik file system browser. The browser has the given title, and is initially in the directory indicated by initialPath (if not specified, it's located at the root of the file system).
|
This function receives a menu description in xml notation contained in the given file. The description must define at least one close button, named CloseButton_<name>. Close buttons cause the dialog to terminate. The name of the widgets in the dictionary corresponds to the name defined in the xml description (per the <Widget Name = "SomeName"> entry). That does not include the close buttons. For convenience, a virtual close button named "CloseButtonClicked" is put in the dictionary: the value is the widget name of the button that caused the dialog to close. Note that for the dialog, close buttons have no other semantic than being used to close the dialog. The semantic is up to the caller as the values stored in the widgets are not affected.
|
Shows a message box dialog with the specified close buttons and returns the label of the button that was clicked to close the dialog. Example:
closeButton = ui.showMessageBox(
"Warning",
["You are about to erase this file:",
filename,
"This operation cannot be undone."],
["OK", "Cancel"])
if closeButton == "OK":
erase(filename)
|
This function creates a dialog for the widgets requested, with
automatic widget layout. The layout is very simple. For each entry in the
provided +---------+------------------+ | Label1 | Widget1 | +---------+------------------+ | Label2 | Widget | +----+----+---------+--------+ | Ok | | Cancel | +----+--------------+--------+ This function receives a list of 4-tuples:
Type: 3 types of widgets are available: TextField, ToggleButton and Menu. Name: a string used to identify the widget. Must be unique. Label text: of the label that shows on the left of the widget. Initial state depends on the widget type:
Example:
widgets = [ ( 'TextField', 'Show', 'Show', 'Academy Awards' ),
( 'ToggleButton', 'Win', 'Do you win ?', True ),
( 'Menu', 'Category', 'Category', (['Editing', 'Directing', 'Music'], 1) ) ]
result = ui.showSimpleDialog( 'MyDialog', widgets, 400, True )
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Feb 8 08:00:12 2012 | http://epydoc.sourceforge.net |