I'm getting a weird bug that resizes my main window to its minimal dimensions. I first create my main window, then I make a function that creates a pane widget (a frame widget but scrollable) and pack it into the main window. The weird part is if I call the pane creation function right after creating the main window, the main window dimensions are preserved. But if I link the pane creation function to a menu bar option call, the main window resizes to its minimal dimensions (defined by $main->minsize). Anyone know how to preserve the main window dimensions through a menu bar function call?
Here is the code I am using:
use strict;
use Tk;
use Tk::Pane;
my $main = MainWindow->new;
$main->minsize(qw(175 125));
$main->configure(-menu => my $menubar = $main->Menu);
my $file_menu = $menubar->cascade(-label => '~File');
$file_menu->command(
-label => 'Load Picture',
-underline => 0,
-command => sub {create_pane();}
);
#create_pane();
MainLoop;
sub create_pane {
my $main_pane = $main->Scrolled(
'Pane',
-width => 1024,
-height => 768,
-background => 'black'
);
$main_pane->pack(-expand => 1, -fill => 'both');
}
-James jchen578@hotmail.com
Here is the code I am using:
Code:
#!/usr/bin/perl use strict;
use Tk;
use Tk::Pane;
my $main = MainWindow->new;
$main->minsize(qw(175 125));
$main->configure(-menu => my $menubar = $main->Menu);
my $file_menu = $menubar->cascade(-label => '~File');
$file_menu->command(
-label => 'Load Picture',
-underline => 0,
-command => sub {create_pane();}
);
#create_pane();
MainLoop;
sub create_pane {
my $main_pane = $main->Scrolled(
'Pane',
-width => 1024,
-height => 768,
-background => 'black'
);
$main_pane->pack(-expand => 1, -fill => 'both');
}
-James jchen578@hotmail.com