Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: resizing problem with Tk appl using PackForget

by monger_39 (Initiate)
on Dec 07, 2011 at 09:50 UTC ( #942196=note: print w/ replies, xml ) Need Help??


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

I like the packArgs trick. Also easy to add an arg to the sub for selecting one of the options.

the canvas within this BANG app resizes fine for each of the chosen packArgs.

But pls try this:
* split the PackForget() and pack() over 2 buttons (show, hide) one containing the packForget, the other the pack
* start the app, and resize the main window
* then hit 'hide'

The canvas and mainwindow are not resized.
I seem to be missing the point about the resizing through a call to geometry. Can't find a hint in the docs either.


Comment on Re^4: resizing problem with Tk appl using PackForget
Re^5: resizing problem with Tk appl using PackForget
by Anonymous Monk on Dec 07, 2011 at 10:06 UTC

    But pls try this:

    No thanks, I'm no monkey. If you have modified my program, post the new program :)

Re^5: resizing problem with Tk appl using PackForget
by Anonymous Monk on Dec 07, 2011 at 11:33 UTC

    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

      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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (13)
As of 2014-12-22 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (119 votes), past polls