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 (actu‐
28 ally the Class name used for options lookup, i.e. with basename with
29 inital caps) or 'Ptk' as the fallback value. If more than one MainWin‐
30 dow is created or several instances of the script are running at the
31 same time the string " #n" is appended where the number "n" is set to
32 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 Main‐
46 Window to which the widget belongs (the MainWindow belongs to itself).
47
49 Documentation is incomplete. Here are some missing items that should
50 be explained in more detail:
51
52 · The new mechanism for MainWindows is slightly different to other
53 widgets.
54
55 · There no explanation about what resources are bound to a MainWindow
56 (e.g., ClassInit done per MainWindow)
57
58 · Passing of command line options to override or augment arguments of
59 the "new" method (see Tk::CmdLine).
60
62 Tk::Toplevel Tk::CmdLine
63
64
65
66perl v5.8.8 2008-02-05 MainWindow(3)