Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: TK Placing Widgets in a Scrolling Pane

by Anonymous Monk
on Dec 03, 2021 at 18:23 UTC ( [id://11139368]=note: print w/replies, xml ) Need Help??


in reply to TK Placing Widgets in a Scrolling Pane

Hi, here is another way to put checkboxes with your text. There is a small mismatch in the scrolling, but you should be able to fix it.
#!/usr/bin/perl use warnings; use strict; use Tk; my @List = (0..50); my @cbvalue; my @cbs; my $mw = tkinit; $mw->geometry("400x400+100+100"); $mw->fontCreate('big', -weight=>'bold', -size=> 14 ); my $button = $mw->Button(-text => 'show selected', -command => \&show_selected, -bg => 'yellow', -font => 'big', )->pack(); my $pane = $mw->Scrolled('Pane',-bg=> 'lightblue') ->pack( -expand => 1, -fill => 'y' ); my $canvas = $pane->Canvas( -bg => 'white', -width => 400, -height => 800, )->pack(-expand => 1, -fill => 'both'); foreach my $i ( 0 .. $#List ) { $cbs[$i] = $canvas->Checkbutton( -text => "Number $List[$i]", -onvalue => 1, -offvalue => 0, -variable => \$cbvalue[$i], -font => 'big', -bg => 'lightseagreen', )->pack(); $cbvalue[$i] = 0; #initialize selections to off } MainLoop; sub show_selected { my @selected; foreach my $i ( 0 .. $#List ) { if ($cbvalue[$i] == 1){push @selected, $i} } print "selected: @selected\n"; }

Replies are listed 'Best First'.
Re^2: TK Placing Widgets in a Scrolling Pane
by Anonymous Monk on Dec 03, 2021 at 21:10 UTC
    Fix scroll region
    my $pane = $mw->Scrolled('Pane',-bg=> 'lightblue') ->pack( -expand => 1, -fill => 'both' );

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-03-28 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found