mmccoo
mmccoo

Reputation: 8536

What are good interactive GUI builder packages for Perl?

I'd like to write some interactive GUIs in Perl. I've used TclTk but it looks dated. I've written QT code for C++, but the PerlTk module hasn't had a release in several years. Googling around I see other possible options.

What are good packages for this, including basic windowing, menus, drawing canvas, scrollbars, and so on.

Upvotes: 11

Views: 9710

Answers (11)

MkV
MkV

Reputation: 3096

Echoing Chas Owens, glade is quite usable with Gtk2 in Perl. In addition, Gtk2 also supports GtkBuilder files (which you can create the latest glade too).

The main problem with wxPerl (and wxWidgets itself) is that it doesn't let you install file event watchers into its main loop (it only has GUI, Socket and Timer events), unlike Tk and Gtk.

The Qt, Tk and Gtk2 event loops can be used in Perl with AnyEvent, and Gtk2 can be hooked into applications running the Event or Ev mainloop with Glib::Event and Glib::EV modules.

Upvotes: 6

krishnaswami kaushik
krishnaswami kaushik

Reputation: 139

Regarding quality of widgets, all three gtk2, wx and qt4 are equally good -- gtk2 is fastest, qt4 has best resolution, whereas wx is somewhere between the two in terms of both the parameters.

But tk is behind all the three both in terms of speed and resolution, but remains firstly because it is the original widget for all unix based interpreted languages, and secondly because it is native-widget of freebsd.

As on today in case of perl, documentation of perl-gtk2 is slightly more developed than both perl-qt4 which is in turn is more developed than wxperl. In fact, if you browse the web, you will find that tutorials for perl-gtk2 is more extensively available than even pygtk (which is also very well established) and ruby-gtk2. In case of python, wxpython documentation leads over PyQt and pygtk, whereas in case of ruby, ruby-qt4 leads over ruby-gtk2 and wxruby. However, others are developing very fast (e.g. ruby-gtk2) and after some time all nine will be equal in all aspects.

The perl-qt4 specific problem is: In case of non-kde desktops, perl-qt4 may not run. I tried running all in ubuntu and sabayon and found that perl-gtk2 and even wxperl (and wxruby also) runs fine whereas I'm not able to run even a single perl-qt4 programs in gnome-desktop where I have installed complete qt4 support without kde.

perl-qt4 asks for installation of not just qt4-libraries, but also kde-desktop libraries. This problem is uniquely perl-qt4-specific, does not exist in case of PyQt and rubyqt4 since they both run fine with qt4 runtime under gnome.

Hence, in this way eight (plus three tk) out of nine options did well (I havent tested PySide yet).

In case of perl-tk, widget is well developed and established and unlike tkinter, pmw and rubytk, its documentation is the best among all of these mentioned above.

But maybe after some time all the documentations become developed and any would become equally good.

After taking a balance between speed, clarity and cross-platform into consideration choose either perl-gtk2, or perl-qt4 or wxperl.

perl-tk, perl-gtk2 and perl-qt4 syntaxes nicely go well with perl programming language syntax, whereas wxperl syntax look more like proper c++ blended into perl which is different from the respective language syntax (just like in case of wxpython and wxruby).

But if you are already keeping in mind that wx code is uniquely different then you can straightaway begin with wxperl.

Otherwise, best way out is: begin with perl-tk, then switch over to perl-gtk2 then perl-qt4 or wxperl alike but make sure that you learn all four instead of only one (the same sequence should also apply to python and ruby too despite the fact that documentation support is reverse, but in case of perl even for this aspect it is same).

Upvotes: 2

Joel Berger
Joel Berger

Reputation: 20280

Recently I was made aware of another GUI toolkit for Perl called Prima. Its claim to fame is that it was written in C especially for Perl, not a port from TCL or bindings to something else. Assuming you have some rather standard libraries on your system, it will install directly from CPAN and its cross-platform!

David Mertens has been writing a new plotting library for PDL using it, and a REPL too!

Upvotes: 3

Joel Berger
Joel Berger

Reputation: 20280

I have used Tk, but in the last few days I have been playing around with Continuity (CPAN entry), a stateful (persistent state per user) web application/server, and it could easily be a way to add "GUI" features into an application, while making it multi-user and portable at the same time.

Edit: At the time I wrote this, I was most interested in the fact that Continuity had its own built-in webserver. This is now true of other webframeworks for Perl as well. I have been using Mojolicious though I hear good things about Dancer too.

Upvotes: 0

LinuxGuru
LinuxGuru

Reputation:

I just want to let everyone know PerlQt is great and this site has a lot of tutorials on how to use it and lots of examples to download.

PerlQt Wiki tutorial

PerlQt is a very fast and easy way to create great looking GUI programs using the Qt drag and drop form designer and Perl. PerlQt is powerful enough for advanced developers and easy for beginners as well.

Upvotes: 1

Chas. Owens
Chas. Owens

Reputation: 64929

Gtk2 has glade2 which can write out an XML file usable by Gtk2::GladeXML. Here is an example of how to bundle the XML with the app in the same file.

I misread the question at first. I thought you wanted a GUI editor for making GUIs (which is what glade2 is). You can also create GUIs using Gtk2 without glade2:

#!/usr/bin/perl

use strict;
use warnings;
use Gtk2;

Gtk2->init;

my $window = Gtk2::Window->new;
my $vbox   = Gtk2::VBox->new;
my $label  = Gtk2::Label->new("Hello World");
my $button = Gtk2::Button->new("Press me");

$window->add($vbox);
$vbox->add($label);
$vbox->add($button);

$window->set_default_size(200, 200);
$window->signal_connect(
    destroy => sub {
        Gtk2->main_quit;
    }
);

my $i = 0;
$button->signal_connect(
    clicked => sub {
        $label->set_text("button pressed " . ++$i . " times");
    }
);

$window->show_all;

Gtk2->main;

Upvotes: 13

mmccoo
mmccoo

Reputation: 8536

The solution I'm going with is Gtk-Perl. At first I had difficulty installing it, but in the end I found Camelbox Perl+Gtk2 in one package.

Upvotes: 0

brian d foy
brian d foy

Reputation: 132832

I don't have a real answer for you, but often you have to consider your deployment targets. Some of the GUI libraries are very nice, but only if you can get them to work on your operating system. I don't necessarily think that all frameworks need to be cross-platform compatible, a very laudable goal to work toward in a perfect world, as long as the one you choose doesn't lock out a significant portion of your users because the foundation GUIs libraries are hard to install or support on a particular platform.

Upvotes: 1

jrockway
jrockway

Reputation: 42674

I would probably use Gtk2, but Tk is definitely not dead. The lack of releases is due to the bugs being ironed out over the years. A lot of people still use it, and it generally works fine. (Tk's event loop is somewhat silly, but that is a detail that probably shouldn't concern you.) The only disadvantage is that your GUI looks like it is from 1996, but who cares?

(The gitk tool included with git showed that Tk GUIs look fine as long as they're useful.)

Upvotes: 4

MaxVT
MaxVT

Reputation: 13234

A GUI builder for WxPerl would be wxGlade or wxFormBuilder, both open-source.

Upvotes: 4

Frank
Frank

Reputation: 66194

Try wxPerl!

From the web site:

wxPerl is an extension module allowing the creation of GUI (Graphical User Interface) from Perl; it is built as a wrapper for the awesome wxWidgets C++ GUI toolkit.

Upvotes: 11

Related Questions