in reply to Re^6: perltk autoresize following users resize
in thread perltk autoresize following users resize
$goMainWindow = new MainWindow; $goMainWindow->geometry('200x300'); #Exit is lopped off
You have a couple of options as I see it.
1. Set a minimum size on Resizing your window. This can be done by setting no geometry at first, letting pack fill to the minimum size, grab that size and set that as a minimum.
that will prevent them making the window smaller than what is required to show everything.# at ther end of your build_gui sub $goMainWindow->idletasks; my $w = $goMainWindow->reqwidth; my $h = $goMainWindow->reqheight; print "$w $h\n"; $goMainWindow->minsize($w,$h);
2. You could put your repacked stuff into a scrolled Pane. Leave the Exit button on the mainwindow.
#!/usr/bin/perl use strict; use Tk; require Tk::Pane; our ($goMainWindow); our (%ghGuiObjs); our (%ghGuiCBVars); $| = 1; &main(); sub main { buildGui(); MainLoop; } #end sub main sub updateA { if ( $ghGuiCBVars{"nEnableFrameA"} == 1 ) { $ghGuiObjs{"oContainerA"}->pack( -expand => '1', -fill => 'both', -pady => '5', ); } else { $ghGuiObjs{"oContainerA"}->packForget(); } } sub updateB { if ( $ghGuiCBVars{"nEnableFrameB"} == 1 ) { $ghGuiObjs{"oContainerB"}->pack( -expand => '1', -fill => 'both', -pady => '5', ); } else { $ghGuiObjs{"oContainerB"}->packForget(); } } sub buildGui { $goMainWindow = new MainWindow; my $mf = $goMainWindow->Scrolled('Pane', -scrollbars => 'osoe', )->pack( -expand => '1', -fill => 'both', -pady => '5', ); my ($oLabel) = $mf->Label( -text => "This is my example", )->pack( -padx => '5', -pady => '5', -expand => '1', -fill => 'x', ); my ($oCbA) = $mf->Checkbutton( -text => 'Enable A', -variable => \$ghGuiCBVars{"nEnableFrameA"}, -command => \&updateA, -anchor => 'w', ); $ghGuiCBVars{"nEnableFrameA"} = 1; my ($oFrameA) = $mf->Labelframe( -labelwidget => $oCbA, )->pack( -padx => '5', -expand => '1', -fill => 'both', ); my ($oContainerFrameA) = $oFrameA->Frame( )->pack( -expand => '1', -fill => 'both', -pady => '5', ); $ghGuiObjs{"oContainerA"} = $oContainerFrameA; my ($oLbA) = $oContainerFrameA->Listbox( -relief => 'groove', -borderwidth => '5', -height => '5', )->pack( -fill => 'both', -expand => '1', ); my ($oCbB) = $mf->Checkbutton( -text => 'Enable B', -variable => \$ghGuiCBVars{"nEnableFrameB"}, -command => \&updateB, -anchor => 'w', ); $ghGuiCBVars{"nEnableFrameB"} = 1; my ($oFrameB) = $mf->Labelframe( -labelwidget => $oCbB, )->pack( -padx => '5', -expand => '1', -fill => 'both', ); my ($oContainerFrameB) = $oFrameB->Frame( )->pack( -expand => '1', -fill => 'both', -pady => '5', ); $ghGuiObjs{"oContainerB"} = $oContainerFrameB; my ($oLbB) = $oContainerFrameB->Listbox( -relief => 'groove', -borderwidth => '5', -height => '5', )->pack( -fill => 'both', -expand => '1', ); my ($oExit) = $goMainWindow->Button(-text => 'Exit', -command => sub{exit}, )->pack( -padx => '5', -pady => '5', -side => 'bottom', ); }
So, I don't know what you expect of the resizer. If you make the mainwindow smaller than what is needed to display everything, something will get lopped off..... widgets don't act like scalable fonts. If you truly wanted scalable widgets, you could make your program on a Canvas-type widget that supports group scaling.....but that is alot more work.
Of course, my view of things may be limited to what I think should be..... you can also post this on the newsgroup comp.lang.perl.tk and see what others may come up with. Maybe pack isn't the best manager for this? I don't dabble much in other geometry managers.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: perltk autoresize following users resize
by zentara (Cardinal) on Aug 20, 2008 at 16:57 UTC | |
|
Re^8: perltk autoresize following users resize
by rpelak (Sexton) on Aug 20, 2008 at 20:26 UTC | |
by zentara (Cardinal) on Aug 21, 2008 at 11:50 UTC | |
by rpelak (Sexton) on Aug 21, 2008 at 17:55 UTC | |
by zentara (Cardinal) on Aug 21, 2008 at 18:28 UTC |