pht has asked for the wisdom of the Perl Monks concerning the following question:

It seems to me that following some rather unfortunate events, Perl/Tk is left unmaintained, and is slowly drifting away from our daily life. ActivePerl already got rid of it, suggesting Tkx instead. But IMHO Tkx is just as good as Gtk, or Qt -- in the sense that it's just another very thin layer over something built for a completely different programming language, and in order to use it, you have to have the guts to study the original documentation and to figure out how to do it in Perl, guessing and inventing tricks in the process. Perl/Tk, on the other hand was so much more: it was Perlish in its true sense, with a ton of documentation (and books), examples and auxiliary modules; its amount of code/performance ratio was excellent! So, with all this, what's going to happen to Perl/Tk? Are we going to just abandon it?

Replies are listed 'Best First'.
Re: Is there any hope for Perl/Tk ?
by zentara (Cardinal) on Nov 25, 2008 at 19:16 UTC
    Send money to srezic :-)

    Tk will always be around. Even in it's current limited state, it is a valuable tool, and the Tk::Canvas is still very useful (it's only drawback IMO, is the lack of transparency support....but Tk::Zinc picks up that slack. Tk ( not the Perl port) is moving ahead full speed, and the newest version has all sorts of improvements. The question is whether someone with c savvy will start the porting to the next Tk level, and hang around to do the innumerable bugs that will pop up.

    I'm gradually trying to move to Gtk2, even if Tk improves. It has very active developers and seems to be going in the right direction, and the perl code parallels the c code very well, so you can prototype in Perl, and if it's widely adopted, convert it to c with relatively little effort.

    So....Perl/Tk is not dead, it's not even dying...it's just growing old with no doctor's care, and being pushed off into the backrooms, while the youngsters( Gtk2, Wx, Tkx, etc) are kicking up their heels and making alot of noise.


    I'm not really a human, but I play one on earth Remember How Lucky You Are
      I don't know - about Gtk - last time I tried it was one hell with connecting all those signals and other, fairly low-level, stuff. Or, what is your way of doing Gtk apps?
        All of the newer gui toolkits have increased in complexity, and is why so many people who just have a simple gui to make, take a fallback position with Perl/Tk. As wiggins said, its mostly about geometry management, and just like with packing-and-Tk, you just have to jump in there and get your feet wet. After you construct a few hundred small test apps, you get the hang of it.

        The signal problem is a 2-edged sword. In Perl/Tk programmers would lament the lack of control over signals, now in Gtk2 they complain about the complexity. ?

        I admit, it is harder to use Perl/Gtk2 for 4 reasons.

        1. The docs take some time getting used to. They are auto-generated from the c code, so they are sparse and to the point. There are a few things to always watch when you open a Perl/Gtk2 perldoc. Look at the inhertitance tree at the top. Gtk2 widgets are well designed and have an inheritance tree. This is important, because the methods of the parents, apply to the child....so often you need to read the perldocs of the ancestors to find the method you need. Also, look at the signals for the widget at the bottom... it will tell you what signal you can define for the widget (also remember to look at the ancestor's signals).

        2. The signals. Yeah, they take getting used to, but if you keep your test code samples around, you can usually just cut'n'paste the signal you want into your app and modify the callback.

        3. The TRUE/FALSE return values from callbacks are often overlooked by someone coming from Tk. Gtk2 has a very clean way of running/stopping timers and chaining of signals. In a timer, return 1 to keep it going, 0 to stop it. In a signal callback, return 0 to let the signal propagate( chain), and 1 to stop it. Stopping a signal chain can be very useful, like when you want to control how a widget behaves.

        3. The Gdk window. The low-level Gdk window is the actual window seen on the screen, it is NOT the widget itself. Often you need to deal with this. The 2 most common issues are the Label widget and the DrawingArea. The Label has no Gdk window associated with it, so it has no signals. You often need to put a Label into an Event box, to give it signalling capabilties like changing colors or clicks. The DrawingArea is another tricky one, and it's low-level window needs to be redrawn on every expose event. The expose event is used often in Gtk2 and has to be watches out for.

        4. Color changes. Everyone in Tk laments the drab look and wants the natural system look and feel. Well Gtk2's theme engine does just that, but at the expense of making it very difficult (compared to Tk) to change colors in widgets. See renegadex's reply in Perl-Gtk2::How to set a window background image.. He was the first one here to figure out how to override the default pixmap theme for a window background.

        The best thing to do, is look at this Perl/Gtk2 tutorial and run the examples, and try to modify them. Save all your test code for snippets to be used later. Also, check out the Perl/Gtk2 maillist . Many answers are in the archives. Download the last year's worth of archives, for easy searching on your local computer. You will usually find an answer, and if you don't ask on the maillist.


        I'm not really a human, but I play one on earth Remember How Lucky You Are
Re: Is there any hope for Perl/Tk ?
by Wiggins (Hermit) on Nov 25, 2008 at 20:43 UTC
    My .2 cents is that PerlTK is the only way I write GUIs for MS Windows, through Active State(which I will now not update if PerlTk is no longer included). I looked at the Windows Exec 1.1 documentation, and decided back then that I didn't like the style or encumberment of the programming model. I took the Xwindows (llR2) road and stayed on that side of the fence until recently with PerlTK allowing me to put GUIs on Winboxes

    I guess I grew up "mashing rectangles together" in the Sony Widgets, OpenLook, early Java, HTML Forms, Frames and page layout. It is all about geometry management. If one doesn't understand these underlying fundamentals, they are limited; not by talent or knowledge, but by the limitations of some layout tool.

      My .2 cents

      That's quite a small amount of change~

      I'm so adjective, I verb nouns!

      chomp; # nom nom nom

      You can install Tk into ActivePerl via the package manager, but they don't ship it per default anymore and they even advise against doing it (because of bugs, some of which are security, or something).
Re: Is there any hope for Perl/Tk ?
by jeffa (Bishop) on Nov 25, 2008 at 18:38 UTC

    You won't get much sympathy from me as I don't use Tk at all. I found Tk drifting away from my life when I became a web programmer. Personally, I also find Perl/Tk to be very un-Perlish and more of your standard "create a bunch of objects and pack them up." However, i really would hate to see Perl/Tk die out, but as long as one person out there takes care of this project it won't be abandoned. Are you busy, ATM? :)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: Is there any hope for Perl/Tk ?
by Anonymous Monk on Nov 26, 2008 at 02:32 UTC
    Are we going to just abandon it?
    Yes, absolutely. Tk was designed to be a thin client, and Perl/Tk tried to make it fat, and so it became outdated quickly. Tkx is the way to go, if you want Tk (or maybe Tcl::Tk).
      So how do you do stuff like scrolled, rotext, hlist, in tkx? IMHO these (and many more) are the added value for Perl/Tk. In Tkx you have to DIY again and again ad nauseam.
        I was under the impression that installing Gtk2 on windows was a PITA too, mostly because google links point you to outdated instructions and ppm repositories. See Re^5: Accessible GUI Applications in Perl for currently working installation instructions (on Vista anyways with ActiveState Perl5.10). You need to chase down one dll, but the locations are located in the above node, so it should be easy for you.

        I'm not really a human, but I play one on earth Remember How Lucky You Are