in reply to Attaching a balloon message to text on the canvas
If a canvas is scrolled, it is wrapped in a frame. Attach the widget to the canvas itself: $balloon->attach($canvas->Subwidget('canvas'), ...
So to make my example work with scrolled canvas......
#!/usr/bin/perl use Tk; use Tk::Balloon; # the scrolled canvas causes problems with balloon # unless you use the subwidget my $mw = MainWindow->new; my $canvas = $mw->Scrolled('Canvas', -takefocus => 0)->pack( -expand => 1, -fill => 'both', ); my $id = $canvas->createText( 5, 5, -text => 'hello', -anchor => 'nw', ); my %messages = (); $messages{$id} = "there"; my $balloon = $canvas->Balloon(); $balloon->attach($canvas->Subwidget('canvas'), -balloonposition => 'mouse', -msg => \%messages, ); MainLoop();
|
|---|