Purpose of the Tk Tutorial Project

Provide programs and terse notes on using Perl/Tk to make a simple graphical user interface (GUI). The notes can help a Perl programmer to use the programs as templates for building a custom GUI.

Introduce object-oriented programming via Perl/Tk.

Provide examples that demonstrate concepts described in man pages.

Document some tips on software development, open-source tools.

Provide a GUI front-end to a program that retrieves and displays data.

Identify existing documents that contain detailed training and reference information about the concepts used here (this project does not reproduce existing man pages and tutorials found elsewhere, but lists pointers to them).

Project Summary

Project Host Site

The project is hosted by SourceForge:



The project includes these files.

Project overview. Purpose, rationale, components, references, audience.

Tips on development; brief notes on techniques; syntax and usage of tools.

Perl/Tk program with these GUI features:
 one window, one text box;
 show a list of topics in the text box.

Perl/Tk program with these GUI features:
 one window, a menu, multiple frames;
 show a list of topics in a listbox;
 show subtopics in a second listbox.

Perl/Tk program with these GUI features:
 main window with multiple buttons;
 each button shows data or calls a program;
 open a toplevel window.

Other programs
Later programs in the project will add more widgets, functions, features.

Tk and GUIs

Why Tk?

Cross-platform GUI tool.
Relatively easy to learn and use.
Available for many languages (eg, Perl, Python, Ruby, Tcl).
Mature technology with many widgets available.
Learn more Perl techniques.
Good approach to learn about Perl concepts such as references and anonymous arrays: seeing results on screen builds understanding.

No web facilities needed.
Doesn't rely on http, web server, and browser like some popular UI techniques today.

Extend the life of old programs.
Build a GUI for old command-line interface (CLI) programs.

Why a GUI?

GUI compared to command-line interface.

Easier learning curve for new and occasional users.
Less need to write, update, and read user documentation.
The GUI describes how to use the program.
Users need not read and understand the source code or a manual: just start the GUI to see what functions are possible.

Why Not a GUI?

Difficult for a novice to build from scratch.
Suggestion: Follow a template.
Use code from programs like tktut or widget, then customize it as needed.

Hard to debug.
Suggestion: Start with a small example.
Build a small program that works and extend it with more functions to learn them.

Once you get a window and widgets on screen, many changes can be made quickly that can enhance learning.

More code to maintain.
Tradeoff: Maybe less documentation to maintain.
If changes to the program (eg, bug fixes to logic) require UI changes, review and update the related GUI code also.

Keep the GUI updated, and don't spend time writing or updating user documents about the UI.

Without a GUI, both code and documents must be updated so users know what to expect.

Other Information Sources

List of online Tk documentation topics (try perldoc -i Tk).

Good introduction with brief coverage of major topics.

Demonstration scripts provided with Perl/Tk. Provides good presentation, uses many widgets, and gives easy access to source code.

Tcl/Tk simple windowing shell.

Mastering Perl/Tk
Lidie & Walsh; O'Reilly, 2002.

A sizeable book, with good coverage of basic and advanced topics (eg, MainLoop), good graphics (see geometry management), many tips. Avoid the January 2002 printing that has a corrupted index, or get the revision from their web site. The few pages on style and debugging offer a good start for a novice.

Object Oriented Perl
Conway; Manning, 2000.

Using Tk introduces OO concepts, and you do a lot with a little knowledge. Conway has an excellent presentation of the basics and of complex topics when you want to study them. Build knowledge and confidence with a very well-written book.

Basic tutorial on references; then try perlref(1).

Basic OO tutorial for Perl. Shorter and easier than perlobj(1), perltoot(1), perlbot(1).

Assumptions About the User


Many thanks to the open source contributors for building and supporting a magnificent collection of software and documentation.

Many thanks to SourceForge and VA Software for providing a great service to the open source community.

Prepared by C. Poda <clpoda -at- users.sourceforge.net>

Copyright (c) 2002 by C. Poda. Permission is hereby granted to distribute this document intact, and in accordance with the licenses of the Perl distribution; derived documents must include this copyright notice intact.

$Id: tktut_project.pod,v 1.6 2002/05/06 03:50:25 clpoda Exp $