1overview(3) User Contributed Perl Documentation overview(3)
2
3
4
6 Tk::overview - An overview of an Object Oriented Tk8 extension for
7 perl5
8
10 "use Tk;"
11
12 "$main = MainWindow->new();"
13
14 "$widget = $main->Widget(...);"
15
16 "$widget->pack(...);"
17
18 ...
19
20 "MainLoop;"
21
23 In writing the perl Tk extension, the goals were to provide a complete
24 interface to the latest production version of John Ousterhout's Tk,
25 while providing an Object Oriented interface to perl code.
26
28 The package is composed of three loosely connected parts:
29
30 pTk - Converted Tk source
31 The pTk sub-directory is a copy of the C code of Tk8.x, modified to
32 allow use by languages other than the original Tcl. (The pTk can
33 be read as 'perl' Tk or 'portable' Tk, depending on your
34 sensibilities.)
35
36 Tk to Perl 'Glue'
37 The top level directory provides Tk.xs and tkGlue.c which provide
38 the perl-callable interfaces to pTk
39
40 Perl code for 'Widget' Classes
41 The Tk sub-directory contains the various perl modules that
42 comprise the "Classes" that are visible to Tk applications.
43
44 The "major" widgets such as Tk::Text are actually in separate
45 directories at the top level (e.g. Text/* for Tk::Text) and are
46 dynamically loaded as needed on platforms which support perl5's
47 DynaLoader.
48
50 package Tk; - the 'base class'
51 All the "command names" documented in Tcl/Tk are made to look like
52 perl sub's and reside in the Tk package. Their names are all lower
53 case. Typically there are very few commands at this level which
54 are called directly by applications.
55
56 package Tk::Widget; - the 'Widget class'
57 There are no actual objects of the Tk::Widget class; however all
58 the various Tk window "widgets" inherit from it, and it in turn
59 inherits all the core Tk functions from Tk.
60
61 Tk::Widget provides various functions and interfaces which are
62 common to all Widgets.
63
64 A widget is represented to perl as a blessed reference to a hash.
65 There are some members of the hash which are private to Tk and its
66 tkGlue code. Keys starting with '.' and of the form
67 /_[A-Z][A-Za-z_]+_/ (i.e. starting and ending in _ and with first
68 char after _ being upper case) should be considered reserved to Tk.
69
70 Tk::Button, Tk::Entry, Tk::Text ...
71 There is one class for each of the "Tk" widget item types. Some of
72 them like Tk::Frame do very little indeed, and really only exist so
73 that they can be derived from or so that focus or menu traversal
74 can discover the "kind" of window being processed.
75
76 Other classes, Tk::Text for example, provide a lot of methods used
77 with Tk's "bind" to provide a rich keyboard/mouse interface to the
78 widgets' data.
79
80 These widget classes also include conversions of the Tcl code for
81 event bindings, keyboard focus traversal, menu bars, and menu
82 keyboard traversal. All the Tcl functions have been converted, but
83 the names have changed (systematically) and they have been split up
84 between the various classes in what I hope is an appropriate
85 manner. Name changes are normally: dropping initial tk_ as the Tk-
86 ness is implicit in the Tk:: prefix, and similarly dropping say
87 Menu from the name if it has been moved the Tk::Menu class. Thus
88 'proc tkMenuNextEntry' becomes 'sub NextEntry' in the Tk::Menu
89 package.
90
91 Tk::Image
92 This does for Tk8.x's "images" what Tk::Widget does for widgets.
93 Images are new to Tk8.x and the class structure is not mature
94 either.
95
96 There are three sub-classes Tk::Bitmap, Tk::Pixmap and Tk::Photo.
97
98 It is possible to create dynamic or auto-loaded image types
99 inherited from Tk::Image for other image types or photo formats
100 (e.g. support for TIFF format).
101
102 Composite Widgets
103 A composite is some kind of 'frame' with subwidgets which give it
104 useful behaviour. Tk::Dialog is an example of a composite widget
105 classes built from the basic Tk ones. It is intended that user
106 code should not need to be aware that a particular class is a
107 composite, and create and configure such widgets in the same manner
108 as any other kind. The configure mechanism and the methods of the
109 class manipulate the subwidgets as required.
110
111 Composite widgets are implemented via Tk::Frame and multiple
112 inheritance. The two 'frame' base classes Tk::Frame and
113 Tk::Toplevel include the additional class Tk::Derived in their
114 inheritance. Tk::Derived provides methods to allow additional
115 configure options to be defined for a widget.
116
117 A Composite widget is typically defined as derived from Tk::Frame
118 or Tk::Toplevel (e.g. Tk::Dialog).
119
120
121
122perl v5.30.0 2019-07-26 overview(3)