Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Wx vs. Tk

by SleepNot (Pilgrim)
on Oct 17, 2003 at 12:28 UTC ( [id://299988]=perlmeditation: print w/replies, xml ) Need Help??

Wx vs. Tk


When I started learning Perl I've made some scripts for searching files in a Samba Network (on Windows Shares). After I finished the console version of the program I wanted to make a fontend or a graphical user interface so I installed Tk.

I've tried to learn Tk but it was no use. Tk it seemed to me like a hard,confusing and ugly way to design an user interface. Furthermore the controls and the windows that i've managed to create looked realy strange and obsolete so I have gave up with my project.

Few months later I've heard about wxWindows and after some research I found wxPerl. wxPerl (or shortly Wx) is a new object-orientated way to design a graphical user interface in Perl. After I tried some examples and modified them a bit I've succeded in developing my project.

The question I would like to ask is why Tk is still supported and Wx is still unknown?

For more details about Wx go here
And if you want to see my project go here


Replies are listed 'Best First'.
Re: Wx vs. Tk
by jdtoronto (Prior) on Oct 17, 2003 at 14:32 UTC
    Wx is relatively new, Tk has been around a long time and is well supported and stable.

    The lack of layout design tools for Tk does make it somewhat harder to get a really good looking interface. I have just finished a new application using Perl/Tk. I used Tk for several reasons.

    • It has a richer collection of widgets at the moment
    • There is at least one good book out on Perl/Tk.
    • In Tk it is very easy to build mega-widgets of your own.
    • A mega-widget can be a complete re-usable interface in its own right.
    • Lots of folks here in the monastery are familiar with TK and can help.
    Now Wx is nice! I looked at it, and I will look at it again. I will also look at Prima - yet another GUI toolkit for Perl. As always in this wonderful Perl culture - TIMTOWTDI. And lastly, for some of us, Tk is what is available to us. In many sites where Iwork I am restricted to either CPAN on Linux or Activestate PPM's for Windows. There are no PPM packages for the Wx environment.

    jdtoronto

      There are no PPM packages for the Wx environment.
      I beg to differ ;)(if you go to the wxperl website you can download all the binaries you want)

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

        Indeed you are correct, my apologies. However it fails the automatic build test at ActiveState and therefore , as far as my two AS user clients are concerned it does not exist!

        jdtoronto

Re: Wx vs. Tk
by hardburn (Abbot) on Oct 17, 2003 at 14:09 UTC

    Tk is old, ugly, and primitive. It's also well-supported and easy to run on any system. Wx is newer, looks prettier, and (I'm guessing) nicer to program with. However, I had problems getting it to work on my development system.

    Not too long ago, I needed to make a GUI for a non-techie to import data from a local Access database and send it to our web server's database. Tk installed without a hitch, and Wx didn't. I didn't have time to mess with installing Wx, so I went with the "it works, use it" philosophy and did the project in Tk.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    :(){ :|:&};:

    Note: All code is untested, unless otherwise stated

Re: Wx vs. Tk
by batkins (Chaplain) on Oct 19, 2003 at 01:58 UTC
    Tk is actually a very well-designed module. It's got a number of advantages over other Perl toolkits, including the following:
    • Tk has no external dependencies (aside from Xlib on X11 systems; without Xlib, though, you won't have a very useful machine)
    • Tk is very mature. There are two O'Reilly books, one newsgroup, and lots of Perl users who'd be glad to help you overcome any difficulties you might have.
    • Tk is well-integrated into Perl. Other toolkits, like wxPerl and Gtk, are simple wrappers around other libraries. Tk is heavily based off Tcl/Tk, but its author, Nick Ing-Simmons, has added a lot of Perl-specific features to it. Instead of being a wrapper around Tcl/Tk, Perl/Tk is what its name suggests: a blending of Perl and Tcl/Tk.
    • Portability. ActiveState offers a PPM for Tk, and it works on pretty much any UNIX system, since it doesn't need GNOME or wx.
    I'm not too sure why you'd call the design confusing and ugly. I find it to be very scalable; it's equally simple to develop a barebones interface or to make an advanced widget with all kinds of bells and whistles. It requires a lot less code than Wx does, and is a little more Perlish for that. For instance, I can write and test a quick addition script in a matter of minutes with Tk:
    use Tk; $mw = MainWindow->new; $e1 = $mw->Entry->pack; $e2 = $mw->Entry->pack; $sum = $mw->Label->pack; $mw->Button(-text => 'Compute', -command => sub { $sum->configure(-text => ($e1->get() + $e2->get())); })->pack; MainLoop;
    In Wx, that would require all kind of infrastructure that isn't really necessary for such a simple script. Of course, There's More Than One Way to Do It, so that might be a good thing if that's the kind of stuff you're into.

    I can definitely see your point about the appearance of Tk, but it doesn't have to be that way. See my node about improving Tk's interface. Basically, try adding the following lines to the top of your app:
    $mw->optionAdd("*font", "-*-arial-normal-r-*-*-*-120-*-*-*-*-*-*"); $mw->optionAdd("*borderWidth", 1);
    Of course, replace $mw with whatever scalar you keep your MainWindow in. I think that the revised interface looks a lot better than the standard one.

    I was trying to resist, but I can't help but make a shameless plug here. Download milkbone from http://milkbone.org and take a look at the interface. It was created completely with Perl/Tk, but, IMHO, it looks as good as any other application.

    So I would suggest giving Tk another look. It's actually a very nice piece of software to work with.
    The computer can't tell you the emotional story. It can give you the exact mathematical design, but what's missing is the eyebrows. - Frank Zappa
      Wrt your mikbone, (I browsed the faq / documentation and I didn't find out of the box support), could you support 'proxy' connections through non-standard ports? (Eg, I'm behind a firewall at work, and I couldn't get it to work because of it... though I still want to try it out at some point... If I tried to use port 23 for communication with aol it should work...) Otherwise cool points in your message. I have yet to dig into Tk (or wx) myself because I'm either developing code for the console or writing a web app for what I need to do...
      Cheers.


      ----
      Zak
      undef$/;$mmm="J\nutsu\nutss\nuts\nutst\nuts A\nutsn\nutso\nutst\nutsh\ +nutse\nutsr\nuts P\nutse\nutsr\nutsl\nuts H\nutsa\nutsc\nutsk\nutse\n +utsr\nuts";open($DOH,"<",\$mmm);$_=$forbbiden=<$DOH>;s/\nuts//g;print +;
        It's funny you should mention that, because that's exactly what I was working on today. :)

        The next release ought to include proxy support.


        The computer can't tell you the emotional story. It can give you the exact mathematical design, but what's missing is the eyebrows. - Frank Zappa
Re: Wx vs. Tk
by menolly (Hermit) on Oct 17, 2003 at 20:03 UTC

    About 4.5-5 years ago, I started learning/using Perl/Tk. At the time, I found it much easier to use than any of the other GUI coding I'd done(1) -- which probably says more about the difficulty of those than about the ease of Tk. Since then, I've been doing web stuff and command-line stuff, and haven't explored the newer GUI development packages. I have heard good things about Wx over the past couple of years, though.

    (1) Some C++ Win32 stuff in college, before I dropped the course. Windows API directly, IIRC, not MFC. And some C++ stuff for my then-employer using a third-party library which gave us a consistent API across several *nixen and WinNT.

Re: Wx vs. Tk
by juo (Curate) on Oct 20, 2003 at 02:22 UTC
    I have been working already for many years with Tk and so far I have not found something that could achieve the things I have done with Tk. The only things that are not so user friendly about Tk is the placing of the objects using pack. You bassically have to think very carefully upfront where you want to have everything and joggle around with frames to place it at the location you want. (pack versus canvase versus grid). Also if you use it on a windows system it does not have that very windows native look.
      Just pasted your Tk example into some Perl I was writing, and it ran right away, right out of a Windows command window. Then I tried to add an Exit button. No sweat! It worked. I've never looked at Tk before so it MUST be easy, at least at this trivial level. So I'm convinced, and will learn more.

      BTW it looked "Windows" to me, but a bit dated; more Win 3.1 than XP. But I don't like the XP style anyway :-)
      - dww (whose preferred languages this year are VBA and Perl)
        Peanut Gallery Observation

        Tk works fine, I like it. But if you are on Windows, I find installing a Web Server like Xitami, then using the Flash Player (on Localhost without web browser), is a highly underated GUI for Perl.
Re: Wx vs. Tk
by zentara (Archbishop) on Oct 17, 2003 at 19:47 UTC
    I'm like hardburn.....I wanted to try Wx but it would never compile for me. Tk nevers gives me trouble.
      The truth is that when i installed Wx I modified some Makefiles in order to compile and to install it. The truth is that all of you who are defending Tk never realy tried Wx.
      Try it and you will see that it has more potential and power than Tk. It has a great html documentation, a lot of tutorials online and a lot of examples.
      I personaly think that Tk is now pretty old and in few years maibe it will become obsolete. So our duty, as perl programmers is to find better ways for creating graphical user interfaces in perl.

      --------------------------------------
      "Quoth The Raven Nevermore"
      SleepNot a.k.a TheCount
Re: Wx vs. Tk
by ctilmes (Vicar) on Oct 23, 2003 at 10:43 UTC
    TMTOWTDI. I've had good results with PerlQt. You can even use the QT Designer interactive GUI builder to prototype your dialogs, etc.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://299988]
Approved by Kanji
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-24 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found