The canvas has a preordained size, and should not be drawn any larger than 1000x400. Should it be truncated to fit the window that it should appear with scrollbars. I've come close by responding to the event and changing the size of the inner pane, but attempt to control the scrollbars seem to cause the subroutine to exit, and the image gets mangled.
Can this layout be done without configuring elements on every change? > mwfOuter->configure( -scrollbars => $scrollbars); Here is the code:#!/usr/bin/perl use Data::Dumper; # this implements 5 text fields that detect the modified properly use strict; use Tk; use Tk::Pane; use Tk::Photo; use Tk::PNG; my $mw = MainWindow->new; $mw->configure(-menu => my $menubar = $mw->Menu); my $app = $menubar->cascade( -label => '~*' ) ; # TODO -bitm +ap =>); my $file = $menubar->cascade( -label => '~File'); my $edit = $menubar->cascade(-label => '~Edit'); my $go = $menubar->cascade(-label => '~Go'); my $group7; my @checkboxes ; my $messageBar = $mw->Entry( )->pack( -side=>"bottom" ) ; $mw->geometry('600x650'); our $lastWidth; our $lastHeight; my $frame = $mw->Canvas( )->form( -top => '20' , -bottom => [ '%100' +, -40 ] , -right => '%95' , -left => '%5' ); # dynamic ! my $mwfOuter = $frame->Scrolled('Pane', -scrollbars=>'osoe', -sticky=>'nwse', -background=>'white', -width => 1000+23, -height => 400+23 # actula dim )->pack(); my $colourBars = $mw->Photo ( -file => 'colourBars.png' ); my $stackImage = $mw->Photo ( -file => 'stack.png' ) ; my $mwf = $mwfOuter->Pane( -sticky=>'nwse', -width => 1000 , -height => 400 )->p +ack() ; # actual dim # this totally works, but you have to set the height of $mwf to fit t +he window , which the user can change.... my $label = $mwf->Label( -image => $colourBars )->place( -x => 0 , -y + => 0 ); $mw->bind( '<Configure>' => [ \&gotResized ] ) ; # we need to change +some things... I'd rather live this to Tk sub gotResized{ my $current_size = $mw->width . "x" . $mw->height; if ($lastWidth == $mw->width and $lastHeight == $mw->height ) +{ return (0==0); }; # the card area is 10% of the width, and height -60; # set the mwfOuter to that size warn $current_size; my $scrollbars; my $w = 1100; if ($mw->width < 1100 ) { # 1.1 * 1000 $w = int ($mw->width * 0.9 ) ; $scrollbars .= 'oe'; } my $h = 400 ; if ($mw->height < 460 ) { $w = int ($mw->height - 60) ; $scrollbars .= 'os'; }; warn "scrollbars $scrollbars "; #$mwfOuter->configure( -scrollbars => $scrollbars ); #TODO why + does this not work? if ($w > 50 and $h > 50 ) { warn "Wanting to resize to $w x $h"; $mwf->configure( -width => $w , -height => $h ) ; $lastWidth = $mw->width ; $lastHeight =$mw->height; #warn "Resized" . Dumper (@_) ; }; return (0==0); }; MainLoop();
In reply to TK Geometry question. by kb3ien
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |