Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  TK::OVERVIEW (3)

.ds Aq ’


Tk::overview - An overview of an Object Oriented Tk8 extension for perl5



use Tk;

$main = MainWindow->new();

$widget = $main->Widget(...);





In writing the perl Tk extension, the goals were to provide a complete interface to the latest production version of John Ousterhout’s Tk, while providing an Object Oriented interface to perl code.


The package is composed of three loosely connected parts:
pTk - Converted Tk source The pTk sub-directory is a copy of the C code of Tk8.x, modified to allow use by languages other than the original Tcl. (The pTk can be read as ’perl’ Tk or ’portable’ Tk, depending on your sensibilities.)
<B>TkB> to Perl ’Glue’ The top level directory provides Tk.xs and tkGlue.c which provide the perl-callable interfaces to pTk
Perl code for ’Widget’ Classes The Tk sub-directory contains the various perl modules that comprise the Classes that are visible to Tk applications.

The major widgets such as <B>Tk::TextB> are actually in separate directories at the top level (e.g. Text/* for <B>Tk::TextB>) and are dynamically loaded as needed on platforms which support perl5’s <B>DynaLoaderB>.


<B>package Tk;B> - the ’base class’ All the command names documented in Tcl/Tk are made to look like perl sub’s and reside in the Tk package. Their names are all lower case. Typically there are very few commands at this level which are called directly by applications.
<B>package Tk::Widget;B> - the ’Widget class’ There are no actual objects of the <B>Tk::WidgetB> class; however all the various Tk window widgets inherit from it, and it in turn inherits all the core Tk functions from Tk.

<B>Tk::WidgetB> provides various functions and interfaces which are common to all Widgets.

A widget is represented to perl as a blessed reference to a hash. There are some members of the hash which are private to Tk and its tkGlue code. Keys starting with <B>’.’B> and of the form <B>/_[A-Z][A-Za-z_]+_/B> (i.e. starting and ending in _ and with first char after _ being upper case) should be considered reserved to <B>TkB>.

<B>Tk::ButtonB>, <B>Tk::EntryB>, <B>Tk::TextB> ... There is one class for each of the Tk widget item types. Some of them like <B>Tk::FrameB> do very little indeed, and really only exist so that they can be derived from or so that focus or menu traversal can discover the kind of window being processed.

Other classes, <B>Tk::TextB> for example, provide a lot of methods used with Tk’s bind to provide a rich keyboard/mouse interface to the widgets’ data.

These widget classes also include conversions of the Tcl code for event bindings, keyboard focus traversal, menu bars, and menu keyboard traversal. All the Tcl functions have been converted, but the names have changed (systematically) and they have been split up between the various classes in what I hope is an appropriate manner. Name changes are normally: dropping initial tk_ as the Tk-ness is implicit in the <B>Tk::B> prefix, and similarly dropping say Menu from the name if it has been moved the Tk::Menu class. Thus ’proc tkMenuNextEntry’ becomes ’sub NextEntry’ in the Tk::Menu package.

<B>Tk::ImageB> This does for Tk8.x’s images what <B>Tk::WidgetB> does for widgets. Images are new to Tk8.x and the class structure is not mature either.

There are three sub-classes <B>Tk::BitmapB>, <B>Tk::PixmapB> and <B>Tk::PhotoB>.

It is possible to create dynamic or auto-loaded image types inherited from <B>Tk::ImageB> for other image types or photo formats (e.g. support for TIFF format).

Composite Widgets A composite is some kind of ’frame’ with subwidgets which give it useful behaviour. <B>Tk::DialogB> is an example of a composite widget classes built from the basic <B>TkB> ones. It is intended that user code should not need to be aware that a particular class is a composite, and create and configure such widgets in the same manner as any other kind. The <B>configureB> mechanism and the methods of the class manipulate the subwidgets as required.

Composite widgets are implemented via <B>Tk::FrameB> and multiple inheritance. The two ’frame’ base classes <B>Tk::FrameB> and <B>Tk::ToplevelB> include the additional class <B>Tk::DerivedB> in their inheritance. <B>Tk::DerivedB> provides methods to allow additional <B>configureB> options to be defined for a widget.

A Composite widget is typically defined as derived from <B>Tk::FrameB> or <B>Tk::ToplevelB> (e.g. <B>Tk::DialogB>).

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 OVERVIEW (3) 2013-11-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.