Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: resizing problem with Tk appl using PackForget

by Anonymous Monk
on Dec 07, 2011 at 11:33 UTC ( #942223=note: print w/ replies, xml ) Need Help??


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


Comment on Re^5: resizing problem with Tk appl using PackForget
Download Code
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 !

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942223]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2014-09-23 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (240 votes), past polls