wilmens™

by William W. Mensah

Problem Solved!

  • Wednesday Sep 24,2008 09:04 PM
  • By wmensah
  • In myDiary

I finally got everything working just the way I want it. Below is a summary of the problem and the solution to it

Problem:

GTK 2.0 Runtime Environment gets installed in 2 different directories based on which version of Windows you’re running. In my case, Vista and XP

In Vista, it was installed to: C:\Program Files (x86)\Common Files\

In XP, it was installed to C:\

As a result the GTK_BASEPATH environment had 2 different values for each operating system – not such a good thing.

Unfortunately for my python application which requires pango modules to run, the pango.modules and gdk-pixbuf.loaders files had paths to the necessary dll files hard-coded in them.

This is a portion of my pango.modules file

# Pango Modules file

# Automatically generated file, do not edit

#

# ModulesPath = C:\GTK\lib\pango\1.6.0\modules

#

“C:\\GTK\\lib\\pango\\1.6.0\\modules\\pango-arabic-fc.dll” ArabicScriptEngineFc PangoEngineShape PangoRenderFc arabic:* nko:*

“C:\\GTK\\lib\\pango\\1.6.0\\modules\\pango-arabic-lang.dll” ArabicScriptEngineLang PangoEngineLang PangoRenderNone arabic:*

Notice how C:\\GTK has been hard-coded. This created a problem whenever the application was installed and run on a different computer other than mine (on which the hard-coded paths made sense). I suppose the executable file pango-querymodules.exe is supposed to fix this but I had weird results instead. So my solution?….

Solution:

  • Manually go inside these two files: pango.modules and gdk-pixbuf.loaders and replace every instance of GTK’s base path with some string of your choice ( I used <gtk_basepath> for mine).
  • Create a python file to access the two files that has hard-coded paths in them: pango.modules and gdk-pixbuf.loaders and perform a search and replace <gtk_basepath> with the value of the GTK_BASEPATH environment variable. You can do something like:

import os
replacestring = os.environ['GTK_BASEPATH']

where replacestring is a variable that will be used to replace every instance of <gtk_basepath> in both files (watch out for ‘\’ and ‘\\’)

  • Finally create a batch file to execute this python file after installation is complete. You can use the same batch file to delete the python file after that when done because you wont need it anymore.?

My batch file looked like this:

START PYTHON postscript.py

DEL postscript.py

And that’s it, pango.modules and gdk-pixbuf.loaders should now have the correct paths to GTK no matter where it is installed.

I hope this helps someone.

GTK_BASEPATH continued…

  • Tuesday Sep 23,2008 09:45 PM
  • By wmensah
  • In myDiary

So a sweeter approach will be to replace the path to GTK in every file for which this path has been hardcoded (pango.modules and gdk-pixbuf.loaders, in my case) with the GTK_BASEPATH environment variable. How to do this?……simply write a python script to perform a search and replace on whatever the current GTK path in the file is and replace it with the value of GTK_BASEPATH. I haven’t actually tried it but when I do I’ll submit a post stating whether I was successful or not.

The python OS module allows us to determine which operating system the user is currently running so that might be of some help.

myDiary 4.2 for Linux on Windows

  • Thursday Sep 4,2008 01:21 PM
  • By wmensah
  • In myDiary

Thanks to py2exe and Inno Setup Compiler I’ve been able to get the Linux version of myDiary 4.2 to run on Windows (of course with GTK+ Runtime Environment). Thanks Chris

Ok, so I went through hell yesterday trying to figure out why the UI wont show any of my external .png images located in the pixmap folder. The culprit? – gdk-pixbuf.loaders. A file located inside the …\etc directory. The path to libpixbufloader-ico.dll amongst several other dll files had been hard-coded inside the gdk-pixbuf.loaders file which I had to manually change before it finally worked.

I’m currently having 2 issues right now:

  • Face Cap image wont load…..I have no clue what’s going on with it.
  • Windows desktop shortcut is having problems locating the .glade XML file which the python file depends on.

Oh well….I’m jumping on that right now.

3:35pm – FIXED!

Killed 2 birds with one stone! Here’s the stone:

os.path.realpath(os.path.dirname(sys.argv[0]))

Yea, more like a rock….it simply gives you the path to the application you’re running and from there you can use an os.path.join or whatever to link to other files or directories you need to access…..like my glade file in this case :)

Other issues:

  • Gtkspell is not working….
  • Synchronization algorithm needs some serious modification in order to work in Windows….ugh!