This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Use 'str' as QString in Python 3

Tags: None
(comma "," separated)
pashazz
Registered Member
Posts
10
Karma
0
OS

Use 'str' as QString in Python 3

Fri Jun 29, 2012 5:58 pm
In Python 3 there are no QStrings in both pyqt4 and pyside

But I have problem with passing str as QString in python3:

Code: Select all
from PyKDE4.kdecore import KStandardDirs
dirs = KStandardDirs()
dirs.findResourceDir('data')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/pasha/<ipython-input-25-a1e493d1ba02> in <module>()
----> 1 d.findResourceDir('data')

TypeError: KStandardDirs.findResourceDir(): argument 1 has unexpected type 'str'



http://api.kde.org/pykde-4.7-api/kdecor ... esourceDir
PyKDE 4.8.95
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Have you tried passing a unicode string instead of a standard string?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
pashazz
Registered Member
Posts
10
Karma
0
OS
bcooksley wrote:Have you tried passing a unicode string instead of a standard string?

in python 3 all strings are unicode just as in Qt.
u'str' gives invalid syntax.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Sorry about that, used to working with Python 2. u'str' is Python 2 syntax...

Have you tried using QString directly?
from PyQt4.QtCore import QString


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient