[PyKDE] can not load xml ui resource file?

Gordon Tyler gordon at doxxx.net
Sun Apr 20 20:11:01 BST 2003


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"))

Ciao,
Gordon




More information about the PyQt mailing list