[PyKDE] can not load xml ui resource file?

Jim Bublitz jbublitz at nwinternet.com
Sun Apr 20 23:17:01 BST 2003


On 20-Apr-03 Gordon Tyler wrote:
> On April 20, 2003 01:13 pm, Jim Bublitz wrote:
>> On 20-Apr-03 Paul Pacheco wrote:
>> > I am trying to create a KMainWindow in PyKDE and I am having
>> > problems trying to create the ui from an xml rc file.
>>
>> Solution #2:
>>
>> In line 61 of xmlmenudemo.py change:
>>
>>  self.createGUI ()
>>
>> to:
>>
>>  self.createGUI
>>  ("/home/jim/PyKDE-3.5-1/examples3/xmlmenudemoui.rc")
>>
>> Obviously, your path will be different, but I wanted to
>> emphasize
>> that it apparently needs to be the complete path (just
>> "xmlmenudemoui.rc" or "./xmlmenudemoui.rc" won't work).
> 
> I used the following in my PyKDE app:
> 
>   import sys
>   import os.path
> 
>   APP_DIR = os.path.dirname(os.path.abspath(sys.argv[0]))
>   UI_RC_FILE = os.path.join(APP_DIR, "xmlmenudemoui.rc")
> 
> It uses the standard first command-line argument -- the script
> location -- to 
> determine the directory in which the script is located. These
> lines appear 
> near the start of my script so that it's available as global
> data. You could 
> also just define APP_DIR as a global and then determine the ui.rc
> location 
> locally at the point where you call createGUI:
> 
>   self.createGUI(os.path.join(APP_DIR, "xmlmenudemoui.rc"))

That's probably what I'll do for the examples for the next release,
since it'll work for all versions and doesn't require messing up
people's KDE directories. It seems like kind of a useless change to
KDE.

Jim




More information about the PyQt mailing list