[PySide] Help with resource files

Eric Johnson hardware at darcygirl.com
Mon Apr 8 21:18:11 CEST 2013


Sean Fisk <sean <at> seanfisk.com> writes:
               
> 
> Thanks for the confirmation with Python 2 and 3 on Ubuntu. Although we
> don't yet know whether it is a bug or just incorrect code by me.
>                 

Works fine for me on Windows (cygwin/bash shell but win32 version of
Python 2.7.2) if I open the file first. 

I'm surprised there is no exception thrown if you don't do this.
I can try on OS X tonight.

   ...
   # Read resource
   test_txt = QtCore.QFile(':/test.txt')
   test_txt.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text)
   print 'Does it exist?: {0}'.format(test_txt.exists())
   print "readAll(): `{0}'".format(test_txt.readAll())

gives output

   $ python test.py
   Running PySide 1.1.0 / Qt 4.7.4
   PySide compiled with Qt 4.7.4
   Does it exist?: True
   readAll(): `This is just a test.
   '

Eric






More information about the PySide mailing list