O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tk::CollapsableFrame

Use a CollapsableFrame to hide information until the widget is opened. This widget is used by the MacCopy widget, described next. Both Tk::CollapsableFrame and Tk::MacCopy are more examples of composite mega-widgets, described in Chapter 14.

See Figure C-1 for a demonstration of a CollapsableFrame widget.

A CollapsableFrame, shown both hidden and displayed

Figure C-1. A CollapsableFrame, shown both hidden and displayed

$Tk::CollapsableFrame::VERSION = '1.0'; package Tk::CollapsableFrame; use Carp; use Tk::widgets qw/Frame/; use vars qw/$cf_height_bias $im_Close $im_Open/; use strict; use base qw/Tk::Frame/; Construct Tk::Widget 'CollapsableFrame'; sub ClassInit { # Define global variables and images for the class. my($class, $mw) = @_; $cf_height_bias = 22; $im_Close = $mw->Photo(-data => 'R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADMxi63BMg yinFAy0HC3XjmLeA4ngpRKoSZoeuDLmo38mwtVvKu93rIo5gSCwWB8ikcolMAAA7'); $im_Open = $mw->Photo(-data => 'R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADNhi63BMg yinFAy0HC3Xj2EJoIEOM32WeaSeeqFK+say+2azUi+5ttx/QJeQIjshkcsBsOp/MBAA7'); $class->SUPER::ClassInit($mw); } # end ClassInit sub Populate { # Create an instance of a CollapsableFrame. Instance variables are: # # {frame} = the ridged frame, which contains the open/close # Label image, the id Label for the collapsable Frame, # and the container Frame within which the user manages # collapsable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required