in reply to Re: Tcl::Tk listbox error
in thread Tcl::Tk listbox error
I was interested to see how much I needed to change the supplied code to get something running with Tk
use strict; use warnings; use Tk; my @cursors = qw/ 12 24 48 96/; my $mw = new MainWindow; my $lb = $mw->Listbox(-selectmode => 'single', ); $lb->pack(-side => 'left', -fill => 'both'); $lb->insert('end', sort @cursors); $lb->bind('<Button-1>', sub { $mw->configure(-background => $lb->get($lb->curselection)); + }); $lb->grid( -row => 10, -column => 2, -columnspan => 1); MainLoop();
Turns out, two lines - initialise $mw and call MainLoop(). The code executes without error and shows a main window containing a list.
|
|---|