Perl/Tk saves your favorite tools

Main
back: Creating Tk-widgets
next: Derived widget -2

First we create one vumeter bar. A widget is represented by an object (package) with the same name. Most parts of the widget's creation are done by Tk: with a few lines, you have a new widget.

First, you have to tell Tk where this widget can be a child of. The Tk::Widget is the base-class of Tk, which means that my vu widget can be contained in any other object.

The construct call is just the same as:

   Tk::Widget->Construct('vu');
but it looks a bit more as a special language facility in this list-notation; just a bit more status to Tk ;)

Specialised (derived) widgets shall always also inherit methods of Tk::Derived, which will overrule methods of the super-class widget. The Tk::Derived must be the first in the @ISA. I do not know where this design flaw happened, but we have to live with it.

At creation of the widget, the InitObject of the super-class will call your method Populate to add more configuration flags to the widget, or to overrule configuration flag defaults. This is done via the ConfigSpecs, which I will explain later.

The $args is a reference to the hash containing the flags which were given by the user. You may delete from it. Populate shall call its super-class to collect the other configuration flags.
When all flags are known, the InitObject of the super-class will process the flags and defaults.

 
Creating Tk-widgets Derived widget -2

Created by Mark Overmeer with PPresenter on 22 May 2000.