SyN/AcK has asked for the wisdom of the Perl Monks concerning the following question:

Hello Friends!

I'm looking to write my first GUI application with perl. I've read some, and researched some, and I'm still finding myself lacking a definitive answer for what I would like to do.

Here's the issue: I found this really cool thing called Glade, I'm sure some of you are familiar with it. It allows you to create GTK+ GUI code thru it. I also found this other cool tool, an IDE, called Anjuta. Its a graphical interface to Glade that reminds me of Visual Basic, allowing you to create C/C++ style GTK+ GUI code with drag and drop and click ease. Then, I found this IDE call Perl Developer, formerly called Visual Perl. Its just like Anjuta, except it creates Perl style GTK+ GUI code. The problem is, I'd love to use Perl Developer, but as far as I can see it was never completed and hasn't been worked on since 2000.

My question is does anyone know of an IDE similar to Perl Developer or Anjuta that can develop Perl GTK+ code? If not, could anyone point me to a good reference of using Glade2 to develop Perl style GTK code?

If not, this brings me to a new issue... I read alot about programming in Gnome/GTK+. It made it sound like Gnome was a wrapper that used GTK+ on a lower level, which would seem to make GUI development easier. Is it possible to develop Gnome/Perl code?

Finally, one more question, if I create a program using GTK+ or Gnome, would it even be usable in anything but Gnome?

Sorry guys and gals for making this so long... I'm just so inquisitive today!

Thanks for your help guys!!!!!

Replies are listed 'Best First'.
Re: Advice on writing GUI's in Perl
by traveler (Parson) on Oct 25, 2003 at 18:20 UTC
    Lots of questions! I have some answers, but first, you should know about the gtk-perl list. The gtkperl website is out of date. gtk-perl now supports Gtk+ 2 and there are bindings (announced today) for the development version. gtk-perl is at 1.0, IIRC. There is a whole directory of examples with the distro.

    You can use Glade and proably any tools that talk to glade (I have not tried the ones you mention) to generate code that works with gtk-perl. I understand the easiest way is to generate the XML with glade, then read that into your perl program. Again, I have not tried it, but there has been discussion on the list and you should check the archives at the link noted above.

    To answer some of your specific questions, Gtk+ exists on Linux and Windows. A Win32 version of the perl bindings should be out any time now. You do not need Gnome for Gtk+. You do need Gnome if you use Gnome features (i.e. you use Gnome widgets in your design).

    HTH, --traveler

Re: Advice on writing GUI's in Perl
by bakunin (Scribe) on Oct 25, 2003 at 22:05 UTC
    Hello! I've been doing some research on the internet about developing (very appealing ) GUIs with Perl, and I ran into PerlQT + QT Designer. Yes, you never mentioned anything about QT, rather, asked about its arch-enemy so to speak... But I couldn't resist, they seem to be doing quite a nice job. Just wanted to let you know.
Re: Advice on writing GUI's in Perl
by batkins (Chaplain) on Oct 26, 2003 at 01:31 UTC
    I don't know of any IDE's for Perl, and I'm not really sure you need one. If you opt to go with Perl/Tk instead of the Gtk+ Perl bindings, you design your interface programmatically. IMHO, this is a better approach. After a bit of practice, you can often code a serious interface faster than you could drag-and-drop it into existence - and more often than not, that interface would be a lot cleaner aesthetically.

    So I'd suggest looking into Perl/Tk and avoiding IDE's. Of course, that's just my own opinion, but if you decide to take my advice, then get Tk off CPAN, read its documentation, and get familiar with it. I highly recommend O'Reilly's Mastering Perl/Tk, butthere's at least one tutorial right here in the Monastery.

    Also, the first time you use Tk, you might be a bit disheartened by its appearance - I was. Look at this node for a quick but extremely effective way of cleaning up Tk's appearance.

    And if you don't belive me that Tk lets you make working UI's quickly, take a look at this sample:

    use Tk; $mw = MainWindow->new; # the next two lines fix the default Tk aesthetics $mw->optionAdd("*font", "-*-arial-normal-r-*-*-*-120-*-*-*-*-*-*"); $mw->optionAdd("*borderWidth", 1)_; $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;
    That code creates a simple form with two entry boxes, an area for results, and a button to add the two entered values together and put the result into the result area. You'd be hard-pressed to write that kind of thing with a click-and-drool IDE and get it working as quickly as you could write a script like the above. But, hey, TMTOWDI. :-)

    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

      Thank you for your reply, and I will take Tk into consideration. I just always thought the GUI's in Tk were a bit ugly. The reason for wanting to use GTK+ was because the newest GTK+ supports Gnome themes, i.e. the programs you write take on the look and feel of the theme currenlty applied.

      The thing I would really like to do is to create a GUI that is highly customized to the way that I wanted it to look. I suppose I should've mentioned that before. I do not know how possible this is in Tk as I've never used it. If its possible, I'd gladly use it.

      I really like the way some applications look when you buy them, even if sometimes a different look makes them a little harder to use. I hoped that with GTK+ and a Gnome theme, I might be able to make a GUI that looks very close to what I'd like it to.

      If any of you have any advice on how to do something like that, I'd appreciate it. I'll definitely take more of a look at Tk, and Qt as you guys mentioned, and I definitely want to thank you all for your posts, especially the one with the link to the gtk-list.

Re: Advice on writing GUI's in Perl
by zentara (Archbishop) on Oct 26, 2003 at 16:42 UTC
    I think you will find Tk-Perl will be the easiest to learn and you would find the most support for it. That is a big consideration. Gtk-Perl and Glade is a nice combination, but you will find it harder to find "howtos, books, and active forums" for it. Whereas with Tk, the newsgroup has experts answering newbie questions everyday. Also the MainLoop event-driven loop style of programming is quite similar in concept, and concepts you learn in Tk can be transferred easily to Gtk.

    P.S. I think the Gtk-perl interface is faster when running, if that is a consideration.

      P.S. I think the Gtk-perl interface is faster when running, if that is a consideration.

      And what's your basis for this?

      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

      Ah, thank you for that, speed is a consideration in this case. Not a huge one, but still a consideration. Like I said, it sounds like Tk would be ideal, but I really would like to make a very nice looking GUI, and the Tk ones always seem very plain and a little ugly.

Re: Advice on writing GUI's in Perl
by traveler (Parson) on Oct 26, 2003 at 17:36 UTC
    When it comes to developing interfaces, I found that for very simple ones Tk is probably easiest. For anything more, though, I found Gtk (without a GUI builder) pretty easy -- much more so than Tk. I have rewritten all but one Tk app I have using Gtk.


Re: Advice on writing GUI's in Perl
by gmpassos (Priest) on Oct 26, 2003 at 18:43 UTC
    See wxPerl, portable and powerful!

    Graciliano M. P.
    "Creativity is the expression of the liberty".

      Oh man! You see, that's why I love this place. Just when I think that I've exhausted my options and that I'm not totally happy with my solutions, someone comes and tells me about something I've never even heard of and it looks like exactly what I want!

      I want to thank everyone again for their advice, especially for how quickly the advice came. I've got a lot to think about now, but I think its boiling down to either gtk+ or this wxPerl thing. I may however, start off writing it in Tk as someone suggested, since I do need to get it done rather quickly.

      I would be most appreciative if anyone could point me to additional resources on programming in gtk+ and wxPerl. I really like this wxPerl since its cross platform! Thanks guys!

Re: Advice on writing GUI's in Perl
by zentara (Archbishop) on Oct 27, 2003 at 01:17 UTC
    To answer Batkin's request for proof of speed comparion: I have no "proof" that gtk is faster other than my subjective impression of it. It seems to have "crisper" widget updates, if that makes any sense. The gtk libraries are more powerful than what you get from Tk.

    As far as the gnome extension problem, you need to have the gnome libs installed if you use the gnome widgets. You don't need to run Gnome as your desktop, but it helps for full functionality of the gnome widgets. Otherwise just don't use the gnome widgets.

    My favorite gtk library is the gtk-image-viewer at gtk-image-viewer

    It allows mouse zooming and panning of images, try that with Tk (and the speed is smooth). Here is a little perl script to use it:

    #!/usr/bin/perl ###################################################################### + # Simple image viewing application with mouse zoom and pan. ###################################################################### + use Gtk; use Gtk::ImageViewer; init Gtk; init Gtk::Gdk::Rgb; init Gtk::Gdk::Pixbuf; init Gtk::ImageViewer; if(@ARGV<1){print "Usage: imageview file\n";exit} $window = Gtk::Widget->new("GtkWindow", -type => "-toplevel", -title => "Image viewer", -delete_event => sub { print exit Gtk; } ); $image = Gtk::Widget->new("GtkImageViewer", -parent => $window, ); $file = shift; $pb = new_from_file Gtk::Gdk::Pixbuf($file); $image->set_image($pb); $window->show_all(); main Gtk;