Hi All,
The following code produces pretty much what I want, but the scrollable pane on the left doesn't scroll. I am using ActivePerl 5.8.9 Build 825:
The code is:
use Tk;
use Tk::Pane;
use Tk::LabFrame;
# create the application window
my $MW = MainWindow->new ( -background => "GREY" );
# set the x/y size for the window
$MW->geometry("800x600");
# add a window title
$MW->title("Monitor Boxes");
# Disallow window resizing
$MW->resizable(0,0);
# create a labelled frame on the window to house the list of buttons to be pressed
$boxListFrame = &create_framed_section( "List Of Boxes",
"acrosstop",
5,
5,
170,
565,
"BLUE",
"GREY");
# create a labelled frame on the window to house the information to be displayed
# when a particular button is pressed
$statusOfBoxFrame = &create_framed_section( "Status",
"acrosstop",
185,
5,
600,
565,
"BLUE",
"GREY");
# create a scrollable pane in the left hand pane so that if more buttons than
# is able to be displayed are put onto the application the scroll bar will allow
# the ones not displayed to be access
my $pane = $MW->Scrolled( 'Pane',
-scrollbars => 'e',
-width => 140,
-height => 555,
-background => "GREY")->place(-x=>15,-y=>25);
# setup the array of buttons
@boxes = ("BUTTON1", "BUTTON2", "BUTTON3", "BUTTON4", "BUTTON5", "BUTTON6", "BUTTON7", "BUTTON8", "BUTTON9", "BUTTON10", "BUTTON11", "BUTTON12", "BUTTON13", "BUTTON14", "BUTTON15", "BUTTON16");
# put the buttons onto the scrollable pane in the frame on the window (LOL)
DisplayCheckButtons( $pane, @boxes);
# wait until the user exits the app
MainLoop;
# exit the app
exit 0;
sub DisplayCheckButtons
{
my ( $parent, @names ) = @_;
$Frame->destroy if $Frame;
$Frame = $parent->Frame( -width => 160,
-height => 555,
-background => "GREY")->place(-x=>15,-y=>15);
$xpos = 5;
$ypos = 5;
foreach $box (@names)
{
$buttons->{$box} = $Frame->Button(-text => $box)->place(-x=>$xpos,-y=>$ypos);
$ypos = $ypos + 40;
}
}
sub create_framed_section
{
# get the parameters
my($label, $labelside, $posX, $posY, $width, $height, $fontColour, $backgroundColour) = @_;
# create the item in the desired position with supplied information
$frame = $MW->LabFrame( -label => $label,
-labelside => $labelside,
-width => $width,
-height => $height,
-foreground => $fontColour,
-background => $backgroundColour,
)->place(-x=>$posX,-y=>$posY);
return $frame;
}
I hope that someone can point out the minor thing that I have missed from this and end my frustration.
Kind regards,
Glen