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'
| [reply] [d/l] |
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....
BlueLines
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.
| [reply] |
While I obviously can't speak for everyone, I can attempt to speak to why I, personally, write stuff with Tk:
- 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.
- 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.
- 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.
- 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'
| [reply] |
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 perltk.org as well, lots of examples are available there.
Kevin O'Rourke
| [reply] |
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 =)
-=rev=- | [reply] |
A question to tag along this one. Which is better for usage on a wide varity of machines: Perl/GTK or Perl/Tk? | [reply] |