PyUI Dialogs

  1. Console Dialog
  2. Using Modal Dialogs
  3. Standard Dialog
  4. File Dialog
  5. Color Picker Dialog

Dialogs are PyUI objects derived from pyui.widgets.Frame that provide higher level functionality than just widgets. There are some built-in dialogs including the Console Dialog.

Console Dialog

The Console Dialog is a PyUI object that allows the user to interact in real time with the python process that is running PyUI . It is a python console that allows arbitrary python commands to be entered and executed. The results of these commands are displayed in the scrolling line output of the console window.

The console can be useful for debugging PyUI applications as it can inspect the attributes of python objects while the program is running. It can also be useful for experimenting with PyUI code in real-time, and for reloading python modules that have changed on disk. The console is invoked by creating an object of the class pyui.dialogs.Console.

Using Modal Dialogs

Modal dialogs are dialogs that take over all event handling while they are in their "modal" state. They must be dealt with by the user - and so are a useful way of ensuring that a response is received before the application will continue. To invoke a dialog as modal, call the doModal() method on it. This will end up with a DIALOGCLOSED event being generated which can be used to determine when the modal dialog is closed.

Standard Dialog

The standard dialog is a useful dialog for prompting the user for responses. It takes a title, a text message that it displays along with an OK button and a Cancel button. This dialog then behaves like a standard modal dialog.

Below is an example of using a modal dialog:

import pyui

def onClosed(event):
    print "Dialgo Closed. Value is:", dialog.modal
pyui.desktop.getDesktop().registerHandler(pyui.locals.DIALOGCLOSED, onClosed)
dialog = pyui.dialogs.StdDialog("a StdDialog", "are you ready to rumble?")

File Dialog

The file dialog is a useful dialog that prompts the user to select a file. It is constructed with a starting directory, a callback method to be invoked when a file is selected, and filter for the list of files that is displayed. The filter matches using python regular expressions. Note that the wildcard for matching anything is ".*" not just "*" as the asterisk is a "repeating character"
modifier in the regular expression language...

Color Picker Dialog

This is another useful dialog for prompting the user to select a color visually from the colors displayed. It is constructed with a callback method, and three integer values from 0 - 255 for the starting Red, Green and Blue values.


(C) Sean Riley 2002