Developing and Distributing wxPerl Applications on Windows: Difference between revisions

From Perl Guilds - Getting Medieval with Perl
Jump to navigation Jump to search
 
Line 140: Line 140:
* Github repo - https://github.com/wxGlade/wxGlade
* Github repo - https://github.com/wxGlade/wxGlade
* email list - https://sourceforge.net/p/wxglade/mailman/wxglade-general/
* email list - https://sourceforge.net/p/wxglade/mailman/wxglade-general/
* See [GUI ideas for use with wxGlade] if you don't know where to start!
* See [[GUI ideas for use with wxGlade]] if you don't know where to start!


== Development Workflow Notes ==
== Development Workflow Notes ==

Latest revision as of 03:16, 5 July 2026

Introduction

[edit | edit source]

This article is part of the Perl Lazarus Project, an effort to make Windows GUI development in Perl practical again by identifying a working toolchain for creating, packaging, and distributing desktop applications.

The name is a nod both to Lazarus of the Bible and to the excellent Lazarus IDE for Free Pascal. Perl does not currently have a direct equivalent to that kind of unified rapid application development environment, so this project focuses on documenting a practical path using the tools that are available today.

This page is about installing wxPerl under Strawberry Perl for application development and distribution as a Windows executable.

Why Perl GUIs, why Windows?

[edit | edit source]

This is a critical ability for any freelance Perl developer, since it complements a Perl journeyman's ability to do many things on servers, such as create remote services. Being able to transfer these skills to the desktop environment is especially useful on Windows, where users are accustomed to paying for software. In short, Perl programmers who want to make a living on their own need to know how to create and distribute Windows GUI applications; this page covers a large piece of how to do that.

wxPerl GUI running on Windows as a double-clickable EXE file!
wxPerl GUI running on Windows as a double-clickable EXE file! Created using wxGlade, a RAD-ish tool. See more images on Github.

Instructions are provided with the versions detailed below. If there are newer versions of any of the modules, you may try them out (of course); but understand they have not been tried and shown to work like the version combinations below.

See the original call for a wxPerl Revival!

[edit | edit source]

Git Repository of wxGlade / wxPerl Examples

[edit | edit source]

https://github.com/The-Perl-Cottage-Guild/wxPerl-Templates

Installing wxPerl on Windows for Development

[edit | edit source]

These instructions are for you, not your customers! Give them a clickable installer like Windows users expect (see how here!)

General Steps

[edit | edit source]
Step Component Link Notes
1 Strawberry Perl releases Install Strawberry Perl first. For the newer PDL-based build, use the PDL ZIP edition rather than the standard MSI.
2 Alien::wxWidgets github Install after Strawberry Perl and wxWidgets are available.
3 Wx / wxPerl github Install last; this is the Perl binding used by wxPerl applications.
[edit | edit source]
Status Strawberry Perl wxWidgets Alien::wxWidgets Wx / wxPerl Detailed Instructions / Links Notes
Latest / Experimental PDL Build 5.42.2.1 64-bit UCRT, PDL ZIP edition 3.2.9 0.73 3.009 Wx 3.009, Alien::wxWidgets 0.73, Strawberry Perl 5.42.2.1 PDL Newer PDL-based build path. The PDL ZIP conventionally unpacks under C:\sw\pdl. Add C:\sw\pdl\c\bin, C:\sw\pdl\perl\site\bin, and C:\sw\pdl\perl\bin to the active PATH. This combination should be treated as experimental until the full build and packaging workflow is verified.
Upstream PowerShell Helper Script 5.42.0.1 64-bit portable, by default 3.2.9 0.73 3.009 wxPerl-Windows.ps1 Read the script carefully before running it. As written, it installs portable Strawberry Perl, builds wxWidgets from source, manually installs Alien::wxWidgets configuration, then builds Wx. It does not use the PDL ZIP by default, so the script needs adjustment for the C:\sw\pdl PDL layout. It is best treated as an upstream build recipe or advanced helper, not as the primary beginner installation path.
Previously Tested 5.40.2.1 64-bit UCRT MSI See detailed instructions page 0.71 3.008 Wx 3.008, Alien::wxWidgets 0.71, Strawberry Perl 5.40.2.1 Previously documented working combination. This is the safer reference path until the newer PDL build is fully verified.
Archive 5.40.0.1 64-bit UCRT MSI See detailed instructions page 0.70 3.005 Wx 3.005, Alien::wxWidgets 0.70, Strawberry Perl 5.40.0.1 Earlier archived working combination. Keep this entry for historical reference and troubleshooting regressions.

Verify Installation

[edit | edit source]

The information provided in this section ought to be unrelated to the verified version combination outlined in the Installation section above.

Install Wx::Demo

[edit | edit source]

Wx::Demo is nice demonstration application, highlight many (if not all) of the wxWidget features available via xPerl.

C:\> cpanm --verbose Wx::Demo

.. then once installed, run it with this command (which is available in the PATH already),

C:\> wxperl_demo.pl

wxGlade - a Perl Friendly Cross-Platform GUI Builder

[edit | edit source]

Trigger Warning: wxGlade is written in wxPython, so you must install it if you want to use wxGlade to build your GUI.

[edit | edit source]

Totally worth it!

Install wxGlade

[edit | edit source]

wxGlade is a GUI builder for wxWidgets applications. It is written in Python, but critically supports outputting Perl code. It is actively developed, and the developer is very responsive on Github to bugs and feature requests. It is the closest thing we have in Perl to a rapid application development environment, in the spirit of Lazarus for Free Pascal.

Developers interested in earlier wxWidgets GUI builders and older Perl-capable tools can also see the longer list of RAD tools and GUI builders near the end of this page, including some useful but discontinued, archived, or historically important projects.

Step 1 - Install Python 3.10.11 for Windows

[edit | edit source]

Install via following link,

https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe (linked here)

Notes:

  1. Last tested on 25 Jan 2025, although later versions of Python 3 were tested (specifically, 3.12.8), wxPython would install but not run wxGlade properly
  2. install as admin (checkbox should be already checked; also opt'd to add "python" to the PATH)

Step 2 - Install wxPython

[edit | edit source]
  1. open up the Windows CMD window
  2. use pip,

C:\> pip install wxPython

Note: if this fails, you may need to reinstall pip; but it should be available in the CMD window. Based on experience, pip doesn't seem to be available via the Strawberry Perl terminal, so be sure to get a standard Windows CMD window to do this part.

Step 3 - Download and unzip wxGlade

[edit | edit source]

You should probably check if there is a new release, but to get the latest at the time of this update, download: https://github.com/wxGlade/wxGlade/archive/refs/tags/v1.1.1.zip (may want to also try wxGlade-1.1.0_win_amd64.zip - the difference between the two is unclear, but both are tested and both work.)

wxGlade running on Windows, showing the design window of a GUI about to be run using wxPerl!
wxGlade running on Windows, showing the design window of a GUI about to be run using wxPerl!

Via Windows CMD terminal, navigate to the unzipped directory and run the command,

C:\> python wxglade.py

Getting wxGlade Help

[edit | edit source]

wxGlade's developer is responsive on Github and there is a semi-active email list on SourceForge,

Development Workflow Notes

[edit | edit source]

This section outlines some different workflows that are found among members of the community who use wxPerl. Like any workflow, the based on level of experience and particular application.

Example layout with Strawberry Perl for running the application and Makefile, vim under MSYS2 for more streamlined workflow. wxGlade is under there, too; when there is a change to the GUI, the project is saved and code generated using "ctrl-g". vim is used to edit the code and will update whenever wxGlade updates it, if you do it right your custom code won't get clobbered.
Example layout with Strawberry Perl for running the application and Makefile, vim under MSYS2 for more streamlined workflow. wxGlade is under there, too; when there is a change to the GUI, the project is saved and code generated using "ctrl-g". vim is used to edit the code and will update whenever wxGlade updates it, if you do it right your custom code won't get clobbered.

Editor and git Options on Windows

[edit | edit source]

The best way to recreate the "edit-run-fix" workflow of code editing enjoyed by vim users is to install MSYS2 and use its terminal to install both vim and git:

pacman -S vim git

Note: you do not want to run the Perl code generated by wxGlade inside of the MSYS2 terminal. When you install git, it will install its own perl and clobber Strawberry Perl in your PATH. Run the Perl code for your project from a Strawberry Perl terminal.

Just like the editor options in Windows is not ideal, neither are the Git options (GH's "Git for Windows" is exceptionally awkward to use, not sure how to it is possible to be good in "Windows" tbh; YMMV.) Under MSYS2's terminal, you may install git and use it as you may be accustomed on Linux. You may want to generate an ssh-key, which will be vailable in `~/.ssh/` by default. So you can do all the normal git workflow stuff from there once your key is created and added to your Github keyset.

Pro Tip: Turn Off MSYS2's vim Mouse Support and Auto/Smart Indenting

[edit | edit source]

I have found that this is required to "copy" text from the MSYS2 vim, you may not need it. But by default vim is aware of the mouse.

To turn all that off, put the following lines in your ~/.vimrc file:

set mouse=
set noautoindent
set nosmartindent
set nocindent

Using wxGlade's "Single file" + "Keep user code" Options

[edit | edit source]

wxGlade has some settings that tells it to not overwrite changes you made in the output Perl script, but beware - this option is not on by default. That means that means that your file will get overwritten if you tell wxGlade to generate new code again. The general workflow is as follows:

  1. start a new project (or open an existing one)
  2. click on the root "Application" object in the object viewer
  3. find the output pane, set the output to be "Perl"
  4. set version of wxWidgets to be "3.0"
  5. Recommended settings for using wxGlade for Perl development.
    Recommended settings for using wxGlade for Perl development.
    check "Keep user code", this will make sure wxGlade doesn't overwrite code that is outside the bounds of very clearly marked blocks in the code

Using wxGlade's "Separate file for each class" Option

[edit | edit source]

... to do

Creating Windows EXEs

[edit | edit source]

This section is more of a work in progress since a reliable method of distributing single file executables (or developing installation packages for Windows) is still an open question, there is hope that this will end up being a relatively smooth process. Needless to say, it is critical for Perl developer to be able to distribute Perl based GUI applications as single file (.exe) or via installation on Windows. The client should NOT need to be running through any of the instructions above to run a program that you would like to sell them for actual money.

Below are the initial instructions for generating an EXE file. There are also many ways that wxPerl developers go about doing, based on their use case and experience.

PAR::Package, App::PP::Autolink, and Wx::Perl::Packager

[edit | edit source]

Step 1 - Install PAR::Package, App::PP::Autolink, and Wx::Perl::Packager

[edit | edit source]

C:\> cpanm --verbose PAR::Package App::PP::Autolink Wx::Perl::Packager

Note: pp_autolink, provided by App::PP::Autolink, has proven to be absolutely critical to finding the required DLLs that need to be added manually to the wxpar command below via the --link flag.

Step 2 - Generate the EXE

[edit | edit source]

Assuming you have a Perl script generated either via wxGlade (see above) or one you have created/updated by hand, the command is as follows:

C:\> wxpar YOURPROGRAM.pl -o YOURPROGRAM.exe

Important Notes About wxGlade Generated Code
[edit | edit source]
  1. Earlier versions of wxGlade introduced an improper idiom at the bottom of the generated Perl script that caused a problem when running via a PAR::Packed executable. TLDR: remove the "unless(caller)" block and just run the Wx event loop unfettered. For more information, please read the PAR::FAQ.
  2. Earlier versions of wxGlade also used a non-Exporter import tag that wxpar could not properly follow; see the code "before" and "after" below:
use Wx qw[:allclasses];
use strict;

...

package main;

unless(caller){
    my $local = Wx::Locale->new("English", "en", "en"); # replace with ??
    $local->AddCatalog("app"); # replace with the appropriate catalog name

    my $app = MyApp->new();
    $app->MainLoop();
}

Should be modified to look like the following:

use Wx;
use strict;

...

package main;

my $local = Wx::Locale->new("English", "en", "en"); # replace with ??
$local->AddCatalog("app"); # replace with the appropriate catalog name

my $app = MyApp->new();
$app->MainLoop();

See this Github issue for wxGlade, where both were fixed. At the time of this writing, the changes have not been put out in an official release; but they are applied in the master branch.

Special Cases

[edit | edit source]
Makefile for an Application uses HTTP::Tiny and calls out to SSL-enabled sites
[edit | edit source]

Example - https://github.com/StormSurgeLive/nhc-advisory-gui/

(copied from the Makefile) - Note, mentions using App::PP::Autolink to suss out required DLLs (provides pp_autolink, which helped!)

all:
        wxpar --verbose -o ./dist/nhc-explorer.exe -l c:/strawberry/c/bin/libcrypto-3-x64__.dll -l c:/strawberry/c/bin/zlib1__.dll -l c:/strawberry/c/bin/libssl-3-x64__.dll ./asgs-storm-bug.pl --gui
        wxpar --verbose -o ./dist/DEBUG-nhc-explorer.exe -l c:/strawberry/c/bin/libcrypto-3-x64__.dll -l c:/strawberry/c/bin/zlib1__.dll -l c:/strawberry/c/bin/libssl-3-x64__.dll ./asgs-storm-bug.pl

# It was an adventure finding all the dependencies related to the wxpar command,
# particularly those around what was needed. The basic process entailed:
# 1. use wxpar, which generates an options file with all the Wx DLLs
# 2. install App::PP::Autolink, which provides the utility "pp_autolink"; this
#    utility scans the .pl file you're packing, in this case, "asgs-storm-bug.pl",
#    for DLLs - lo' and behold, it found the ones I needed; in particular the critical
#    one that was not getting picked up by pp or wxpar, "libcrypto-3-x64___.dll!"
# 3. run the "wxpar" command above
# 4. test in a non-Strawberry Perl window, such as the MSYS2 terminal, using the command:
#
#      PERL_DL_DEBUG=5 dist/nhc-explorer.exe
#
#    I learned about this command while searching, here:
#
#      https://stackoverflow.com/questions/423330/why-cant-dynaloader-pm-load-ssleay-dll-for-netssleay-and-cryptssleay

Important Note About Finding all DLLs

[edit | edit source]

It is worth repeating that pp_autolink, provided by App::PP::Autolink has proven to be absolutely critical to finding the required DLLs that need to be added manually to the wxpar command below via the --link flag.

If you are having problems finding all the DLLs (some which may not be obvious until the EXE generated is tried on a different machine,) you need to give pp_autolink a shot.

Martha - A lightweight wxPerl helper for packaging Perl applications on Windows

[edit | edit source]

In February 2026, an exciting new project was launched to help Perl programmers bootstrap creating Windows executables and program installers. Martha, formerly referred to here as wxPerl Helper, is designed to work within the development environment described herein (Strawberry Perl, Alien::wxWidgets, wxPerl, wxGlade). Given this environment, the current "beta" version of the software can assist with the following:

  • automatically finds required DLLs
  • generates Makefile, based on using wxpar (a pp wrapper)
  • user can tweak and save the Makefile
  • user can load an existing Makefile
  • user can run the Makefile to create the executable
  • user can run the executable
  • user can configure an Inno Setup provided it is installed
  • run the Inno Setup file to generate an installer for their program
  • finally, they may test the installer directly from the GUI

Martha is targeting the gap that exists for a user that is able to generate Perl code from wxGlade, but then is unsure how to actually distribute their application in the way Windows users expect.

For more information and updates on the project, visit the Github repo here.

Background: Perl, wxWidgets, and RAD on Windows

[edit | edit source]

For historical context on earlier Perl/wxWidgets GUI builders, RAD tools, and discontinued Windows application-building efforts, see Perl and wxWidgets RAD on Windows.

Creating Installers for Windows EXEs

[edit | edit source]

Professional Windows programs are expected to provide installers. This section will be developed as I figure out how to do this. A few notes:

  • Strawberry Perl itself uses WiX Toolset (Windows Installer XML Toolset) to generate its MSI installer (see here)
  • NSIS (Nullsoft Scriptable Install System) is another option - (tutorials, examples, screenshots) - it also has its own IDE for visually designing installers! See more here.
  • A possible "old school" approach, may be to use Office'97 Office Developer Edition (ODE) - via Access'97 there is an installer builder - this is a last resort and still needs to be verified to work for non-Access distributions
  • Inno Setup (github) - Inno Setup is a free installer for Windows programs by Jordan Russell and Martijn Laan. First introduced in 1997, Inno Setup today rivals and even surpasses many commercial installers in feature set and stability.
  • InstallShield (commercial - software monetization services)

Using Inno Setup

[edit | edit source]

This section briefly describes using Inno Setup to build an installed for a Windows executable. It seems to be pretty easy to use and has support for many more things than most Perl programmers may actually need. One important thing to note is that it is free for non-commercial use, there is a commercial license required by the author for using this to distribute commercial programs. The license is one-time and entitles the end-user to 2 years of updates. After that, they may continue to use it but will not receive the updates. For all intents and purposes it is a one-time fee, and may considered worth it for some software authors.

Using Inno Setup consists of creating a configuration file, then using the Inno Setup Compiler's GUI to open up an ".iss" file, then run it interactively. It may also be run on the command line or as part of a Makefile.

Click here to see an example configuration file used by the NHC Advisory GUI.

Support for creating configurations and installers with Inno Setup is also being included in Martha, the wxPerl helper application being created as part of this Perl Guilds effort to make it easier for traditional Perl programmers to break into the world of commercial Windows GUI programs.

Underdeveloped Sections

[edit | edit source]

The following sections are "works in progress," and remain open questions (for this author anyway). Contributions to develop these sections are greatly appreciated, but not expected. Over time I will update these sections as I learn more about using wxGlade and Perl on Windows.

Distributing EXEs to other Windows Machines

[edit | edit source]

While wxpar does indeed create EXEs that can run on Windows machines that do not otherwise have any required libraries on them, I have found some early problems that are most likely due to lack of experience in this area. An understanding of this area is forthcoming.

Maintaining Perl Applications using XRC

[edit | edit source]

XRC is a language agnostic and XML based way of describing the GUI layout for wxWidgets. It appears to be the right way to maintain the GUI layout of your production grade program, while maintaining the set of Perl handlers in your own source tree. Think of XRC as the separation of the controller and view in MVC - it to GUI programming what templates are to web application programming. It seems that as one advances his skills in this area, he will want to use XRC. The benefit also of this is that one may be able to create controllers in multiple languages rather than tie the GUI construction in Perl or some other language exclusive - of course, wxGlade can output in different languages, but none is as abstract as XRC.

Wx::Demo example of loading an XRC file; wxGlade can output directly to XRC, which can then be read in Perl. This is how.
Wx::Demo example of loading an XRC file; wxGlade can output directly to XRC, which can then be read in Perl. This is how.

Wx::Demo has a few good examples of running XRC applications; wxGlade can output XRC, but it is not aware of any language bindings or drivers for it.

Experience with managing XRC files may allow us as Perl programmers to use RAD tools and GUI builders that were not intended to support wxPerl, but can output XRC files. DialogBlocks is such a professional and commercial GUI builder for wxWidgets, and it is actively maintained.

Frequently Asked Questions

[edit | edit source]

Nobody actually contacts me to ask these questions, but they seem to be important.

Q: Can these wxPerl applications using Strawberry Perl make https requests?

[edit | edit source]

A: Yes! Strawberry Perl comes with HTTP::Tiny (a core Perl module) and Net::SSLeay (used by HTTP::Tiny for https requests).

Additional Resources

[edit | edit source]

Printed Books

[edit | edit source]
This great, but out of print wxWidgets book is available for free (PDF) at https://wxwidgets.org/docs/book/. It mentions wxPerl and has an index of tools and programs that any wxWidgets programmer may find interest.
This great, but out of print wxWidgets book is available for free (PDF) at https://wxwidgets.org/docs/book/. It mentions wxPerl and has an index of tools and programs that any wxWidgets programmer may find interest.

Cross-Platform GUI Programming with wxWidgets (free PDF!!) by Julian Smart and Kevin Hock (with Stefan Csomor) is an old, but nice resource to have. It mentions wxPerl quite a bit and has a nice index of tools to help the wxWidgets GUI programmer, regardless of the language they are using. In particular, "Appendix E: Third-Party Tools for wxWidgets" is a very interesting read.

Longer List of RAD Tools and GUI Builders*

[edit | edit source]
  • wxGlade (Latest at this time, Version 1.1.0, July 7, 2024)
  • wxDesigner (Latest at this time, 2.14 - wxWidgets 2.8.8/ 2.20a - wxWidgets pre-3.0, May 2009)
    • outputs Perl code
    • archived but a trial is downloadable here (archive.org)
    • Reliable contact for license: undetermined at this time
  • DialogBlocks - (Latest at this time, Version 5.18, August 21st, 2024)
    • can export C++, XRC, which wxGlade should be able to import
    • No Perl export (see XRC)
    • Cross Platform (Windows, Mac, Linux)
    • Registration required, but support is discontinued - email support@anthemion.co.uk, they may just give you a free key if you are nice :-)

*You may want to also check this duplicated internal page.