the thpinfo.com blogger archives (2007-2008)

PyGTK applications on Windows

Published: 2007-09-26T10:01:00.000+02:00
Tags: win32, porting, python, pygtk, gpodder

One advantage that you automatically gain when writing Python programs is that they are portable to several other mainstream operating systems (although there are some problems with specific extensions, etc..).

So, after releasing gPodder 0.10.0, which has now only one strict dependency on a pure Python module (feedparser), I wanted to try out if I could get gPodder running on Windows (I have tried it once before, but back then I was spawning a wget process to do the actual downloading, which was kind of awkward on the Windows platform).

What you need to get this working is Alberto Ruiz' All-in-one PyGTK Win32 installer and a check-out of the current SVN trunk head of gPodder. To check out a working copy from a Subversion repository on Win32, you can use TortoiseSVN.


I've found some divide-by-zero errors that I didn't see happening on Linux, so I could quickly fix them in our Subversion repository. I also got rid of some old symlinking code that I didn't use anymore, because symlinks on Windows isn't really possible (except for Vista maybe). Other than that, there were just some minor problems with my code being Unix/X11-specific, for example I'm checking for the $DISPLAY variable in the main script, which isn't needed on Win32.

There were other minor annoyances which I haven't dealt with yet, but which don't interfere with the basic functionality of gPodder:

  • Running .mp3 or .avi files with the preferred media player (how do I do that on Win32?)
  • Getting a GTK Icon Theme into my GTK installation, so all icons in gPodder display properly
  • Removing the GUI for iPod synchronization (or get libgpod + Python bindings working on Win32)
  • Testing, testing testing :)
I wonder if it's possible to use Py2exe to create a nice, self-contained Win32 package of gPodder that has Python2.5, the GTK runtime, PyGTK and python-feedparser integrated and works without installing anything.


Comments

Morrighu Tel Uvrith (2007-10-28T17:16:00.000+01:00)
Hi,

We’re an open source gaming engine project that’s looking for python devs. If you or anyone you know is interested, please visit us at www.projectangela.org.

TIA,

M.

Guillaume (2007-09-27T04:33:00.000+02:00)
Hello,

I have been making stand-alone exes with pygtk for a couple of years. It is not complicated. All you have to do really is copy the whole \bin \lib \share directories into your project folder and to have a line in your python script before the import gtk that does
import os
os.environ["PATH"].append("GTKLIBS")

to point to the correct path.

bimone (2007-09-26T17:37:00.000+02:00)
I did a python podcast retriever, orm, which is on berlios. I haven't touched it for a while, but there might be some stuff to use from it ... there was a start of a curses gui :)

Ali (2007-09-26T13:38:00.000+02:00)
Hi. I am really glad to see PyGTK applications on Windows. I use them a lot, and usually without problem.

About the question of using py2exe to make executable environments, I blogged this at:

http://unpythonic.blogspot.com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html

Tim Golden (2007-09-26T11:48:00.000+02:00)
To answer your question: "How do I get an .mp3 or .avi to start with the associated app?", the most straightforward answer is: use os.startfile (or its under-the-covers equivalent ShellExecute).

If you want a little more control, you can determine which app. that would use by using the FindExecutable API:

http://timgolden.me.uk/python/win32_how_do_i/tell-if-a-file-is-executable.html

I *believe* (tho' I haven't used it) that the desktop module:

http://pypi.python.org/pypi/desktop

covers this kind of thing x-platform.

TJG


Thomas Perl (m at thp io); jabber: thp@jabber.org