Search code examples
perluser-interfaceperltk

How to wrap text in balloon in Perl/Tk


How can I wrap the text displayed in a balloon in Perl/Tk?

my code is something like this

my $balloon1 = $mw->Balloon();
my $txt = "file Name: ".$fileName."\n"."location: ".$path;
$balloon1->attach($button, -balloonmsg=>$txt);

But this help text in balloon goes out of screen boundaries. Is there a way to wrap the text displayed in a balloon?


Solution

  • The Label widget inside the Balloon is advertised as the "message" subwidget and may be accessed directly using:

    my $balloon1_label = $balloon1->Subwidget('message');
    

    You can apply all Tk::Label configure options here, for example the -wraplength option:

    $balloon1_label->configure(-wraplength => 100);