in reply to Attaching a balloon message to text on the canvas

Does this work for you?
#!/usr/bin/perl use Tk; use Tk::Balloon; my $mw = MainWindow->new; my $canvas = $mw->Canvas()->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, -balloonposition => 'mouse', -msg => \%messages, ); MainLoop();

Replies are listed 'Best First'.
Re: Re: Attaching a balloon message to text on the canvas
by bblustein (Beadle) on Sep 25, 2003 at 19:41 UTC
    You beat me to it, zentara. The method of attaching the balloon to the canvas, but then calling the -msg => \%messages structure does solve the problem. However, it seems not to work on a "Scrolled" canvas. For some reason, when using the Scrolled("Canvas", etc...) syntax, the message returns a "hash ref...." type message, and returns it on the whole canvas, not merely the portion you want.

    So the likely solution is for you to do a regular canvas, add scrollbars the old manual way, and use the above hash format (which is available for easy browsing in the widget demo that perl tk comes with). I hope this helps you solve your problem. Do look at the widget demo for code ideas on this, as they have a good example of exactly this type of code (minus the scrolled version).
Re: Re: Attaching a balloon message to text on the canvas
by Anonymous Monk on Sep 25, 2003 at 20:49 UTC
    Thanks all! -Mark