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.2. Frame Style

As with all widgets, you can use the -relief and -borderwidth options to change how the edges of a frame widget are drawn. The default -relief is 'flat', and the default -borderwidth is 0. If you want the frame to have any edges at all, make sure you change -borderwidth to something higher than 0. Unless you put something in a frame, you'll never see it. So, for the examples in Figure 12.1, I have inserted a label widget and an entry widget that state the relief of that frame. Note that I actually created a label widget by using Label() and did not use the -label option (see the next section).

Figure 12.1. Different relief values for frames; borderwidth of 2 and borderwidth of 5

Using -relief and -borderwidth is a great way to find out where your frame is in the window. If you have a complicated window, it's confusing to remember which frame is where. I'll often add -borderwidth => 5, -relief => "groove" to my Frame command to find that frame in the window.

12.2.1. Adding a Label to a Frame

With Perl/Tk, you can add a label to your frame by using the -label option, which takes a text string as an argument:

$mw->Frame(-label => "My Frame:")->pack;
...
# configure label in frame later :
$frame->configure(-label => "My Frame:")->pack;

By default, the label is placed at the top of the frame, centered across the width (see Figure 12.2). Again, I put something in ...

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