pdk.UserMessages ($Date: 2002/12/04 10:13:05 $)
index
pdk/UserMessages.py

Generic user messages for console and GUI.

The main idea behind these classes is to provide a single interface to several kinds of user messages - so far, text and progress bar messages are implemented.

Usage: simple message:

   popupmessage('This is important information!')
    
progress bar: ::

   msg = popupprogressmessage('time-consuming operation!', 30) # prepare
   for i in range(30):
       <lengthy computation>
       msg()                                                   # update

statusmessage() and statusprogressmessage() work in a similar way, but
direct their output to the currently active status widget (i.e., the
status bar of the top frame of the application or a widget registered
with a call to .setstatuswidget).

If -1 is passed as the second argument to a progress message, the
progress bar will wrap and start at the beginning.

FOG 01.2000

 
Classes
            
_StatusWidgetRegistry
_UserMessage
ConsolePopupUserMessage
ConsoleStatusUserMessage
_GUIUserMessage
GUIPopupUserMessage
GUIStatusUserMessage
 
class ConsolePopupUserMessage(_UserMessage)
     
Purpose:shows a (modal) console popup message on a console (or any other stream linked to sys.stdout)

 
   Methods defined here:
ShowMessage(self, messageString, **dummy)
 
class ConsoleStatusUserMessage(_UserMessage)
     
Purpose:shows status messages on a console (or any other stream linked to sys.stdout)

 
   Methods defined here:
CloseProgressBar(self)
PrepareProgressBar(self, messageString, **dummy)
ShowMessage(self, messageString, **dummy)
ShowProgress(self, newPosition, currentPosition)

Data and non-method functions defined here:
GAUGE_RANGE = 60
 
class GUIPopupUserMessage(_GUIUserMessage)
     
Purpose:provides generic and progress bar popup messages under wxPython

 
  
Method resolution order:
GUIPopupUserMessage
_GUIUserMessage
_UserMessage

Methods defined here:
PrepareProgressBar(self, messageString, **optionD)
ShowMessage(self, messageString, **optionD)
 
class GUIStatusUserMessage(_GUIUserMessage)
     
Purpose:provides generic and progress bar status messages under wxPython Todo: get the size in the progress dialog right.

 
  
Method resolution order:
GUIStatusUserMessage
_GUIUserMessage
_UserMessage

Methods defined here:
PrepareProgressBar(self, messageString, **optionD)
sets up a progress bar in the widget that is currently set as the status widget. Note that if the current status widget defines a .``GetFiledRect`` method (like wxPython.wx.wxStatusBar), the first status bar field is used to place the progress bar in. For all other widgets, the full size (as determined by the .``GetRect`` method) is used.
ShowMessage(self, messageString, push=0, pop=0, duration=None, **optionD)

show a GUI status message. The following additional options will be recognized (only one of them at a time can be used, though):

  • push: boolean; if true, push messageString on the status message stack
  • pop: boolean; if true, pop the last message from the status message stack (the messageString argument will be ignored in this case)
  • duration: float or callable; display messageString for either for the specified duration in seconds or until the callable returns, then pop the previous message.
 
class _UserMessage
     
Purpose:abstract base class for displaying user message display
Detail:

presents an integrated interface to both simple messages and progress bar messages in the .__call__ method, which can be called with a single string as argument (simple message) or a string and an integer as arguments (progress bar of the range given by the integer value and displaying the string as message). Derived classes shoud provide the following methods:

  • ShowMessage(messageString, **optionD): shows a message displaying the string given in messageString. optionD contains additional keyword arguments passed to __call__;
  • PrepareProgressBar(messageString, **optionD): creates a progress bar displaying messageString. optionD contains additional keyword arguments passed to __call__;
  • ShowProgress(newPosition, currentPosition): update the position of the progress bar. newPosition gives the requested new, currentPosition the current position of the indicator;
  • CloseProgressBar(): performs clean-up after the process finished.

 
   Methods defined here:
__call__(self, cycleInfo=None)
__init__(self, messageString='', steps=None, **optionD)
Parameters:
  • messageString: the string to be displayed
  • steps: number of updates for a progress message
  • optionD: options for the targeted message class
getResponse(self)
setResponse(self, response)

Data and non-method functions defined here:
DEFAULT_STEPS = 30
 
class _GUIUserMessage(_UserMessage)
     
Purpose:abstract base class for GUI message classes

 
   Methods defined here:
CloseProgressBar(self)
ShowProgress(self, newPosition, dummy)

Data and non-method functions defined here:
GAUGE_RANGE = 100
 
class _StatusWidgetRegistry
     
Purpose:allows redirection of status messages to any widget
Detail:call .setStatusWidget with a widget instance as argument to redirect all future status messages to it. The default status widget is the status bar of the top frame of the application; it can be re-enabled by calling .setStatusWidget with None as argument.

 
   Methods defined here:
__init__(self)
getStatusWidget(self)
returns the currently registered status message widget, or None.
setStatusWidget(self, widget)
register %widget% as the active status message widget.
 
Functions
            
getstatuswidget = getStatusWidget(self) method of _StatusWidgetRegistry instance
popupmessage(messageString, **optionD)
displays a GUI popup message or a console message, if no GUI is available.
popupprogressmessage(messageString, steps, **optionD)
displays a GUI popup progress message or a console message, if no GUI is available
setstatuswidget = setStatusWidget(self, widget) method of _StatusWidgetRegistry instance
statusmessage(messageString='', **optionD)
displays a status message in the GUI statusbar or on the console, if no GUI is available. If no messageString is passed, the current message is cleared.
statusprogressmessage(messageString, steps, **optionD)
displays a status progress message in the GUI statusbar or on the console, if no GUI is available
userinput(prompt, **optionD)
prompts for simple text user input in a text control or in the console, if no GUI is available.
 
Author
            
$Author: gathmann $