-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong type returned for the icon? #23
Comments
Thanks for reporting. Does your |
@goanpeca this looks like an issue with qtpy. |
Hmmmm I will take a look |
@baudren Can you print the type of print(type(icon))
print(icon.__str__)
print(icon.__unicode__)
print(icon.__repr__) |
You do not have PyQt on ubuntu or on windows? |
Can you show the full script/code of the example you are trying to run? |
Hi @goanpeca print(type(icon))
<class 'PyQt4.QtGui.QIcon'>
print(icon.__str__)
<method-wrapper '__str__' of QIcon object at 0x2aab6d9e7d60>
print(icon.__unicode__)
AttributeError: 'QIcon' object has no attribute '__unicode__'
print(icon.__repr__)
<method-wrapper '__repr__' of QIcon object at 0x2b379b695d60> @SylvainCorlay , For the presence of By the way, I am running |
To give a full example (which, by the way, does not work on my other setup, Win8.1, with Anaconda 2.1 (Python 2.7.8), under cygwin): import sys
from PySide import QtGui
import qtawesome as qta
app = QtGui.QApplication(sys.argv)
wid = QtGui.QWidget()
wid.setWindowTitle('Simple')
icon = qta.icon('fa.flag')
button = QtGui.QPushButton(icon, 'toto', wid)
wid.show()
sys.exit(app.exec_()) This snippet without the icon displays a Traceback (most recent call last):
File "simple.py", line 10, in <module>
button = QtGui.QPushButton(icon, 'Toto', wid)
TypeError: 'PySide.QtGui.QPushButton' called with wrong argument types:
PySide.QtGui.QPushButton(QIcon, str, PySide.QtGui.QWidget)
Supported signatures:
PySide.QtGui.QPushButton(PySide.QtGui.QWidget = None)
PySide.QtGui.QPushButton(PySide.QtGui.QIcon, unicode, PySide.QtGui.QWidget = None)
PySide.QtGui.QPushButton(unicode, PySide.QtGui.QWidget = None) |
Can you put this at the top of your script? from PySide import QtGui
##
import os
print(os.environ['QT_API'])
os.environ['QT_API'] = 'PySide'
##
import qtawesome as qta |
The However, setting What do you recon? Why is the Thanks |
Not sure if calling PySide is supposed to set an environment variable, I just wanted to check. QtPy will autodetect the backend in this order, PyQt5, PyQt4, PySide, unless it is enforced using |
But precisely - since I do not have PyQt5, nor PyQt4 installed, it should never set it to anything else. I don't think it is right to specify an |
Well it seems that you do have some remnant of either PyQt4 or PyQt5 in the system |
In projects that use the shim (qtpy in this case), there will be no problem cause the project and qtawesome will use the same (whatever that is) but if you are using or aiming a specific backend (pyside in this case) this must be set explicitly before calling qtawesome. |
I really have nothing from PyQt4 nor 5 on my system. Indeed, the problem goes away if I replace my |
What do you get if you do import sip
import PyQt4 and what do you get when you import import PyQt5 Regarding...
It should and I unfortunately cannot reproduce your error. I am using ubuntu 14.04 and have tested the library with only PyQt4, or with only PySide installed and it works on both cases. However if you have PyQt4 and PySide side by side and in your project you only use PySide, then it will not work and hence why I said "I will update the readme to make this clear." |
Ok, fair enough, the In any case, now that I realised that I do have import sys
from PyQt4 import QtGui
import qtawesome as qta
app = QtGui.QApplication(sys.argv)
wid = QtGui.QWidget()
wid.setWindowTitle('Simple')
icon = qta.icon('fa.flag')
button = QtGui.QPushButton(icon, 'Toto', wid)
wid.show()
sys.exit(app.exec_()) I get this traceback, then: No handlers could be found for logger "qtpy"
Traceback (most recent call last):
File "qt.py", line 10, in <module>
button = QtGui.QPushButton(icon, 'Toto', wid)
TypeError: arguments did not match any overloaded call:
QPushButton(QWidget parent=None): argument 1 has unexpected type 'PySide.QtGui.QIcon'
QPushButton(QString, QWidget parent=None): argument 1 has unexpected type 'PySide.QtGui.QIcon'
QPushButton(QIcon, QString, QWidget parent=None): argument 1 has unexpected type 'PySide.QtGui.QIcon' There really seems to be something fishy, here. Why would suddenly the icon get the |
True, it seems something is weird, but in your specific case is clear that you DO have to define the environment variable. Can you print the |
This time again, |
Thanks for reporting but given your actual setup (having both a system PyQt4, and a PySide on pip) you need to set the API to use explicitly, otherwise the automatic detection might result in the error case you found. |
@baudren, another option is for you to use qtpy for your entire project, with the benefit that your software will work with both pyqt and pyside! It is pretty stable (used in Spyder for a while). |
@SylvainCorlay, sure. I did a quick test by replacing the import statements, and it was breaking the code - I have to adapt all my calls to the PyQt5 syntax, including the tests, which will not be done so quickly. Does In any case, thank you for the feedback. |
@baudren it does support Python 2 and 3 PyQt5, PyQt4 and PySide, but the calls need to resemble the Qt5 api which splitted QtGui into QtGui and QtWidgets. QtPy will also add in the future some new widgets for common use, like rich text checkboxes and others. If you experience any problem please report it in the QtPy issue tracker :-) Thanks! |
qtpy is heavily used in Spyder which is Python2/Python3/PySide/PyQt compatible and has a big userbase, hence I am rather confident that you should be able to use it in your application. |
Hi,
thanks for the project, and for using some layer of abstraction to make it simpler to support both PySide and PyQt.
I am getting a strange error on my ubuntu 14.04, though, when trying out the simple example in the readme. I am trying to interface with my PySide project, doing the following:
but when running, I get the following trace:
The
QIcon
is probably coming fromPyQt
? In anyway, it is not understood asPySide.QtGui.QIcon
.If that helps to narrow down the problem:
Thanks in advance!
The text was updated successfully, but these errors were encountered: