Pmw demonstrations and tests

Pmw comes with an extensive range of demonstrations and tests. The demonstrations can be used to get a feel for what is provided by Pmw and the demonstration code can be viewed to see examples of how to use Pmw. The tests can be executed to check that there are no problems with running Pmw in your environment.


The Pmw demos directory contains demonstration scripts showing many of the features of Pmw megawidgets. To view a comprehensive package of all the demonstrations, including a view of the source code, run the script. Run -help for a short description of the script's options.

All of the demonstrations may also be run separately. Most of the demonstrations show some of the features of one of the Pmw megawidgets. For example, to see a demonstration of the ButtonBox megawidget, change into the demos directory and run


Other demonstrations, which show other features of Pmw include         demonstrates the Pmw interface to
                    the BLT graph and vector commands        demonstrates the Pmw interface to
                    the BLT tabset command           how to set color schemes      how to configure the python class
                    of a megawidger component    how Pmw displays run time errors
                    in a window      template for new demonstrations             the Tkinter Grid geometry manager      how to use standard values for fonts      how to extend the Pmw MegaToplevel
                    class    how nested modal dialogs behave        how to use the option database to
                    modify Tk widget option defaults    how to use the option database to
                    modify megawidget option defaults         demonstrates the Pmw interface to
                    the BLT busy command     deriving from Pmw.EntryField         some of the Pmw color handling
                    functions        tests the speed of creating Pmw
                    megawidgets      how to extend the Pmw MegaWidget
                    class    megawidget destruction
Creating demonstrations of new megawidgets

If you create a new megawidget you can create a demonstration for it by using the file as a template. This template allows the demonstration to be run individually or to be automatically included as part of the demonstration package You should take a copy of the template and name the new file after your megawidget. You should then replace each instance of the word EXAMPLE with the name of your megawidget and replace the code in the __init__ method with code to create and initialise one or more instances of your megawidget, which should be a child of parent. You can add other methods as necessary.


The Pmw tests directory contains a test framework and a set of test scripts for Pmw. The tests cover the standard Tkinter module and most of the Pmw megawidgets. The tests make a great demonstration of the flexibility of the megawidgets. Simply change into the tests directory and run python

If all tests pass there should be no output printed to standard output. If any of the tests fail, please send the test output to the maintainer at

All of the tests may be run separately. Most of the tests test the features of one of the Pmw megawidgets. For example, to execute the test for the ButtonBox megawidget, run


The file contains general testing functions and is imported by all test files. Other files, which test other features of Pmw include           BLT vector and graph interface        setting color schemes    creation of megawidget classes       option and component handling       more option and component handling       Tk widgets in the Tkinter module
Creating tests for new megawidgets

If you create a new megawidget you should create a test for it. There is no template file for creating tests, but by looking at the other Pmw tests (for example, you will get some idea of how to create a test for your megawidget.

The test files are designed to be run both individually or automatically by the test package Each test file must define the testData tuple. This consists of a sequence of 2-element tuples, each tuple being a test specification for one megawidget. Usually a file tests only one megawidget and so there is only one test specification. The first element in the specification is the megawidget class and the second is a sequence of (yet more) 2-element tuples. In each of these tuples, the first element is a sequence of individual tests to perform on an instance of the megawidget and the second element is a dictionary to use for the keyword arguments when creating the instance. Each individual test is a tuple, the meaning of which depends on the type of the first element, which may be either a string, a function or a method of the megawidget class, as explained below.

Some special functions and values supplied by the Test module that may be used in the tests include:

Test.callback       callback taking no arguments
Test.callback1      callback taking one argument
Test.callbackN      callback taking any number of arguments

Test.currentWidget  returns the widget instance being tested
Test.num_options    returns number of options for the widget

Test.earthris       a sample Tkinter.PhotoImage
Test.flagup         a sample Tkinter.BitmapImage
Test.floatvar       a Tkinter.DoubleVar
Test.stringvar      a Tkinter.StringVar

To slow down a test (to see what is being displayed), add the following line which sets the delay between tests to (say) 1000 milliseconds:


To print information about what is being tested, add the line:


Pmw 1.3 - 6 Aug 2007 - Home