Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^3: resizing problem with Tk appl using PackForget

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

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

Do you perhaps know of an easy way to store/remember the pack arguments for each widget?

Make it a widget (read object)

my $rememberer = MakeHideDaddyChildButton( -buttonDaddy => $top_frame, -hidersDaddy => $mw, # gets resized -hiders => [ $top_frame, $middle_frame ], #daddys kiddys ); $rememberer->pack;

This does leave the problem that after a resize, the 'hide' action does not minimize the container frame. Any idea how to get that fixed?

Um, repack the container frame (or its parent, or mainwindow ) .... or better idea, only ever forget/repack the container frame

Might need to resize (->geometry)

I'd have posted an example, but I was already working on this one, keep shooting, and watch the canvas resize :) the mainwindow doesn't resize

#!/usr/bin/perl -- use strict; use warnings; use Tk; my $packArgs = do { my @packargs = ( [ qw/-expand 0 / ], [ qw/-expand 1 -fill x / ], [ qw/-expand 1 -fill y / ], [ qw/-expand 1 -fill both / ], ); my $ix = -1; my $xx = @packargs ; sub { $ix++; warn $ix % $xx ; return @{ $packargs[ $ix % $xx ] }; }; }; my $mw = tkinit; $mw->Button( -text => 'BANG!', -command => \&bangBang )->pack(qw/-side top -anchor n/); my $ca = $mw->Canvas( background => 'white' ) ->pack( $packArgs->() ); $ca->createOval( 50, 50, 100, 100, -fill => 'pink', ); MainLoop; exit 0; sub bangBang { my $b = $Tk::event->W; $mw->Busy; $b->configure(-state => "disabled"); my $text = $b->cget(qw/ -text /); unless( $text =~ s/(\d+)/ $1 + 1 /e ){ $text .= " 1"; } $b->configure( -text => $text); $ca->packForget; $mw->update; sleep 1; $ca->pack( $packArgs->() ); $mw->Unbusy; $b->configure(-state => "normal"); $mw->update; }

Replies are listed 'Best First'.
Re^4: resizing problem with Tk appl using PackForget
by monger_39 (Initiate) on Dec 07, 2011 at 09:50 UTC
    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.

      But pls try this:

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

      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;
        $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:
        So I can add that to my code in some way or another. Only thing is that I do not understand it yet ;-(

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2022-12-06 13:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found