Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

GUI toolkit+designer for the perl newbie

by faibistes (Novice)
on Sep 07, 2011 at 18:37 UTC ( #924638=perlquestion: print w/ replies, xml ) Need Help??
faibistes has asked for the wisdom of the Perl Monks concerning the following question:

I'm going to teach a perl course. Which is crazy, but I digress. I have to teach them a way to code X-Windows UI's. What's the way to go? It should be

1) Well supported by perl, with decent and up-to-date bindings and well documented

2) With at least one good tutorial on the Interwebs

3) A GUI designer app exists for it

4) Well suited for beginners

Nothing comes to my mind... Tk seems more and more outdated, I can't find any working UI designer for it, GTK+Glade doesn't look well supported by perl, or at least I can't find decent documentation and tutorials, and wxPerl+wxGlade looks promising, but for the life of me I can't find a real tutorial anywhere. Any ideas?

Comment on GUI toolkit+designer for the perl newbie
Re: GUI toolkit+designer for the perl newbie
by Anonymous Monk on Sep 07, 2011 at 20:31 UTC
Re: GUI toolkit+designer for the perl newbie
by Gangabass (Priest) on Sep 08, 2011 at 06:11 UTC

    Tk is not outdated . Here you can find excellent TK tutorial for Perl

      Not to be contrary, but yes, perl/Tk (what perl programmers refer to as Tk) is outdated, and has been for at least 10 years, in relation to the toolkit it is built on, Tcl/Tk

      The tutorial you link to is for Tkx , a thin interface to Tcl, and its gui library toolkit, Tk

      Unlike Tk.pm, Tkx does not have a book or two dedicated to it, and relies mostly on Tcl/Tk documentation, which means you have to learn Tcl

      The tutorial you linked helps with the easy tcl syntax, like the Tkx docs, but as soon as you reach for the reference Tcl/Tk docs, you have to learn more Tcl syntax, so you can translate to perl.

      Tcl::pTk, like Tkx, builds on Tcl but does it with Tk.pm compatible syntax, and takes the brilliant step and exposes the Tcl interpreter, so you can Eval Tcl code directly, no need to translate to perl at all

      What Tk.pm has going for it, is years and years and years of use, many perl users, and many perl examples and cpan extensions

      What Tkx/Tcl::pTk have going for it, is years and years and years of use, many Tcl users, many tcl examples, and TEA/TEApot/TEAcup extensions

      With ActiveState/ppm/Tkx you get, a certain set of Tcl/Tk widgets, Tcl::tkkit, great for embedding via par/perlapp/perl2exe. Its mostly a one-two-click operation, but you can't add more widgets.

      If you go your own way :) you can install ActiveTcl (or other tcl distribution) and then install Tcl/Tcl::pTk||Tkx, you also get the ability, to install other widgets, like TIX, at the cost of two installations to manage, two path entries ... unless you decide which widgets you want and then build your own Tcl::kit equivalent

      So yes, that tutorial you linked, is most excellent 2) one good tut.

      If you stick to ActivePerl, Tkx is well supported by perl at minimal expense to the programmer, with an excellent but fixed set of widgets, with decent enough documentation.

      SpecTCL fills the WYSYWIG designer role nicely, but the binaries are a tad dated, built around Tk 8.4 (ActivePerl deploys with the stable 8.5 , the current beta is 8.6)

      Suitable for beginners? Yup, its a very good toehold, ought to get a beginner making short GUI programs in short order

      Hi :)

      As AM points out above, in a very nice article I might add, you've linked to a tutorial whose Perl code is for Tkx. Here's a Tk version:

      use Tk; use Scalar::Util qw{looks_like_number}; my ($feet, $metres) = (q{}, q{}); my $mw = MainWindow->new(-title => q{Feet to Metres}); my $f = $mw->Frame() ->grid(-padx => 12, -pady => 3, -sticky => q{nsew}); my %pad = (-padx => 5, -pady => 5); my $feet_E = $f->Entry(-textvariable => \$feet, -width => 7) ->grid(-row => 0, -column => 1, -sticky => q{we}, %pad); $f->Label(-text => q{feet}) ->grid(-row => 0, -column => 2, -sticky => q{w}, %pad); $f->Label(-text => q{is equivalent to}) ->grid(-row => 1, -column => 0, -sticky => q{e}, %pad); $f->Label(-textvariable => \$metres) ->grid(-row => 1, -column => 1, -sticky => q{we}, %pad); $f->Label(-text => q{metres}) ->grid(-row => 1, -column => 2, -sticky => q{w}, %pad); my $calc_B = $f->Button(-text => q{Calculate}, -command => sub { $metres = looks_like_number($feet) ? int(0.3048 * $feet * 10000.0 + 0.5) / 10000.0 : q{}; })->grid(-row => 2, -column => 2, -sticky => q{w}, %pad); $feet_E->focus(); $mw->bind(q{<Return>} => sub {$calc_B->invoke()}); MainLoop;

      -- Ken

Re: GUI toolkit+designer for the perl newbie
by blindluke (Scribe) on Sep 08, 2011 at 06:29 UTC

    I'd still recommend Tk. It may seem outdated, but it works, it gets the job done, and there's plenty of documentation and tutorials around. And if you are going to teach a course, and the course's aim is to teach a way to code GUIs, then I think that your toolkit of choice should be well documented, and easy to use first, because it's just a tool to teach your students working with widget toolkits.

    There's a good chance, that if your students learn to use Tk, they won't have many problems switching to wx, or GTK, as long as you teach them the basics - separating the presentation and the content, laying out the widgets, using some geometry managers, and so on.

    That said, some links that can be useful:

    I hope that any of this will be useful to you. All the best, and good luck with the course!

    regards,
    Luke Jefferson

Re: GUI toolkit+designer for the perl newbie
by zentara (Archbishop) on Sep 08, 2011 at 10:51 UTC
    I second the call for Tk, to teach beginners. It is easier to learn and get up and running than any other gui. You do a dis-service to students when you start them off writing with a GUI designer. You will spend more time just trying to decipher the boilerplate code those designer programs emit, than if you just taught the basics of windows, bindings, and event loops.

    If you are under orders to teach with a GUI designer, Glade is still probably your best bet.

    If you notice, very few people actually use those GUI designer programs for anything more than simple popups and displays, because it just gets too hard to follow the boilerplate code.


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-09-22 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (185 votes), past polls