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 ...

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.