Learning Perl/Tk 65
Learning Perl/Tk | |
author | Nancy Walsh |
pages | |
publisher | O'Reilly |
rating | 8/10 |
reviewer | Jason Bennett |
ISBN | 1-56592-314-6 |
summary | A solid introduction to using the Tk toolkit with Perl. If you have a reasonable Perl background, and a little GUI on the side, you'll pick it up in no time. |
Background
Greetings, all. This will be the first in a series of reviews dealing with some Tcl/Tk books I've recently acquired. Since I already have some Perl in my background, I took this one first, both to sharpen my Perl skills, and to find out what this Tk thing is all about. Given that my GUI experience is limited to Smalltalk and Java, Tk is quite easy to use. With Smalltalk, I was too busy wrapping myself around OO theory to enjoy the interface, and Java always seemed to make GUI stuff more difficult than it needed to be (although I still love it). Perl and Tk are strong partners, because they share a philosophy of getting things done without a lot of fuss. Perl and Tk are excellent replacements for any GUI scripting language you might use (read: VB). Read on to see how to jump in!
What's the book about?
This is another book in O'Reilly's Learning series (of which Learning Perl really saved my butt in college), which is dedicated to teaching the fundamentals of a certain topic. I want to compare this series with the Learn XY in 21 days type of books, although I believe that would generally be an insult to the quality of O'Reilly. Once you finish this book, you will have enough of an understanding of Tk to be able to do most small projects. You will know most widgets (although I'll admit my own knowledge is limited here), and will generally be prepared to be productive with Tk in Perl.
What's Good?
In order for you to be able to evaluate the usefulness of this book, it will probably help to understand where I'm coming from. I have a BSCS from Georgia Tech, and have enough languages under my belt to do some damage (Lisp is cool!). In fact, I learned Perl originally for a networking project using Learning Perl. It gave me enough to do what was needed. Having said that, I don't live to program, and in fact I'm not big on reading language books. I don't know every language under the sun, and I don't necessarily learn them with the greatest of ease. In other words, my results should be duplicable by most programmers. The most important thing when reading this book is to know Perl (at least have written some stuff in it), and probably have an idea of what to expect when writing GUI code.
Going into this, my Perl was definitely rusty (having not touched it in a while). I didn't have any trouble diving straight in, however. The Perl constructs used are not overly complicated, and my knowledge was sufficient. (NOTE: make sure you have a very recent version of Perl installed. My Redhat 5.2 needed to be upgraded to m4 before the examples would work. Also, get the errata from O'Reilly.) The early chapters deal with basic constructs and widgets, and spend a great deal of time on the geometry managers (go figure). Each chapter introduces a new widget, although some are used before they are introduced (just nod and smile when you see those and don't worry). There are plenty of examples, code fragments, and exercises to keep anyone busy. I tried to work as many as I could, to get a feel for the language, and generally felt like they were helpful. I never felt completely lost or confused, and generally followed things without much trouble. Having finished the book, I feel confident that, given a little work on my Perl, I could write a useful application with Tk, especially given some research on CPAN for various contributed modules. For me, the book worked.
What's Bad?
Nothing in this book is particularly bad, although there are a few nits I'd like to pick. First, the early emphasis on geometry was somewhat interesting. I'm not sure why I care about grid vs pack when I can barely create a button to put on the screen. For that matter, frames are referenced in a short chapter late in the book, after being used all throughout. If the concept is so basic, why not put it toward the beginning? Also, there were times when the author mentions that an option is esoteric, or generally unused, and then spends much more time than necessary on that point. If it's so esoteric, why is it being covered in a basic book like this one? Finally, there were a few times that the book did not explain a point well enough to me, and I had to divine the answer down the road (like configuring scrollbars). It was not a major issue, but there were some things that could have been clearer.
What's In It For Us?
If you want to learn Tk using Perl, this book will let you do that. It gives a solid introduction to the topic, and on completion, you will be a useful Perl/Tk programmer. Just know your Perl going in, and you will be fine.
Purchase the book over at Computer Literacy.
- Preface
- Introduction to Perl/Tk
- Geometry Management
- The Basic Button
- Checkbuttons and Radiobuttons
- Label and Entry Widgets
- Scrollbars
- The Listbox Widget
- The Text Widget
- The Canvas Widget
- The Scale Widget
- Menus
- Frames
- Toplevel Widgets
- Binding Events
- Composite Widgets
- Methods for Any Widget
- Configuring Widgets with configure and cget
- Operating System Differences
- Fonts
Index
Interesting Review. Too bad Tk/Perl is needed. (Score:1)
If only TCL wasn't so strange. (At least to me and I've been using it since 1994!) You wouldn't need to graft Tk onto Perl. On the other hand I find Perl's syntax to be not strange but down right poor.
Interestingly enough when I was at the Tcl BOF at the 1998 USENIX conf Outserhout seemed surprised that more people were interested in Tk than Tcl.
Ron Rangel
Perl's syntax is poor? I think not. (Score:1)
In short, it lets me write code the way I think. If it doesn't let you write code the way you think, well, that's fine. Let a thousand virtual flowers coded in a thousand different languages bloom.
-- Just Another Anonymous Coward
paper books? (Score:1)
Besides, I learn best when I have a book (usually ORA), a few browsers, a few rxvts viewing manpages, and a few vi windows. Makes for very rapid education..
A Quick Tk Question for the experts (Score:1)
Thanks, Aaron Newsome
Just plain GTK+ docs suck... (Score:1)
...at least the last time I tried to use them about 3 months ago.
A lot of the basic properties are there, but there's very little in the way of tutorials on higher level stuff.
Where to get? (Score:1)
The only FTP site I could find had a version number of 0.1.17--that can't be right. Where's the latest?
TkApache (Score:1)
I have this book, and it's nice to have a solid book, it's not THAT much more than what's out there already.
Perl's syntax is poor? I think not.-structure (Score:1)
VB to Perl/Tk translator? (Score:1)
Tip #1: Go to a bookstore and see for yourself! (Score:1)
All in all, I would say that it was the best programming language book that I have ever read.
Of course, it goes without saying that everyone is different. That's why I would recommend going to a bookstore and checking things out for yourself.
VB to Perl/Tk translator? (Score:1)
Doug Loss
Why bother? (Score:1)
Doug Loss
Vb apps already work under Linux (Score:1)
Doug Loss
VB to Perl/Tk translator? (Score:1)
Doug Loss
The focus on geometry management (Score:1)
Tip #1: Avoid 'Learning Perl' by O'Reilly! (Score:1)
Perl by Example by Ellie Quigley
and
Perl Power! (can't remember author)
Both are quite nice - and you'll _really_ want Perl by Example - Perl is so obtuse at times that you'll need the line by line examples to figure somethings out. How 'Learning Perl' ever came to be respected, I'll never know - unless it's because the authors are influential, which is a ridiculous way to evaluate a book, IMO.
Anyway - my 2 cents' worth. Good luck!
Go to a bookstore and see for yourself! - Agreed! (Score:1)
the store and check them out in person. Everyone
learns a little bit differently than the person
next to them, and that's the only way to be
sure...other than nuking the site from orbit,
of course!
Dumb newbie question - what is Tk.pm? (Score:1)
Why bother? (Score:1)
And since perl/TK works just fine on windows, you're not getting hurt at all, it's just all value-added. Oh, and you don't have to pay $1K+ (US) for the compiler.
Any program that translated VB to Perl would, by necessity, generate ugly code because VB code is just generally ugly. Better to do the job right the first time, I say. Or, you can always just wait for Micro$oft to come up with VB for Unix. >:)
Grid widget (Score:1)
Check out the FAQ (I can't remember the URL, but
it's worth poking around the CPAN directory on
CPAN, it's in a module listing included there).
The Tk module's worth the masses of disk space it
uses up just for the TkPod addon.
Chris Wareham
Try the (more than a) tutorial (Score:1)
as a reference. For the more detailed points I
currently turn to the mailing lists, which have
some very knowledgable posters.
Yeah, the rest of the GTK+ docs are a little
sparse at the moment. For low level stuff, volume
one of the O'Reilly X Programming series is good,
the one on Xlib. The GDK in particular maps quite
closely onto the functionality of Xlib - but with
a much, much nicer API.
Chris Wareham
BLATANT FLAMEBAIT - MOVE ALONG (Score:1)
Chris Wareham
More flamebait - but warrants a reply (Score:1)
problems they're fantastic. After all, that's
what VB is used for in the Windows world - quick
apps that may be a little kludgy and slow, but
that get the job done without taking an age to
program.
They're tools for a certain job (or jobs), don't
knock them.
Chris Wareham
Tcl and Perl (Score:2)
than Perl. The KDE to Perl's Gnome if you're
into weird analogies.
With version 8, Tcl/Tk really came of age, and I
have actually found myself questioning my
otherwise firm devotion to Perl. Especially when
I encountered oodles of memory leaks in the Perl
Tk module.
Chris Wareham
paper books? (Score:1)
obsolete, my arse...
Vb apps already work under Linux (Score:1)
paper books? (Score:1)
Perl/GTk+ Docs Suck but... (Score:1)
Vb apps already work under Linux (Score:1)
Good Perl 5 Into book? (Score:1)
http://www.oreilly.com/catalog/lperl2/
Tip #1: Avoid 'Learning Perl' by O'Reilly! (Score:1)
I want working examples of Perl code, I go to
"The Perl Cookbook" by Tom Christiansen & Nathan Torkington, also on O'Reilly.
(And "Learning Perl" may not be a perfect book -- myself I was a bit put off by the artificial nature of the examples in the first chapter -- but it's hardly "garbage". )
RE: Tip #1: Avoid 'Learning Perl' by O'Reilly!- NO (Score:1)
It was Perl, more than anything else, that got me into Unix, and hence, Linux.
I got more out of chapter one than I do out of most computer books...
'course I already had a good base in c/c++...
I just got Perl/Tk.. (Score:1)
It's a good book, and very informative. I spent all last night fooling with Perl/Tk, and searching the web for good online introductory material. It was slim pickins, let me tell ya.
I got more done after spending 20 minutes reading the book than I did with 4 hours of searching and trial and error.
Combine Perl/Tk with perl2exe, and who needs VB? Now my exact same Perl/Tk program can run on Linux or Win32, and if they don't have Perl installed, I just perl2exe it!
VB who?
Good Perl 5 Into book? (Score:1)
Good Perl 5 Intro book? (Score:1)
Perl's syntax is poor? I think not.-structure (Score:1)
Perl is as structured as you make it. It's up to the programmer. That's the way Larry wants it.
Perl/Tk module confusion (Score:1)
I'll make a wild guess that you're getting burned by some historical confusion concerning Tcl/Tk interfaces used by Perl. Unfortunately, there's a Tcl/Tk package (not likely to be what you want), an ancient Tk package (ditto, surprisingly enough) and what you do want: either Tk400.202.tar.gz, or, possibly, Tk800.012.tar.gz (which is based on the version of Tk used in Tcl/Tk 8).
Of course, it's possible that you do have the right version of perl/Tk, but don't have them installed correctly; re-installation might do the trick there.
Or, it's possible that the perl/Tk tax package isn't giving you useful feedback about what it really wants.
King Babar
Grid Geometry Manager for Tk (Score:1)
Tk, Tcl, and Perl (Score:1)
Other Tcl/Tk packages (Score:1)
Perl is an abortion (Score:1)
GUILE-Gtk Rocks!!!!!
Good Perl 5 Into book? (Score:1)
Take a look at it, it's a great book.
Concise PerlTk Instructional Book (Score:1)
Just read the book in question and loved it.
Having spent the last year with MS development tools such as MFC before learning the PerlTk module available from ActiveState I was enthralled with Perl's syntactic and stylistic flexibility, plus, the blazing speed I can design/build complex event driven GUIs without depending on brittle proprietary Wizard built hocus-pocus code.
I'm not surprised most users/consumers don't seem to respond well to menu driven console programs. PerlTk is a wonderful way to enhance your sysadmin scripts as well, and escape from those convoluted menus and argument lists. All this while you write code that can run across multiple platforms with little or no tweaking. What's not to like?
Nancy Walsh's book _Learning_Perl/Tk_ is supporting evidence for my theory that Perl programmers write better books.
VB to Perl/Tk translator? (Score:1)
Tip #1: Avoid 'Learning Perl' by O'Reilly! (Score:1)
If you are into all-inclusive tomes then be sure to scope out _Perl5_Complete_ published by McGraw-Hill ( their the ones that like to put corporate ads into the textbooks of elementary school children and then blame it on the companies that purchased the space