I am learning Perl and GUI development, and working currently on code that will work on multiple toolkits (Tk, Wx, Gtk etc). I need help with Tk. For my purposes I have to place all my widgets (rather than pack->() them). I wish to create a fixed sized, fixed position scrolling Listbox, to be later populated by other items. This works perfectly well if I insert strings, I appear not to be able to insert other widgets (e.g Checkbuttons).
Have searched many places, and most suggest I should use pack->(), but I guess mixing pack and place does not work, and I am committed to use pack for my use-case. Your guidance will be gratefully received,#!/usr/bin/perl use strict; use Tk; my $mw = MainWindow->new; $mw->geometry('400x250'); my $canvas = $mw->Canvas( -bg => 'lavender', -relief => 'sunken', -width => 400, -height => 250)->pack(-expand => 1, -fill => 'both'); my $size=[200,200]; # size of the widget my $location=[50,12]; # position of widget my @strings2 = qw/apples bananas pears grapes/ x 5; $canvas->{"listbox"}=$mw->Scrolled("Listbox", -bg => 'white', -scrollbars => "e", -selectmode => 'extended', -width => (${$size}[0])/7, # some scaling -height => (${$size}[1]+12)/15); # scaling $canvas->{"listbox"}->insert('end',@strings2); # This works $canvas->createWindow(${$location}[0] ,${$location}[1], -anchor => "nw", -window => $canvas->{"listbox"}); MainLoop();
saif
In reply to TK Placing Widgets in a Scrolling Pane by saiftynet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |