Automatic optimal window sizing 
Author Message
 Automatic optimal window sizing

I'm writing a utility to monitor one of our systems. The display will have
items added and deleted as the system status changes.

This works fine, and the main window grows and shrinks as needed so as to
optimally contain all widgets. However, as soon as the main window is
manually
resized, all this nice auto-resizing stops happening.

To demonstrate the problem try this program:

#!/usr/bin/perl -w
use strict;
use Tk;

my $main = MainWindow->new;

$main->Button(-text => "Grow", -command => \&click)->pack;

Tk::MainLoop;

sub click {
    my $b = $main->Button(-text => "Shrink")->pack;
    $b->configure(-command => sub {destroy $b});

Quote:
}

__END__

See how the window grows when you click Grow, and shrinks when you
click Shrink?
Now manually resize the window and click Grow/Shrink again. See how the
behaviour is different?

How can I restore the auto-sizing behaviour once the window has been
resized? Or, better still, how can I get the main window to resize to
the optimum size (so that all children just fit) whenever I add/remove
a child widget?

I've read the docs about pack and packPropagate, but changing the
packProgagate property of the main window doesn't seemto change this
behaviour.

Thanks in advance for any help,
Dave.



Thu, 19 Jun 2003 05:19:44 GMT  
 Automatic optimal window sizing

Quote:

> I'm writing a utility to monitor one of our systems. The display will have
> items added and deleted as the system status changes.

> This works fine, and the main window grows and shrinks as needed so
> as to optimally contain all widgets. However, as soon as the main
> window is manually resized, all this nice auto-resizing stops
> happening.

[snip]

Quote:
> How can I restore the auto-sizing behaviour once the window has been
> resized? Or, better still, how can I get the main window to resize to
> the optimum size (so that all children just fit) whenever I add/remove
> a child widget?

If you add the following line after you create the window:

    $main->resizable(0, 0);

the window will no longer be resizable by the user, but it will still
automatically resize as you add and remove widgets.
--
Kevin Michael Vail | a billion stars go spinning through the night,

. . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)



Thu, 19 Jun 2003 05:46:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Automatic mail generation in windows 95

2. CGI.pm Bug: file upload file size mismatch when file size is close to buffer size

3. Optimal way to handle variable value search replace

4. Optimal keys on associative arrays

5. Searching for tags - Is this optimal

6. Cutting variable length scalar into chunks - optimal?

7. Window sizing with perl or CGI.pm

8. X Windows: Obtaining Screen Size of Display

9. How to get window size

10. Setting your dos window size, title and colour!

11. Does anyone know how to determine window size?

12. File size checking over Windows network returns 0

 

 
Powered by phpBB® Forum Software