1overview(3)           User Contributed Perl Documentation          overview(3)
2
3
4

NAME

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

SYNOPSIS

9       "use Tk;"
10
11       "$main = MainWindow->new();"
12
13       "$widget = $main->Widget(...);"
14
15       "$widget->pack(...);"
16
17       ...
18
19       "MainLoop;"
20

DESCRIPTION

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

CONTENTS

27       The package is composed of three loosely connected parts:
28
29       pTk - Converted Tk source
30           The pTk sub-directory is a copy of the C code of Tk8.x, modified to
31           allow use by languages other than the original Tcl.  (The pTk can
32           be read as 'perl' Tk or 'portable' Tk, depending on your sensibili‐
33           ties.)
34
35       Tk to Perl 'Glue'
36           The top level directory provides Tk.xs and tkGlue.c which provide
37           the perl-callable interfaces to pTk
38
39       Perl code for 'Widget' Classes
40           The Tk sub-directory contains the various perl modules that com‐
41           prise the "Classes" that are visible to Tk applications.
42
43           The "major" widgets such as Tk::Text are actually in separate
44           directories at the top level (e.g. Text/* for Tk::Text) and are
45           dynamically loaded as needed on platforms which support perl5's
46           DynaLoader.
47

CLASS HIERARCHY

49       package Tk; - the 'base class'
50           All the "command names" documented in Tcl/Tk are made to look like
51           perl sub's and reside in the Tk package. Their names are all lower
52           case.  Typically there are very few commands at this level which
53           are called directly by applications.
54
55       package Tk::Widget; - the 'Widget class'
56           There are no actual objects of the Tk::Widget class; however all
57           the various Tk window "widgets" inherit from it, and it in turn
58           inherits all the core Tk functions from Tk.
59
60           Tk::Widget provides various functions and interfaces which are com‐
61           mon to all Widgets.
62
63           A widget is represented to perl as a blessed reference to a hash.
64           There are some members of the hash which are private to Tk and its
65           tkGlue code.  Keys starting with '.' and of the form
66           /_[A-Z][A-Za-z_]+_/ (i.e. starting and ending in _ and with  first
67           char after _ being upper case) should be considered reserved to Tk.
68
69       Tk::Button, Tk::Entry, Tk::Text ...
70           There is one class for each of the "Tk" widget item types.  Some of
71           them like Tk::Frame do very little indeed, and really only exist so
72           that they can be derived from or so that focus or menu traversal
73           can discover the "kind" of window being processed.
74
75           Other classes, Tk::Text for example, provide a lot of methods used
76           with Tk's "bind" to provide a rich keyboard/mouse interface to the
77           widgets' data.
78
79           These widget classes also include conversions of the Tcl code for
80           event bindings, keyboard focus traversal, menu bars, and menu key‐
81           board traversal. All the Tcl functions have been converted, but the
82           names have changed (systematically) and they have been split up
83           between the various classes in what I hope is an appropriate man‐
84           ner.  Name changes are normally: dropping initial tk_ as the Tk-
85           ness is implicit in the Tk:: prefix, and similarly dropping say
86           Menu from the name if it has been moved the Tk::Menu class.  Thus
87           'proc tkMenuNextEntry' becomes 'sub NextEntry' in the Tk::Menu
88           package.
89
90       Tk::Image
91           This does for Tk8.x's "images" what Tk::Widget does for widgets.
92           Images are new to Tk8.x and the class structure is not mature
93           either.
94
95           There are three sub-classes Tk::Bitmap, Tk::Pixmap and Tk::Photo.
96
97           It is possible to create dynamic or auto-loaded image types inher‐
98           ited from Tk::Image for other image types or photo formats (e.g.
99           support for TIFF format).
100
101       Composite Widgets
102           A composite is some kind of 'frame' with subwidgets which give it
103           useful behaviour.  Tk::Dialog is an example of a composite widget
104           classes built from the basic Tk ones.  It is intended that user
105           code should not need to be aware that a particular class is a com‐
106           posite, and create and configure such widgets in the same manner as
107           any other kind. The configure mechanism and the methods of the
108           class manipulate the subwidgets as required.
109
110           Composite widgets are implemented via Tk::Frame and multiple inher‐
111           itance.  The two 'frame' base classes Tk::Frame and Tk::Toplevel
112           include the additional class Tk::Derived in their inheritance.
113           Tk::Derived provides methods to allow additional configure options
114           to be defined for a widget.
115
116           A Composite widget is typically defined as derived from Tk::Frame
117           or Tk::Toplevel (e.g. Tk::Dialog).
118
119
120
121perl v5.8.8                       2008-02-05                       overview(3)
Impressum