Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

12.1. Creating a Frame

Use the parent widget of the frame to invoke the Frame() method:

$frame = $parent->Frame( [ option => value, ... ])->pack();

The $parent can be a MainWindow, a toplevel, or another frame widget.[2] After the frame is created, it can become a parent to other widgets. You must have created the frame but not necessarily packed it on the screen for it to be the parent of other widgets. Keep in mind that, even if you pack other widgets inside your frame, if you don't pack the frame as well, the other widgets won't show on the screen.

[2] Technically, any widget can be a parent of another widget, but I like to make my life easier when it comes to placing the widget inside the window. If I made a frame the child of a $button, I wouldn't be able to pack it inside the button. I would then have to use the -in option with pack, confusing myself even further. Keep it simple, and you'll be much happier.

Just as with all the other widgets in Perl/Tk, the options specified in the Frame method will change how the frame looks inside the window. There are few options available with the frame widget, and they aren't complicated at all. This section covers all the options and what they do.

-background => color

Sets the color of the frame's background area (there is no foreground area).

-borderwidth => amount

Sets the width of the frame's edges. Default is 0.

-class =>classname

Indicates the class associated with the frame in the option database. This option can actually be ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata