The vizinput module provides several dialog style boxes for eliciting user input and displaying messages. All dialogs create a blocking action that halts events until the user has responded or the box is closed. To set their positions and titles use the standard dialog options described in the vizinput properties section.
Use vizinput.message() to display a message box to the user:
The vizinput.input() dialog returns a string entered by the user:
The vizinput.input() command accepts the following optional keyword arguments, along with the standard dialog options.
Argument |
Description |
password |
If the value of this argument evaluates to True, then the contents of input control will be displayed as asterisks (*). This is useful when entering passwords or other sensitive information. |
The vizinput.ask() dialog displays a question and allows the user to select a Yes/No response. The answer will be 1 for 'Yes' and 0 for 'No':
Use the vizinput.choose() dialog to create a pop-down menu of choices. The user's answer will be the order of their response within the array of options (0 is returned for choice 1, 1 for choice two, etc...):
The vizinput.color() dialog allows the user to select a color using a variety of tools. The return value is a list of normalized RGB values. Optionally, one can specify the initial color that is selected when the dialog opens.
Use vizinput.fileOpen() and vizinput.fileSave() to display standard Windows open and save dialogs. A string holding the path to the selected file is returned when the open or save button is pressed:
The following commands create open/save dialogs:
Command |
Description |
vizinput.fileOpen() |
Displays a Windows open dialog box. The path to the file is returned as a string when the Open button is pressed. |
vizinput.fileSave() |
Displays a Windows save dialog box. The path to the file is returned as a string when the Save button is pressed. |
Both commands accept the following optional keyword arguments, along with the standard dialog options.
Argument |
Description |
filter |
A list of 2 item tuples. The first item of the tuple is a file type description. The second item of the tuple is a file type filter, with wildcards supported. |
file |
Specifies the default file name to open/save. |
directory |
Specifies an initial directory to display in the dialog. |
In the code below a vizinput.fileOpen dialog displays the Vizard resource directory and filters for OSG and VRML files. The file selected is added to a Vizard scene:
In the following code a default file name is specified:
The vizinput.directory() command displays the standard Windows directory selection dialog. A string holding the path to the selected directory is returned when the OK button is pressed:
The vizinput.directory() command accepts the following optional keyword arguments, along with the standard dialog options.
Command |
Description |
prompt |
The message prompt to display above the directory tree. |
directory |
The initial directory to have selected. |
In the code below, a file is opened in the selected directory: