http://qs1969.pair.com?node_id=942223


in reply to Re^4: resizing problem with Tk appl using PackForget
in thread resizing problem with Tk appl using PackForget

To get , natural geometry, that disregards a users resizing, that doesn't change position on screen, use undef

$mw->geometry( undef );

I'm still not a monkey, play along

Replies are listed 'Best First'.
Re^6: resizing problem with Tk appl using PackForget
by monger_39 (Initiate) on Dec 07, 2011 at 12:54 UTC
    sure; I don't blame anyone in being a monkey. Just thought adding more code would clobber...

    I tried the $mw->geometry(undef); this works great when hiding the to be hidden widgets. So far so good.
    But then when restoring the hidden, they are restored to their 'required' width and height, rather than those they had when they were 'packForgotten'.
    This seems to be the effect of the $mw->geometry(undef); call

    There is a diff between:
    $mw_w = $mw->width; $mw_h = $mw->height;
    and
    $mw_w = $mw->reqwidth; $mw_h = $mw->reqheight;
    After many tries I found a solution (?) by remembering the geometry of the MW when hiding:
    $mw_geom = $mw->geometry();
    and restoring this when re-packing:
    $mw->geometry($mw_geom);
    So I can add that to my code in some way or another. Only thing is that I do not understand it yet ;-(
      What you can also add is code to watch for the resize event, occuring while the Frames are unpacked. You can keep a running array of the current window size.

      It seems to me that repacking your children into larger frames might be accomplished by using -fill=>both -expand=>1 in the packing, and then calling the packPropagate command.... but that is untested.

      #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $current_size = $mw->reqwidth . "x" . $mw->reqheight; my $old_current_size = $current_size; $mw->bind( '<Configure>', sub{ &OnResize }); my $leave = 0; $mw->bind( '<Leave>',sub { $leave = 1; } ); $mw->bind( '<Enter>',sub { $leave = 0; &OnResize; } ); MainLoop; sub OnResize { my $current_size = $mw->width . "x" . $mw->height; if( $leave == 1) {return } if($old_current_size eq $current_size){return} ## Resize has occurred do something: printf( "Resize happened - old size: %s, new size: %s\n", $old_current_size, $current_size ); ## set the old size to the new size $old_current_size = $current_size; }

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        The binding for the resizing is a good idea, since I'm not sure yet what would happen exactly when resizing (manually) between my hide/show actions.

        Still, if I'm honest, I think this is a limitation of Tk: imho their should be more automatic resize options than me coding and remembering the size of all frames. For my app this is still doable, but for larger apps this would become very cumbersome!
        Well, I probably just have to live with it; maybe someone will make a widget->hide() and widget->restore() to ease doing this. thx for your help !