Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Tooltips for Tk widgets in perl - easier than ever

by vkon (Curate)
on Jul 12, 2007 at 17:14 UTC ( #626281=perlmeditation: print w/replies, xml ) Need Help??

I want to share my experience how to make Tcl/Tk GUI easier for end-user.

Perl/Tk have balloon widget, so anyone can create and manipulate Balloon widget.
I've rarely actually used it, because of its complexity.

Now that I'm using Tcl::Tk for a long time already for Tk GUI, I want to share how much easier it is.

Every widget in Tcl::Tk now have tooltip("text") method, so now tooltips are trivial and I use them even for tiny programs, just making final programs better to user.

Here's an example:

use Tcl::Tk; my $mw = Tcl::Tk::tkinit; $mw->Entry->tooltip('enter small values here')->pack; $mw->Button(-text=>'test')->tooltip("test button\npress to see the res +ult")->pack; Tcl::Tk::MainLoop;
That simple!

Best regards,
Vadim.

Replies are listed 'Best First'.
Re: Tooltips for Tk widgets in perl - easier than ever
by zentara (Archbishop) on Jul 13, 2007 at 12:17 UTC
    Gtk2 has similar ease of adding tooltips to any widget:
    my $tooltip1 = Gtk2::Tooltips->new; my $tip_text1 = 'Just Another Exit Button'; $tooltip1->set_tip($button, $tip_text1, undef);

    and it's not really that much harder in Perl/Tk. The real difficulty with balloons comes, when you need to dynamically change them at post time.

    #!/usr/bin/perl #by Jack D. # Just attach the balloon to the widget itself instead # of treating it like a canvas item. # The script below shows both. ## Example ## use Tk; use Tk::Balloon; use strict; my $mw=tkinit; my $c=$mw->Canvas->pack; my $l = $c->Label(-relief=>'sunken',-text=>'embedded window'); $c->create('window',150,150,-window=>$l); $c->create('text', 150,100,-text=>"A Text Canvas Item",-tags=>'TESTTAG +'); my $ba = $mw->Balloon(-background=>'yellow'); $ba->attach($l,-initwait=>0,-balloonmsg=>'Attached to Widget'); $ba->attach($c, -initwait=>0, -balloonposition => 'mouse', -msg=>{ 'TESTTAG'=>'A Canvas Item'} ); MainLoop; __END__

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      all true.

      However, perl/Tk limits to Tix's Balloons, whereas in Tcl/Tk there is larger choice of different "tooltip" widgets, so allowing better TIMTOWTDI principle.

      Best regards,
      Vadim.

        Yeah. someone has to keep people aware of the virtues of Tcl/TK ...... it's good, but Tcl is not Perl, thats it's drawback in my book.

        I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://626281]
Approved by Corion
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-06-13 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (54 votes). Check out past polls.

    Notices?