Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

(GUI) Windows Programming FAQ

by Jouke (Curate)
on Aug 29, 2001 at 12:23 UTC ( [id://108708]=perlmeditation: print w/replies, xml ) Need Help??

There have been quite a few questions and remarks concerning building Windows-like programs in Perl. I don't know everything about all facets of this, but I hope this thread will be a kind of a FAQ-like thread to prevent some questions from being asked over and over again.

1. Can I build a GUI around my Perl program?
-> Yes you can. There are several different options:
a) Tk. Tk is the widest used GUI toolkit for Perl. O'Reilly has a book on it (although I heard it is discontinued), and a lot of resources on it are available. Tk is portable between Win32 and Unix variants.
b) Gtk. Gtk does not run on Win32. But for Gnome minded people it's a very nice GUI toolkit. It should be possible to port it to Win32 though. After all the Gimp is ported to Win32, and Gtk is based on the Gimp's widgetset.
c) Win32::GUI. Win32::GUI is (of course) only available on Win32. It's a toolkit to access all of Windows GUI api.
d) wxPerl. wxPerl is based on wxWidgets, a crossplatform GUI api. It really takes the look and feel of the platform it runs on, Win32, Motif, Gtk or MacOS.
e) Qt is available with Perl support now too. KDE support is planned but not yet available.

2. Aren't there more GUI toolkits?
-> Yes there are, but either old and (?) unmaintained, or very new:
X11::Fvwm Last update 1997!
X11::Lib Last update 1998!
X11::Protocol Last update 1998!
X11::Xforms4Perl Link does not work, but module can be found on CPAN (by-module)
Prima Very new. Has anyone tried it?

3. Where are the FAQ's on the toolkits?
-> Not every toolkit has a FAQ as far as I've found out:
a) Tk's FAQ is at (very outdated!)
b) Gtk's FAQ is nowhere to be found...
c) Win32::GUI's FAQ is at
d) wxPerl's FAQ is not yet written. There is however a wxPerl Wiki
e) perlQt's FAQ is at

4. What GUI api is the best?
-> That depends on your personal preferences. Tk is the oldest and normally the most stable GUI available for Perl. It's also the best documented. Gtk is good if you only want to run on Gnome platforms. Win32::GUI gives you access to all of window's GUI functions and wxPerl is the most portable and the most Object Oriented, for people who like that.

5. Are there any GUI builders available?
-> Yes there are. To name at least one for every toolkit I mentioned:
a) For Tk there is SpecPerl and Guido (alpha stage)
b) for Gtk there is Glade-Perl and PerlComposer
c) for Win32::GUI there is jplindstrom's The GUI Loft and GB
d) for wxPerl there is wxGlade, a GUI designer for wxPerl, wxPython and others. wxPerl support for wxGlade was added by PodMaster aka crazyinsomniac.
Then there's also the (non-free) wxDesigner
e) for perlQt there is Puic

6. Can I compile my Perl program?
-> Yes you can. However, except for perlcc (see below) none of the mentioned methods will really compile your code to machine code. The mentioned tools merely wrap up your code with the nessecary modules and the Perl interpreter and put them inside a standalone executable.
Therefore it's not suitable for hiding your sourcecode, but it's very useful when you want to distribute your script without having your end-users installing Perl and a bunch of CPAN modules
I think the best option for this these days is PAR. PAR is portable (runs on Win32 and (as far as I know) all Unix-like OSses), and using the 'pp' tool you can create standalone executables.
Then there's also:
Perl ships with perlcc which needs a C-compiler to actually do the final compilation, but it works most of the time for simple programs.
Then there is Perl2Exe which can do more than just build the 'exe' for a Win32 environment. It's available for many other platforms, including Linux, Solaris and AIX.
Also Activestate has its Perl Development Kit, which includes PerlApp. PerlApp can build binary executables for Win32 (though the compilation itself has to be done on an NT platform, not Win95/98), Linux and Solaris.

7. Can I create some nice distribution like a MSI or an Installshield wizard?
-> Activestate's Perl Development Kit includes PerlMSI. I haven't used it, but according to the description on the website it is possible to create MSI's easily with that.
Besides that there is InnoSetup a free, Open Source Installshield clone. It is *very* easy to use and allows you to build a nice installer around your program.

Another free tool (just like the previous one not related to Perl in any way) is NSIS, the NullSoft Scriptable Install System. As far as I've heard you can do even more with this than with InnoSetup, but I've never used it so far.

8. When I run my GUI script, a console window pops up and stays there until I close my program. How can I prevent this?
-> There are two options: either use wperl.exe instead of perl.exe (wperl.exe is distributed with ActiveState's Perl), or compile your code using one of the tools mentioned in answer 6 using the --gui option.

9. When I warn or die all messages go to the console window or aren't displayed at all. How can I see what warnings or errors my GUI script gives?
-> When you 'compiled' your script with PAR, PerlApp or Perl2Exe so it doesn't display a console window (the --gui option), warnings and errors aren't displayed anywhere. This is also the case when you use wperl.exe (distributed with ActiveState Perl) to run your script
However when you're using wxPerl, you can use Wx::Perl::Carp by PodMaster which captures your errors and warnings and displays them in a GUI dialog.
For Tk, there's Tk::Carp, and for Win32::GUI there's Win32::GUI::Carp (both by bbfu)

10. Do you have any useful outside links?
-> Here are a few. If you have any additions to these, please /msg me and I'll add them
Perl Tk homepage
Gtk Perl homepage
wxPerl homepage
Win32::GUI homepage
jmcnamara's dfm2gui
Writing GUI Applications in Perl/Tk ( article)
Gtk Perl Tutorial
first wxPerl tutorial on Updates:
  • fixed the link to InnoSetup (thx mirod!)
  • corrected the name of The GUI Loft (thx jplindstrom!)
  • (2001/09/03) Added info on Guido
  • (2001/09/03) Added info on PerlComposer
  • (2001/09/03) Added 6th question
  • (2001/09/04) Added 'Other GUI toolkits'
  • (2001/09/04) Reshuffled the questions
  • (2001/09/04) Added outside links
  • (2001/12/10) Added outside link to wxPerl tutorial
  • (2004/04/05) Added link to perlQt
  • (2004/04/05) Added link to wxGlade
  • (2004/04/05) Added info about PAR
  • (2004/04/05) Added question 8 and 9
  • {2004/05/11) Changed wxWindows to wxWidgets (new name)
  • (2004/07/27) Fixed the link for wxGlade

Jouke Visser, Perl 'Adept'
Using Perl to help the disabled: pVoice and pStory

Replies are listed 'Best First'.
Re: (GUI) Windows Programming FAQ
by patgas (Friar) on Aug 29, 2001 at 17:52 UTC

    Funny you should bring it up, I just started investigating wxPerl yesterday. I asked the CB for a GUI that supports a web browser-like control (like the IE-thingy for VB), and wxPerl was recommended. In fact, was it you, Jouke, that recommended it to me?

    Either way, I noticed you got the wxPerl developer to cough up those samples over on SourceForge, and for that I'm very grateful! (I was really stuck!)

    I was a little surprised at the lack of nodes here that had anything to do with wxPerl. So far it seems like a pretty friendly GUI setup, and there should be more coverage of it. I'll contribute my stuff once it's working...

    "We're experiencing some Godzilla-related turbulence..."

      Funny indeed, this must be the first time my wxPerl evangelizing really did its work, because it wasn't me for the first time :)

      Indeed I've been quite busy with wxPerl. In fact, I've written a first tutorial on wxPerl, which will most likely be published on soon. When it is, I will notify you.

      Jouke Visser, Perl 'Adept'
      Using Perl to help the disabled: pVoice and pStory
Re: (GUI) Windows Programming FAQ
by mrmick (Curate) on Aug 29, 2001 at 16:20 UTC
    This is very interesting, I haven't done too much GUI programming mostly because of the nature of the tools I build (non-interactive) and this gives me a lot of resurces to read.

    Especially the part about wxPerl. I never heard about it so I definitely have to check it out.

    Thanks for the info, Jouke. ++

Re: (GUI) Windows Programming FAQ
by demerphq (Chancellor) on Jul 03, 2003 at 06:14 UTC


    As I said in New(ish?) portable GUI framework for Perl prima is very impressive. Full featured GUI designer, portable event model. Way sexier looking widgets than Tk, primarily Perl based (relies on a portability layer in C but the widgets are implemented in Perl). Lots of prebuilt cool dialogs (the color wheel selector looks like its out Adobe, buts its actually from OS/2).

    Essentially the look and feel is cribbed from OS/2 but with lots of little features stolen from Windows and X11.

    Check it out!


    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
Re: (GUI) Windows Programming FAQ
by eserte (Deacon) on Apr 19, 2004 at 11:42 UTC
    Some notes:
    • X11::Fvwm is not really a GUI library, just a module to get access to fvwm-specific functions. It is not possible to build a GUI application with X11::Fvwm only.
    • X11::Protocol got a recent update, but given the simplicity of this module I would consider X11::Protocol to be rock stable for all times :-)
    • The Perl/Tk FAQ is still maintained and updated, though there's a lot of historical information in it which should really be removed.
Re: (GUI) Windows Programming FAQ
by Anonymous Monk on Apr 19, 2004 at 11:23 UTC
Gtk and Perl on Win32
by Anonymous Monk on Jun 08, 2004 at 00:21 UTC
    Gtk2 (the perl binding for gtk+ 2.x) works quite well on win32 as well as X11-supporting platforms (unix/linux/osx).
Re: (GUI) Windows Programming FAQ
by Rayman (Initiate) on Sep 30, 2004 at 19:04 UTC
    Hi, came across this page from Google today, this is very informative and addresses my needs exactly. Thanks! I built a simple document processing program and distributed with Perl2Exe but now thinking about doing a GUI front for it. Your site provided the info! Thanks again Ray
Re: (GUI) Windows Programming FAQ
by Anonymous Monk on Oct 03, 2005 at 20:31 UTC
    Much more up to date information on Win32::GUI can be found at
Re: (GUI) Windows Programming FAQ
by Anonymous Monk on Jun 10, 2012 at 02:58 UTC
    IUP - Cross-platform GUI toolkit for building graphical user interfaces
Re: (GUI) Windows Programming FAQ
by Anonymous Monk on May 04, 2012 at 21:02 UTC
    I run ActiveState's Perl Dev Kit (perlapp) on linux (RHEL5) to compile perl scripts to Window's exe's. It worked out of the box! It's intended for cross platform use and even downloads the target platform's ActivePerl on the fly to link it in. Seems to work ok, so far. It can produce either perl-dependent app's (requires perl be installed on the target machine) or standalone (no dependencies), and the latter means I do not have to ask end-users to deal with CPAN. The exe's are somewhat larger than I expected (3MB). It also requires ActivePerl to be installed on the build machine -- not the linux that comes with perl -- which was free and trivial to install. NOTE: although ActivePerl is free, the PDK costs US$300 or more for an educational license, so perl2exe is a better deal if you have the time to figure out how to run it. Also, ActiveState is a Canadian company and some US companies cannot deal with their legal terms and so do not allow AS software.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://108708]
Approved by root
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-07-16 04:04 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.