Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Perl Tk compound formatting

by thundergnat (Deacon)
on Jun 07, 2013 at 12:32 UTC ( #1037668=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Perl Tk compound formatting
in thread Perl Tk compound formatting

You don't want to (can't actually) scroll the main window directly. You need to insert a scrolled Frame or Pane into the toplevel (main window) then pack your widgets inside that.

use strict; use warnings; use Tk; use Tk::Pane; my %w; $w{mw} = MainWindow->new; $w{mw}->geometry('220x350'); $w{bframe} = $w{mw}->Scrolled( 'Frame', -scrollbars => 'oe' )->pack( -expand => 1, -fill => 'both' ); for (qw/ this that a_longer_name X cheese verb witty_retort superstiti +on A..Z whatever/){ my $bttn = $w{bframe}->Button( -text => "$_", -font => 'times 19', -justify => 'left', -compound => 'right', -bitmap => ('error','info','question','warning')[rand 4], -anchor => 'e', -padx => 4, )->pack; push @{$w{buttons}}, $bttn; } $w{mw}->update; { my $width = 0; for (@{$w{buttons}}) { $width = $_->width if $_->width > $width; } for (@{$w{buttons}}) { $_->configure(-width => $width); } } MainLoop;


Comment on Re^3: Perl Tk compound formatting
Download Code
Replies are listed 'Best First'.
Re^4: Perl Tk compound formatting
by CColin (Scribe) on Jun 07, 2013 at 17:25 UTC
    Great, works well again. The geometry introduced has squashed the buttons but that reconfigures easily. Thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (19)
As of 2015-07-07 21:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls