PyQT4 App
-
@JonB
I began to solve this problem, but now i have this error:C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 26, in __init__ self.setWindowIcon(QtWidgets.QIcon("zigbee.png")) AttributeError: module 'PyQt5.QtWidgets' has no attribute 'QIcon'
-
I change it, but now i have this:
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 26, in __init__ self.setWindowIcon(QtWidgets.QGui("zigbee.png")) AttributeError: module 'PyQt5.QtWidgets' has no attribute 'QGui'
-
I change it, but now i have this:
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 26, in __init__ self.setWindowIcon(QtWidgets.QGui("zigbee.png")) AttributeError: module 'PyQt5.QtWidgets' has no attribute 'QGui'
-
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 26, in __init__ self.setWindowIcon(PyQt5.QGui("zigbee.png")) NameError: name 'PyQt5' is not defined
-
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 26, in __init__ self.setWindowIcon(PyQt5.QGui("zigbee.png")) NameError: name 'PyQt5' is not defined
PyQt5.QGui("zigbee.png")
What is this?! You want to use QIcon, right?
It should be I guessQtGui.QIcon("zigbee.png")
It is also shown in the documentation which you should consult: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QIcon.html
-
PyQt5.QGui("zigbee.png")
What is this?! You want to use QIcon, right?
It should be I guessQtGui.QIcon("zigbee.png")
It is also shown in the documentation which you should consult: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QIcon.html
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 26, in __init__ self.setWindowIcon(QtGui.QIcon("zigbee.png")) NameError: name 'QtGui' is not defined
-
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 26, in __init__ self.setWindowIcon(QtGui.QIcon("zigbee.png")) NameError: name 'QtGui' is not defined
-
-
@jsulm
Thank you, i fix thisBut now i have this:
Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 28, in __init__ self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget) AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
-
@jsulm
Thank you, i fix thisBut now i have this:
Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 360, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 355, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 28, in __init__ self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget) AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
QVBoxLayout
Please do also some research on your own!
If you google for QVBoxLayout you will find https://doc.qt.io/qt-5/qvboxlayout.html and there it is clearly stated that it is in widgets module (qmake: QT += widgets). -
QVBoxLayout
Please do also some research on your own!
If you google for QVBoxLayout you will find https://doc.qt.io/qt-5/qvboxlayout.html and there it is clearly stated that it is in widgets module (qmake: QT += widgets). -
QVBoxLayout
Please do also some research on your own!
If you google for QVBoxLayout you will find https://doc.qt.io/qt-5/qvboxlayout.html and there it is clearly stated that it is in widgets module (qmake: QT += widgets). -
I've try this but i have same error
from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QLineEdit, QTabBar, QFrame, QStackedLayout)
@Mitko
You should only get the same error if you left the code withQtGui.QVBoxLayout(self.centralWidget)
. After theimport
it should work with plainQVBoxLayout(self.centralWidget)
. Otherwise please don't say " same error" when so many errors are flying around, please show the actual line of any error and paste the error message. -
@Mitko
You should only get the same error if you left the code withQtGui.QVBoxLayout(self.centralWidget)
. After theimport
it should work with plainQVBoxLayout(self.centralWidget)
. Otherwise please don't say " same error" when so many errors are flying around, please show the actual line of any error and paste the error message.When i use:
from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout
I have this:
File "C:/xbee-gui-master/MainForm.py", line 3, in <module> from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout ImportError: cannot import name 'QVBoxLayout' from 'PyQt5' (C:\xbee-gui-master\PyQT\lib\site-packages\PyQt5\__init__.py)
When i use:
from PyQt5 import QtWidgets, QtCore, QtGui from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QLineEdit, QTabBar, QFrame, QStackedLayout)
I have this:
File "C:/xbee-gui-master/MainForm.py", line 35, in __init__ self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget) AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
-
When i use:
from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout
I have this:
File "C:/xbee-gui-master/MainForm.py", line 3, in <module> from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout ImportError: cannot import name 'QVBoxLayout' from 'PyQt5' (C:\xbee-gui-master\PyQT\lib\site-packages\PyQt5\__init__.py)
When i use:
from PyQt5 import QtWidgets, QtCore, QtGui from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QLineEdit, QTabBar, QFrame, QStackedLayout)
I have this:
File "C:/xbee-gui-master/MainForm.py", line 35, in __init__ self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget) AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
@Mitko
The first error is correct.from PyQt5 import QtWidgets, QtCore, QtGui
is good.QVBoxLayout
is not inPyQt5
, so the error is correct.Your second example is correct.
QtWidgets
does containQVBoxLayout
so that is good.Given which, it is hardly surprising that
self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
gives the error it does, is it? You know that
QVBoxLayout
has been moved fromQtGui
in Qt 4 toQtWidgets
in Qt 5, don't you, because that is what you are supposed to be changing to make it work. So there's no point putting what used to work and does not work now.Given your second example code, there are two ways you can address
QVBoxLayout
:-
QtWidgets.QVBoxLayout
: This is allowed from yourfrom PyQt5 import QtWidgets
line. -
QVBoxLayout
: This is allowed from yourfrom PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, ...
line.
-
-
@Mitko
The first error is correct.from PyQt5 import QtWidgets, QtCore, QtGui
is good.QVBoxLayout
is not inPyQt5
, so the error is correct.Your second example is correct.
QtWidgets
does containQVBoxLayout
so that is good.Given which, it is hardly surprising that
self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
gives the error it does, is it? You know that
QVBoxLayout
has been moved fromQtGui
in Qt 4 toQtWidgets
in Qt 5, don't you, because that is what you are supposed to be changing to make it work. So there's no point putting what used to work and does not work now.Given your second example code, there are two ways you can address
QVBoxLayout
:-
QtWidgets.QVBoxLayout
: This is allowed from yourfrom PyQt5 import QtWidgets
line. -
QVBoxLayout
: This is allowed from yourfrom PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, ...
line.
Hi, i'm really grateful for your help so far.
I managed to clear that types of errors.
But now i have different types of error:
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 367, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 362, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 50, in __init__ self.all_tab() File "C:/xbee-gui-master/MainForm.py", line 63, in all_tab self.tab_control() File "C:/xbee-gui-master/MainForm.py", line 160, in tab_control self.list_all_commands() File "C:/xbee-gui-master/MainForm.py", line 211, in list_all_commands self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked) AttributeError: 'Block' object has no attribute 'connect'
Can you please help me ?
-
-
You wrote as if it was C++. That's wrong.
With PyQt/PySide:
source_object.name_of_signal.connect(target_object.name_of_slot)
Replace source_object and target_object with suitable objects in your code.
Note that in the project your linked to, there are several connect statements already done.
-
Hi, i'm really grateful for your help so far.
I managed to clear that types of errors.
But now i have different types of error:
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 367, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 362, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 50, in __init__ self.all_tab() File "C:/xbee-gui-master/MainForm.py", line 63, in all_tab self.tab_control() File "C:/xbee-gui-master/MainForm.py", line 160, in tab_control self.list_all_commands() File "C:/xbee-gui-master/MainForm.py", line 211, in list_all_commands self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked) AttributeError: 'Block' object has no attribute 'connect'
Can you please help me ?
self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked)
That is the original.
-
I have never heard of
self.connect()
. -
I doubt that
QtCore.SIGNAL("clicked(const QModelIndex&)")
is acceptable, but I don't know.
I would try
self.view.clicked.connect(on_item_clicked)
Meanwhile separately I note that the code has:
class Block(QtGui.QMainWindow, QtGui.QTreeView):
That means
Block
is derived from twoQObject
s,QMainWindow
&QTreeView
. This is explicitly forbidden in Qt, at least in Qt5 and/or C++. Maybe it worked in Qt4/PyQt4, but will not now in any circumstances....Meanwhile, I don't know why you couldn't find this for yourself but isn't https://github.com/RuslanSdk/XBee-PyQt5-V.1.0 like it says Qt5/PyQt5 and what you want?
-
-
self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked)
That is the original.
-
I have never heard of
self.connect()
. -
I doubt that
QtCore.SIGNAL("clicked(const QModelIndex&)")
is acceptable, but I don't know.
I would try
self.view.clicked.connect(on_item_clicked)
Meanwhile separately I note that the code has:
class Block(QtGui.QMainWindow, QtGui.QTreeView):
That means
Block
is derived from twoQObject
s,QMainWindow
&QTreeView
. This is explicitly forbidden in Qt, at least in Qt5 and/or C++. Maybe it worked in Qt4/PyQt4, but will not now in any circumstances....Meanwhile, I don't know why you couldn't find this for yourself but isn't https://github.com/RuslanSdk/XBee-PyQt5-V.1.0 like it says Qt5/PyQt5 and what you want?
I think i fix this:
self.view.clicked.connect(on_item_clicked)
About the "Block" error - is there some Qt5 replacement ?
About the project you refer to - i've tried it and it can be runned, but it can't load more then one xbee modules, and i wish to establish a network with meny devices.
I tried to contact the creator, but he don't reply.Meanwhile i have new errors:
C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py Traceback (most recent call last): File "C:/xbee-gui-master/MainForm.py", line 367, in <module> main() File "C:/xbee-gui-master/MainForm.py", line 362, in main bl = Block() File "C:/xbee-gui-master/MainForm.py", line 50, in __init__ self.all_tab() File "C:/xbee-gui-master/MainForm.py", line 63, in all_tab self.tab_control() File "C:/xbee-gui-master/MainForm.py", line 174, in tab_control model = QtWidgets.QStringListModel() AttributeError: module 'PyQt5.QtWidgets' has no attribute 'QStringListModel'
Any help, please ?
-