Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: TK Geometry Management

by thundergnat (Deacon)
on Mar 16, 2012 at 16:59 UTC ( [id://960022]=note: print w/replies, xml ) Need Help??


in reply to TK Geometry Management

Here's another example for comparison. (with some added silliness.) The frames grow/shrink when you resize the main window.

use warnings; use strict; use Tk; my %w; $w{mw} = MainWindow->new; my ($initial_height, $initial_width) = (60, 100); my @quadrants = qw/tl tr bl br/; my @color = qw/red yellow green orange blue black white/; { my ($row, $col) = (0,0); for my $frame (@quadrants){ $w{frame}{$frame} = $w{mw}->Frame( -borderwidth => 3, -relief => 'groove', -height => $initial_height, -width => $initial_width, )->grid( -row => $row, -column => $col, -sticky => 'nsew' ); $w{frame}{$frame}->bind('<Configure>', \&update_frames); $col++; $row++ unless $col %= 2; } } $w{mw}->repeat(150, sub { $w{frame}{$quadrants[rand @quadrants]}-> configure(-background => $color[rand @color]) } ); MainLoop; sub update_frames{ return if $w{updating}; $w{updating} = 1; my ($w,$h) = split /[x+]/, $w{mw}->geometry; for my $frame (qw/tl tr bl br/){ $w{frame}{$frame}->configure( -width => $w / 2 - 2, -height => $h / 2 - 2 ) } $w{mw}->update; $w{updating} = 0; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-16 09:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found