.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "MainWindow 3" .TH MainWindow 3 2025-07-14 "perl v5.42.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::MainWindow \- Root widget of a widget tree .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Tk; \& \& my $mw = MainWindow\->new( ... options ... ); \& \& my $this = $mw\->ThisWidget \-> pack ; \& my $that = $mw\->ThatWidget; \& ... \& \& MainLoop; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Perl/Tk applications (which have windows associated with them) create one or more \fBMainWindow\fRs which act as the containers and parents of the other widgets. .PP \&\fBTk::MainWindow\fR is a special kind of Toplevel widget. It is the root of a widget tree. Therefore \f(CW\*(C`$mw\->Parent\*(C'\fR returns \&\f(CW\*(C`undef\*(C'\fR. .PP The default title of a MainWindow is the basename of the script (actually the Class name used for options lookup, i.e. with basename with inital caps) or \*(AqPtk\*(Aq as the fallback value. If more than one MainWindow is created or several instances of the script are running at the same time the string \f(CW" #n"\fR is appended where the number \f(CW\*(C`n\*(C'\fR is set to get a unique value. .PP Unlike the standard Tcl/Tk\*(Aqs wish, perl/Tk allows you to create several MainWindows. When the \fIlast\fR \fBMainWindow\fR is destroyed the Tk eventloop exits (the eventloop is entered with the call of \&\f(CW\*(C`MainLoop\*(C'\fR). Various resources (bindings, fonts, images, colors) are maintained or cached for each MainWindow, so each MainWindow consumes more resources than a Toplevel. However multiple MainWindows can make sense when the user can destroy them independently. .SH METHODS .IX Header "METHODS" You can apply all methods that a Toplevel widget accepts. .PP The method \fR\f(CI$w\fR\fI\fR\->\fBMainWindow\fR applied to any widget will return the \&\fBMainWindow\fR to which the widget belongs (the MainWindow belongs to itself). .SH MISSING .IX Header "MISSING" Documentation is incomplete. Here are \fIsome\fR missing items that should be explained in more detail: .IP \(bu 4 The new mechanism for MainWindows is slightly different to other widgets. .IP \(bu 4 There no explanation about what resources are bound to a MainWindow (e.g., ClassInit done per MainWindow) .IP \(bu 4 Passing of command line options to override or augment arguments of the \f(CW\*(C`new\*(C'\fR method (see Tk::CmdLine). .SH "SEE ALSO" .IX Header "SEE ALSO" Tk::Toplevel Tk::CmdLine