I have a .png file that I need to access via
pkg_resources.resource_string (or _stream).  I want to turn this file
into a QIcon, and so I tried the following:

        data_str = pkg_resources.resource_string('my.package',
os.path.join('img', 'my.png'))

        qba = QByteArray.fromRawData(buffer(data_str))
        print >>sys.stderr, len(data_str), qba.length(),
data_str.index('\x00'), repr(qba)

        assert len(data_str) == qba.length() # This fails due to the
qba having stopped at the first null byte in data_str.

        qimg = QImage.fromData(qba, 'PNG')
        qpix = QPixmap.fromImage(qimg)
        qicon = QIcon(qpix)

However, due to bug 717 (I suggest bumping the priority on that bug -
it seems pretty serious to not be able to have nulls in QByteArrays),
it doesn't work.  Likewise, QImage.fromData(data_str, 'PNG') doesn't
seem to work either.

http://bugs.pyside.org/show_bug.cgi?id=717

Does anyone have any suggestions on how to connect the dots?

Thanks,
Eli
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to