Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Perl/Tk exemplars?

by dws (Chancellor)
on Feb 20, 2002 at 20:57 UTC ( #146630=perlquestion: print w/ replies, xml ) Need Help??
dws has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

When launching into something new, I learn best by finding and studying good example solutions from the new domain. For almost any area of programming you get into, there's usually concensus about who has done thing right, and/or who is worthy of study.

I'm about to launch into Perl/Tk land for the first time, and I'm looking for recommendations on good Perl/Tk code to study. (I do have Mastering Perl/Tk on order.)

What can you recommend for study? What scripts/applications really do Perl/Tk "right"? Who really puts Perl/Tk through its paces? What are good example of direct manipulation?

Thanks in advance for pointers.

Comment on Perl/Tk exemplars?
Re: Perl/Tk exemplars?
by Chmrr (Vicar) on Feb 20, 2002 at 23:51 UTC

    One word: widget It's a comilation of about 20 or more small Tk scripts that demonstrate a large variety of what one can do with Tk. It puts itself into your path, so you should be able to run it from any command prompt.

    The other cool thing is that there's a button under every example that shows the full source code used to make the example. However, one should be warned that the top handful of lines are specific to the fact that it's an example in the widget program, and those lines should not be copied verbatim into anything you write.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Re: Perl/Tk exemplars?
by BlueLines (Hermit) on Feb 21, 2002 at 07:00 UTC

    Ok, this may be a bit off topic, but why Tk? IMHO, its' ugliness rivals Motif. I mean, it's really really ugly. There are very well maintained perl bindings for Gtk+ and there are (apparently orphaned) perl bindings for qt as well. Both of these are fairly cross platform (ie, win32 + *nix). Both of these are prettier than Tk. WIth Gtk+, you can use Glade to play around and see what types of widget stacking are possible.

    I mean, if you want to learn Tk, learn Tk. I'm just making sure you know that there are more modern alternatives that are easier on the eyes....


    Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.

      While I obviously can't speak for everyone, I can attempt to speak to why I, personally, write stuff with Tk:

      1. Documentation. This is a biggie. With two books out on Perl/Tk (the aforementioned Mastering Perl/Tk, as well as Learning Perl/Tk) it's fairly comprehensively discussed in dead tree form -- if that's how you like your documentation. It also has much more comprehensive digital documentation, as well; I mean, it has about a hundred pieces of POD, including one for every widget.
      2. Portability. Despite what you say above, I was unable to find reference to Gtk working under Win32, or qt. In either case, it looks to be a hassle, and the few places I did see reference to it, people sad "if it exists, it's probably buggy." I'd be inclined to agree with them. Tk installs well and easily under Activestate, as one can just use PPM. I saw no such option for Gtk or qt.
      3. User base. From what I've seen, there are quite a few more people already using Tk than use Gtk or qt. This means that it's easier to find people with clue when you get stuck. Unfortunatly, this is a self-enfocing problem.
      4. I don't care that much about the ugliness. For people who care about that extra bit of spit and polish, perhaps Tk is a cancer on their screen. That's probably the price of being cross-platform, though.

      perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

        Reason: (petral) as per content

        For more information on this node visit: this

      Quite apart from real cross-platform capability (rather than "it works on Linux and you might just about get it to work on Windows") Tk can look good if a bit of thought is put into the design.

      Another Tk tip is to make use of the standard dialogs, which should use the dialogs provided by your OS (if any). For example on Windows you can use the standard file open and colour picker dialogs.

      Have a look at as well, lots of examples are available there.

      Kevin O'Rourke

Re: Perl/Tk exemplars?
by Reverend Phil (Pilgrim) on Feb 21, 2002 at 22:44 UTC
    Thanks for the post - I recently started working with Tk myself. I'm on Win32, and had some trouble getting things to look just the way I want them. I used some of the Widget source for the occasional answer, but found myself a tad confused when trying to weasel out the actual widget code that gives you the dismiss/see code functionality =) There are definitely some tweaks I'm looking to make to my app that I'm a little lost on still.. like a better method of reading in a line of data and keeping it hidden when a certain menu-item is selected..

    I've got Learning Perl/Tk, and it helps..but I'm looking for more real-world examples also. It appears that you're post has sparked a link or two, so thanks again =)

Re: Perl/Tk exemplars?
by Ashcrow (Acolyte) on Feb 22, 2002 at 04:34 UTC
    A question to tag along this one. Which is better for usage on a wide varity of machines: Perl/GTK or Perl/Tk?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://146630]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2014-09-21 05:05 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (166 votes), past polls