[PyQt] Determining location of pyqtdeployed app at runtime

Dave Gradwell davegradwell at yahoo.co.uk
Sat Aug 2 07:37:02 BST 2014

Hm, odd, I'm on v0.5.

admins-Mac-2:~ admin$ python3.4 /Users/admin/Desktop/clientUtility/clientUtility.py 
QtCore.QFileInfo(__file__).absolutePath() ---> /Users/admin/Desktop/clientUtility

admins-Mac-2:~ admin$ /Users/admin/Desktop/clientUtility/build/clientUtility.app/Contents/MacOS/clientUtility
QtCore.QFileInfo(__file__).absolutePath() ---> /Users/admin

Okay, I'll hack it for now with:
    import pyqtdeploy
    PATH_TO_ICONS = os.path.dirname(sys.executable) + "/icons/"
except ImportError:
    PATH_TO_ICONS = QtCore.QFileInfo(__file__).absolutePath() + "/icons/"
... or something.

Thanks, Dave.

On Fri, 1/8/14, Phil Thompson <phil at riverbankcomputing.com> wrote:

 Subject: Re: [PyQt] Determining location of pyqtdeployed app at runtime
 To: pyqt at riverbankcomputing.com
 Date: Friday, 1 August, 2014, 22:19
 It should work (with v0.5, not

 sys.executable will be correct (pyqtdeploy uses
 it internally). You can 
 use sys.executable
 when you know that the location you are after *will 
 not* be in the resource. You should use
 QFileInfo when the location 
 *might* be in
 the resource.

More information about the PyQt mailing list