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

zentara's post was the most helpful. But I was hoping there was a way to just turn the auto resizer back on, not to have to force the window to a given size.
Example...
window is 100 tall. Containing a listbox. listbox is 25 tall. User wants so see more of the list box without scrolling, so they drag the window to 125. Widgets are setup so that the listbox expands to 50, and nothing else does. Then user checks a checkbox that causes the packing of an additional listbox in the gui. If the user hadn't manually resized the window, it would just expand to give space to the new listbox. But since they did, it will not change size, and the bottom of the form will run off the bottom of the window.
of course since I know the size of the new listbox, I could increase the size of the window, but that would mean keeping track of sizes for everything that can be packed and unpacked, which is a lot of things. Too many in fact to be rational to do.
all said and done, it sounds like this solution doesn't scale well to large apps. Randell
  • Comment on Re^2: perltk autoresize following users resize

Replies are listed 'Best First'.
Re^3: perltk autoresize following users resize
by zentara (Cardinal) on Aug 19, 2008 at 17:01 UTC
    I'm not sure exactly what you want, but it sounds like you are looking for a Tk::Adjuster. See Tk::Adjuster, how to keep proportions for maintaining ratios. Here is a simple example with no ratio.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; my $mw = MainWindow->new(); my $pane = $mw->Scrolled('Pane', -sticky => 'nsew', -scrollbars => 'osoe', )->pack(-fill => 'both',-expand => 1); my $i; for ($i = 0; $i <= 5; $i++){ my $frame = $pane->Frame( -relief => 'ridge', -bd => 1,) ->pack(-side => 'top',-fill => 'both',-expand => 1); my $adjust = $pane->Adjuster(); $adjust->packAfter($frame, -side => 'top',-fill=>'both',-expand=>1); my $label = $frame->Label(-width => 30, -text => "Frame ". $i,)->pack(); } my $frame = $pane->Frame( -relief => 'ridge', -bd => 1,) ->pack(-side => 'top',-fill => 'both',-expand => 1); my $label = $frame->Label(-width => 30, -text => "Frame 6 ")->pack(); MainLoop;

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      I looked at the adjuster and it didn't do what I needed... so let me try to explain better.

      I have a window, I put in a labeledframe which we can call foo. In it, I put a checkbox (enable foo) and a frame(which I use as a kind of container). If you uncheck the checkbox, the container frame is packForget'ed. If you recheck it, it is pack'ed. By default, the whole window resizes after each change. But if while it is unchecked, the user resizes the window slightly (in the y direction), then if they check the checkbox it will not resize to fit the new contents, causing them to be off the bottom of the gui.

      So when the user does a manual resize, it does something to stop the automatic resizing. I want to turn the auto resizing back on.

      Of course I could manually handle the resizing in this case, but in the real case there are just too many widgets and too many other things to make that effective.

      Randell
        As usual, there probably is a solution, but without a small code example that demonstrates it, I'm not going to take the time to write it from scratch. You give a good explanation of what you want, but it all boils down to how you are actually coding it. It sounds to me, like you want to use that previous example I showed, that gets the new window measurements after a resize, and do some sort of repacking/packPropagation trickery. If you did make a minimal example, you could also post it on comp.lang.perl.tk, and get more eyes looking at it. If worse comes to worse, you could completely withdraw the top window, repack everything, then raise it. But you get a crummy flicker that way. Also, there may be other techniques than what you are using, which is unknown to us. Maybe all you need to do is do a geometry statement with the new size, then update/packPropagate the window.

        I've found when you get into these esoteric situations, there is usually a way out by putting things into a scrolled Pane or something similar. like deep nesting of frames with expand set.


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