Saturday, May 31, 2008

PyGTK and Glade on Windows

It's been told that the PyGTK & Glade is a cross-platform developing combo. And there's a good reason to believe that most folks started it from Linux as I did. Well, now it is time to deliver the combo's platform-crossing feature: let's march on to MS Windows. I tested this on Windows XP and so far everything seemed fine. To set up the developing environment, several packages are needed. I list their names as well as downloading links below. Assuming you haven't installed any of them before, I would suggest that you download them all (don't install yet). Even if you have, the version might not be guaranteed to work with other components. I also need to mention py2exe here. It is not essential for the application development. What it does is "compiling" your script into a executable and collecting other related files required by the script together, so that it will be able to run independently on those windows systems where the packages don't exist. Since you can't expect your users to have installed every packages, it indeed roles significantly in this game. The order of the installation does matter here. First you need to install Gtk+ 2.12.9 Development Environment, this includes GTK+ development environment, libglade and Glade3. However the launcher it creates on your desktop has a little problem: it points to glade-2. You can fix that manually by modify its properties. Since many tutorials about PyGTK & Glade only apply on glade2, you may want to install glade-2. You can decompress the package and copy the files into corresponding path (e.g GTK/bin and GTK/share) if you like. Next, install Python 2.5. And then the rest. This is where the order matters. Because the rest of the packages wouldn't be able to detect the right location to go if python was absent. Now the installation is done. You can open IDLE and try import pygtk, gtk and py2exe to see if everything works. You also should also be able to edit you GUI with Glade now. Some more words on py2exe. You can find a brief tutorial on its usage [here]. And how to combine it with PyGTK [here]. The second link tells you to copy some stuff from GTK to your executable path, that makes the size of you application way more bigger that it was. Try to remove some of the unrelated files in these folders, like Docs, as long as your executable behaves properly.

2 comments:

DreamonK said...

Oh, shit
Suddenly, I'm seeing blogspot?!!!!!!!!!!!!!!

Pablo Lerman said...

Thanks you very much,,,after try many of times, this tutorial realy help me,,,,