Perl/Tk saves your favourite tools

Main
back: Ties
next: Tk items

(program source) This is one of the simplest Tk programs you can write. First, you have to create a main window (a big thing with border). Each call for MainWindow::new creates a new one. You can create more than one for one application, and they can reside on different screens... only on UNIX, of course.

Not before the MainLoop the window will appear. On the moment your program reaches the MainLoop statement, the whole interface must be built. The program will never return from the MainLoop: the rest must be done (user-)event driven.

To show an object, like a button, you require two things: first you have to create the object to be displayed on a window. Then you give the object a place in the window.

The list of parameters looks like a hash, which is almost true: within the object creation routines it is tranformed into a hash. The labels start with a dash which is (happily) accepted by Perl as part of a string left from the '=>'. The names are usually equivalent to the option-names which can be used with other X11 client programs. Even X-resource files can be used.


 
Ties Tk items

Created by Mark Overmeer with PPresenter on 11 juli 2001.