in reply to Re^8: perltk autoresize following users resize
in thread perltk autoresize following users resize

Yeah, I see. My best guess is to save the minimum geometry needed, and set it everytime A is selected. I guess if you wanted perfect fitting everytime, you could loop thru all the widgets, get their reqwidth and reqheight, sum them up with a small fudge factor added for padding, then set your mainwindow geometry to that.

Personally, I think the scrolled Pane is the best. Let the Scrolled Pane do all the expansion/contraction for you.

#!/usr/bin/perl use strict; use Tk; our ($goMainWindow); our (%ghGuiObjs); our (%ghGuiCBVars); my ($w,$h); $| = 1; &main(); sub main { buildGui(); MainLoop; } #end sub main sub updateA { if ( $ghGuiCBVars{"nEnableFrameA"} == 1 ) { $ghGuiObjs{"oContainerA"}->pack( -expand => '1', -fill => 'both', -pady => '5', ); $goMainWindow->geometry($w.'x'.$h); $goMainWindow->update; } 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; # $goMainWindow->geometry('200x300'); my ($oExit) = $goMainWindow->Button(-text => 'Exit', -command => sub{exit}, )->pack( -padx => '5', -pady => '5', -side => 'bottom', ); my $mf = $goMainWindow->Frame->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', ); $goMainWindow->idletasks; $w = $goMainWindow->reqwidth; $h = $goMainWindow->reqheight; print "$w $h\n"; #$goMainWindow->minsize($w,$h); }

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^10: perltk autoresize following users resize
by rpelak (Sexton) on Aug 21, 2008 at 17:55 UTC
    odd question...
    you said to post to comp.lang.perl.tk newsgroup
    Is that the same as the google group?
    Assuming it isn't... how do I post to that. A google search turned up the FAQ a bazillion times, but not that actual newsgroup...

    Randell
      comp.lang.perl.tk thru google-groups But I see your post in there.

      Just for your information, newsgroups are knd of like email servers, you need a program that can access the nntp protocol ( as compared to http ). Google has a gateway thru the web, but you can get a full fledged newsgroup program, and set it up. I use Agent, which runs on linux under Wine, as well on it's native Windows. Linux also has the Pan newsreader.

      You can even use Perl scripts.....nntp


      I'm not really a human, but I play one on earth Remember How Lucky You Are