Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Perl TK

by slacker (Friar)
on Sep 29, 2010 at 15:09 UTC ( #862625=perlquestion: print w/replies, xml ) Need Help??
slacker has asked for the wisdom of the Perl Monks concerning the following question:

I'm delving back into perl for work and I wanted to implement some kind of GUI with my code.
Apparently Perl/TK is dead now and people are suggesting Tkx.
Now I'm stuck with a Mastering Perl TK book that I suppose is no longer relevant.

What are the advantages to using Tkx over Perl Tk?

Should I stick with Perl TK despite it being dead or should I take the plunge into Tkx?

If Tkx is the route to go, does anyone have any books they would suggest? I prefer books to reading online.

I guess I'm looking for pros and cons between the two and if its worth it to consider the new option.
Thanks for any help.

Replies are listed 'Best First'.
Re: Perl TK
by zentara (Archbishop) on Sep 29, 2010 at 16:08 UTC
    What are the advantages to using Tkx over Perl Tk?

    The only advantage I see is ActiveState is behind it, and will probably do a better job of fixing bugs and adding new features.

    But the plain old Tk is NOT dead, and does have some advantages, in that there is a huge base of code already out there ready to google for examples, it is easy to learn, and it is relatively stable. The Tk::Zinc module alone makes it worth knowing Tk, as it is probably the best canvas out there.

    In my opinion, if you want to choose a good GUI toolkit that has a bright future, and is actively developed ( many new modules for modern applications, like GTK webkit and GStreamer), go with Gtk2. If you like the OO approach, use WxWidgets, which on most systems is an OO layer on top of Gtk2.

    Finally ask yourself this: If ActiveState suddenly drops Tkx, where will you be? With plain old Tk, it will always be on CPAN.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      Okay, assume you have inspired me to look into GTK2 as my brighter future for migrating away from Tk. Will I be able to build a stand-alone *.exe using PAR from my Perl app employing GTK2?

      That's kind of important to me. I myself use the script. But for giving things away to non-Perl folks stuck with Windoze, nothing satisfies like a stand-alone exe.

        I don't build stand alone executables, but Cava has had good reports. I would suggest getting their free version, and go thru one of the Gtk2 tutorials, like at Novell's Gtk2 tutorial and see how well Cava packages your tutorial scripts.

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh
Re: Perl TK
by halfcountplus (Hermit) on Sep 29, 2010 at 15:43 UTC

    The regular old perl TK module is not "dead now" -- it is still being maintained. I would guess it's one of the first things many people who learn programming via perl make use of, it is not particularly difficult or awkward as far as GUI stuff goes, I've done great things with it and I am sure plenty of people still use it.

    You should understand that TK and TKx are both just perl interfaces to the same system Tcl/Tk library. In other words, if there is any "advantage" of one over the other, it is purely in terms of the style of the perl interface. From looking at the Tkx CPAN page, it appears the author simply wanted one which presents more transparent access to the Tcl library. If you are not a Tcl programmer (Tcl is another interpreted language like perl) then that may be somewhat irrelevant for your purposes.

    To put it another way: this is the same as the difference between doing (eg) a GTK application in python vs. a GTK app in perl: the end result will be identical and uses the exact same system libraries. They are both GTK applications. So, if you have a good book on the TK module (I also prefer books), just use that as I suspect you will have to wait a long time before you find any books specifically on TKx (like, forever...). This is from the TKx CPAN page:

    The main idea behind Tkx is that it is a very thin wrapper on top of Tcl, i.e. that what you get is exactly the behaviour you read about in the Tcl/Tk documentation with no surprises added by the Perl layer.

    This makes sense if you want to use the Tcl/Tk (non perl) documentation to learn Tk, which online is probably more extensive. But if you want to learn it out of a book called "Mastering Perl TK" then it is a non issue. Hence, the book is only "no longer relevant" if you are sure you'd prefer the other module for some reason -- do you have any concrete reasons for that? If so, there are books on Tcl/Tk, but that seems very awkward to me as there will be no perl in them. You might as well just learn Tcl...
      Thanks for all the information. I had read this morning that perl tk was no longer being maintained, which I why I said my book is no longer relevant.
      I would rather not stick with a dying method of implementing TK.
      Since this is not the case I guess I have no issues. Thanks again.
        There is a bit of truth in the lack of maintenance in the Tk module. When Nick Ing Simmons( Tk module's author) passed away, Slaven Rezsic took over maintenance. BUT, he is just maintaining it, as in fixing bugs.

        There has been all sorts of advances in the underlying TCL libraries; especially in things like Theme Support and thread safety, that need to be incorporated into Perl Tk. In that respect, Tk is falling behind. On the other hand, Tk is so simple to use, that is is very easy to reach for it for simple GUI's, like just displaying some text or lists.

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh
Re: Perl TK
by BrimBorium (Friar) on Sep 29, 2010 at 16:50 UTC

    I have also to cope with Tkx because of updating to AS perl 5.12, which has no Tk but Tkx (I read Tk will not even compile with 5.12 due to 3 critical bugs, but I did not tryout myself). So I tried to migrate a simple GUI with some frames and OpenFile to Tkx and it was nearly the same like in Tk, only the function names have changed. Checkout, the examples helped me a lot.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://862625]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-01-16 11:25 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (149 votes). Check out past polls.