Question

I'm trying to use PyKDE, PyKDE.kdecore.KStandardDirs to be precise. This method is called with two strings according to the documentation and according to the PyQt4 documentation, I can use standard Python strs instead of QString. This doesn't work:

>> KStandardDirs.locate()("socket", "foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): not enough arguments
>>> KStandardDirs.locate("socket", "foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): argument 1 has unexpected type 'str'

I can't use QString either because it doesn't seem to exist:

>>> from PyQt4.QtCore import QString
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name QString
>>> from PyQt4.QtCore import *
>>> QString
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'QString' is not defined

What am I doing wrong?

Était-ce utile?

La solution

I suspect that PyKDE is not yet Python 3 ready, at least as far as that error message is concerned; try passing in a bytestring instead:

KStandardDirs.locate(b"socket", "foo")
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top