ProSEM In Action

Scripts - Using Dialogs for User Interactions


For some script uses, it is necessary to interact with the user, for example, the inform the user, to have the user make a selection, or to choose a file to read or write.  The Wx library is a common toolkit library including with ProSEM's Python installation that makes many forms of user interaction quite easy, using dialog elements that are native to the operating system, so they are immediately familiar to users.  



    • Using Wx Dialogs in scripts, for user interactions
    • Examples include:
      • Text dialogs with one or two selection buttons and different standard icons
      • User Choice from a List of Selections
      • User Input of a Text String
      • User Selection of an already-existing file
      • User Input of a File Path and Name for Creation of a New File


This downloadable archive contains a script which demonstrates many of the available dialogs using the Wx library. For details on how to install and use this script, see How to Use Scripts Downloaded from this Website.

Note that this script simply demonstrates the possible dialogs, but no actions are taken based on user input, and particularly, no files are opened or created by the file selection demonstrations.  The code within this demonstration can be copied and modified for use in your own scripting projects.

Usage Notes:

  • As with any library, the definitions must be included in your script with:
import wx
  • In any script using Wx dialogs, a Wx app object must be instantiated before the ProSEM object.  See the demonstration script for an example. In the prototype scripts, this is done early in the main segment of the program, with the line:
  • Each Wx function has many possible optional arguments; there is copious documentation and example scripts found online, such as at this useful website or this other reference site.
  • The examples in provided use available convenience functions, which simplify the usage for many common cases, but it is also possible to build custom dialogs with individual elements; see the online resources for details and examples.



When the script is run, it displays a Choice dialog showing the user a list of other dialogs to demonstrate.  To exit the demonstration script, click the 'Cancel' button.

The script demonstrates three different 1-Button Message Boxes; here is one example:

and here is a Message Box with 2-Buttons:

And here is a Text Input Box:

And here is a dialog to select or input a filename: