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