[PySide] Help with resource files
Algis Kabaila
akabaila at pcug.org.au
Sun Apr 7 07:19:43 CEST 2013
Hi Sean,
You do not give much away: to begin with, your OS and Python version would
be useful.
If it is Python 3.x then a small change may help:
pyside-rcc -py3 resources.qrc -o resources.py
Just a shot in the dark, Sean!
Al.
On Saturday 06 April 2013 17:51:28 Sean Fisk wrote:
Hello everyone,
I want to embed some images and fonts in my PySide program using Qt's
resource system. I've used it very successfully in C++. However, I'm
having some trouble getting resource files to work with PySide. The
resource files seem to compile it all right, but I can't read my files in my
program.
I've created a minimum example to illustrate the problem:
test.py
#!/usr/bin/env python
# test.py
import PySide
from PySide import QtCore
import resources
# Versions
print 'Running PySide {0} / Qt {1}'.format(
PySide.__version__, QtCore.__version__)
print 'PySide compiled with Qt {0}'.format(QtCore.qVersion())
# Read resource
test_txt = QtCore.QFile(':/test.txt')
print 'Does it exist?: {0}'.format(test_txt.exists())
print "readAll(): `{0}'".format(test_txt.readAll())
resources.qrc
<RCC>
<qresource prefix="/">
<file>test.txt</file>
</qresource>
</RCC>
test.txt
This is just a test.
Instructions
Compile the resource file and then run:
$ pyside-rcc resources.qrc -o resources.py
$ python test.py
Running PySide 1.1.2 / Qt 4.8.4
PySide compiled with Qt 4.8.4
Does it exist?: True
readAll(): `'
Interestingly, if I change the readAll() call to readLine(), the program
segfaults. Anyone have any suggestions? I'd be open to other ways to
distribute fonts and images with my program as well.
Sincerely,
--
Sean Fisk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20130407/4c60b7ac/attachment.html>
More information about the PySide
mailing list