views:

1185

answers:

8

I need to develop a small-medium sized desktop GUI application, preferably with Python as a language of choice because of time constraints.

What GUI library choices do I have which allow me to redistribute my application standalone, assuming that the users don't have a working Python installation and obviously don't have the GUI libraries I'm using either?

Also, how would I go about packaging everything up in binaries of reasonable size for each target OS? (my main targets are Windows and Mac OS X)

Addition: I've been looking at WxPython, but I've found plenty of horror stories of packaging it with cx_freeze and getting 30mb+ binaries, and no real advice on how to actually do the packaging and how trust-worthy it is.

A: 

I've used py2Exe myself - it's really easy (at least for small apps).

Jon Cage
+4  A: 

http://wiki.wxpython.org/CreatingStandaloneExecutables

It shouldn't be that large unless you have managed to include the debug build of wx. I seem to rememebr about 4Mb for the python.dll and similair for wx.

Martin Beckett
+1  A: 

http://Gajim.org for Windows uses python and PyGtk. You can check, how they did it. Also, there's PyQt for GUI (and wxpython mentioned earlier).

Kasprzol
A: 

If you're open to other languages, consider Tcl/Tk. It has what is arguably the best deployment solution of any dynamic language. The short version is, you can use tclkit/starkit/starpack to wrap up an entire application -- code, images, sounds, dlls, .sos, etc into a single virtual filesystem of a very manageable size.

I wrote more about it here:

http://stackoverflow.com/questions/67185/best-tool-for-the-job-cross-platform-open-source-on-and-off-line-tool-developme#83386

Bryan Oakley
By Tcl/Tk, do you mean the Python tkinter module? This is a Python question, after all.
S.Lott
No, I meant Tcl/Tk. The original question said "preferably python" which to me means "I might consider other languages". If the question had said "I want a python solution" I wouldn't have mentioned tcl/tk.
Bryan Oakley
+2  A: 

Python has an embedded GUI toolkit named TKinter which is based on Tk library from TCL programming language. It is very basic and does not have all the functionality you expect in Windows Forms or GTK for example but if you must have platform independent toolkit I see no other choice taking in mind that you also dont want to grow that much the binary.

Tkinter is not hard at all to use since it doesnt have millions of widgets/controls and options and is the default toolkit included in most python distributions, at least on Windows, OSX and Linux.

GTK and QT are prettier and more powerful but they have a one big disadvantage for you: they are heavy and deppend upon third libraries, especially GTK which has a lot of dependencies that makes it a little hard to distribute it embeded in your software.

As for the binary creation I know there is py2exe which converts python code to win32 executable code (.exe's) but im not sure if there is something similar for OSX. Are you worried because people could see the source code or just so you can bundle all in a single package? If you just want to bundle everything you dont need to create a standalone executable, you could easily create an installer:

Creating distributable in python

That's a guide on how to distribute your software when it's done.

Gustavo Rubio
A: 

Combination that I am familiar with: wxPython, py2exe, upx

The key to resolving your last concern about the size of the distribution is using upx to compress the DLLs. It looks like they support MacOS executables. You will pay an initial decompression penalty when the DLLs are first loaded.

Jeremy Brown
+1  A: 

I don't have any experience building stand-alone apps for any platform other than Windows.

That said:

Tkinter: works fine with py2exe. Python Megawidgets (an "expansion library" for Tkinter) works fine also, but it does funky things with dynamic imports, so you need to combine all the components into a big file "pmw.py" and add it to your project (well, you'll also have pmwblt.py and pmwcolor.py). There are instructions for how to do this somewhere (either on py2exe wiki or in the PMW docs). Tix (an extension to Tk that you can use with Tkinter) doesn't work with py2exe, or at least that was my experience about four years ago.

wxPython also works fine with py2exe. I just checked an app I have; the whole distribution came to around 11MB. Most of that was the wx DLLs and .pyd files, but I can't see how you'd avoid that. If you are targetting Windows XP, you need to include a manifest in your setup.py or else it will look ugly. See this email for details.

John Fouhy