1MainWindow(3) User Contributed Perl Documentation MainWindow(3)
2
3
4
6 Tk::MainWindow - Root widget of a widget tree
7
9 use Tk;
10
11 my $mw = MainWindow->new( ... options ... );
12
13 my $this = $mw->ThisWidget -> pack ;
14 my $that = $mw->ThatWidget;
15 ...
16
17 MainLoop;
18
20 Perl/Tk applications (which have windows associated with them) create
21 one or more MainWindows which act as the containers and parents of the
22 other widgets.
23
24 Tk::MainWindow is a special kind of Toplevel widget. It is the root of
25 a widget tree. Therefore "$mw->Parent" returns "undef".
26
27 The default title of a MainWindow is the basename of the script
28 (actually the Class name used for options lookup, i.e. with basename
29 with inital caps) or 'Ptk' as the fallback value. If more than one
30 MainWindow is created or several instances of the script are running at
31 the same time the string " #n" is appended where the number "n" is set
32 to get a unique value.
33
34 Unlike the standard Tcl/Tk's wish, perl/Tk allows you to create several
35 MainWindows. When the last MainWindow is destroyed the Tk eventloop
36 exits (the eventloop is entered with the call of "MainLoop"). Various
37 resources (bindings, fonts, images, colors) are maintained or cached
38 for each MainWindow, so each MainWindow consumes more resources than a
39 Toplevel. However multiple MainWindows can make sense when the user can
40 destroy them independently.
41
43 You can apply all methods that a Toplevel widget accepts.
44
45 The method $w->MainWindow applied to any widget will return the
46 MainWindow to which the widget belongs (the MainWindow belongs to
47 itself).
48
50 Documentation is incomplete. Here are some missing items that should
51 be explained in more detail:
52
53 · The new mechanism for MainWindows is slightly different to other
54 widgets.
55
56 · There no explanation about what resources are bound to a MainWindow
57 (e.g., ClassInit done per MainWindow)
58
59 · Passing of command line options to override or augment arguments of
60 the "new" method (see Tk::CmdLine).
61
63 Tk::Toplevel Tk::CmdLine
64
65
66
67perl v5.32.0 2020-07-28 MainWindow(3)