The Toplevel Widget

Create a toplevel widget, displayed independently from the main window with the same decoration as the window system, using the Toplevel method.

The standard configuration options that apply to Toplevel are: -background, -bg, -borderwidth, -bw, -cursor, -height, -highlightbackground, -highlightcolor, -highlightthickness, -relief, -takefocus, and -width.

Other options are:

-class => name

The class associated with the toplevel widget.

-colormap => \$window

Specifies another window to share the colormap with. You can point to another window or use the value "new" to specify a new colormap. Default is undef.

-screen => screen

The screen to place the toplevel widget on.

-visual => type n

For the X Window System, changes the depth of colors.

Toplevel Methods

In addition to cget and configure, the following methods are supported by the Toplevel widget. Note that since the MainWindow is a Toplevel widget, each of these methods applies to the MainWindow as well.


Returns the constraints to the aspect of the window. The four-item list returned corresponds to the minimum width, the minimum height, the maximum width, and the maximum height.


Assigns a name to the toplevel window.


For the X Window System, passes a list of windows to the window manager that have private colormaps. Controls the WM_COLORMAP_WINDOWS property.


For the X Window System, returns the command used to start the application.


Displays an iconified ...

Get Perl in a Nutshell 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.