Toplevel Methods

The Toplevel widget methods are listed and explained in the following sections. It is important to note that all of these methods apply to a MainWindow as well; a MainWindow is just a specialized Toplevel widget. Also keep in mind that a lot of these methods were designed originally for use with a Unix windowing environment, and quite a few of them will state “No effect in Win32 system.” Many of these functions serve no useful purpose to the typical ordinary Perl/Tk application, but we document them here for thoroughness.

Several of the methods here alter window manager properties, which often look like WM_PROPERTY_THING. These properties are also traditionally associated with the X Window system on Unix, but some still apply in Win32 systems. If a specific method doesn’t say anything about which system it applies to, it will apply to both. If it applies only to one or the other (or only half-works in one system), this will be mentioned as well.

Sizing a Toplevel

You can use the geometry method to define or retrieve a geometry string. A geometry string determines the size and placement of a window on the screen. The geometry string is a concept that originated on Unix systems and is a bit cryptic at first glance. Here is a regular expression that describes a complete geometry string:

^=?(\d+x\d+)?([+-]\d+[+-]\d+)?$

The equals sign can be omitted completely (and usually is). The first portion (\d+x\d+) is the width and height (in that order), separated by an x. Both ...

Get Mastering Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.