Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Right out of mastering perl/tk:

use Tk; my $mw = MainWindow->new; my $c = $mw->Scrolled('Canvas')->pack(); my $canvas = $c->Subwidget('canvas'); $canvas->CanvasBind("<Button-1>", [ \&print_xy, Ev('x'), Ev('y') ]); sub print_xy { my ($canv, $x, $y) = @_; print "(x,y) = ",$canv->canvasx($x),", ",$canv->canvasy($y),"\n"; }

The code, as is, won't show any window. Why not? I even tried making a $mw label and packing it, but still nothing. What's up?

Replies are listed 'Best First'.
Re: Tk Woes
by RMGir (Prior) on Jul 06, 2002 at 01:25 UTC
    I don't have Perl/Tk handy, but I think you need to finish up with
    MainLoop;
    I found the answer googling; came up with this answer in the comp.lang.perl.tk FAQ.

    Edit:Also, check out Perl TK for more wisdom from the monks here about Perl/Tk.
    Edit^2: Hmmm, I _do_ have Perl/Tk installed, and that does work. Thank you, ActiveState :)
    --
    Mike