我正在尝试在我自己的PyQt4编写的应用程序中使用Rviz(ROS Visualization工具)。我正在使用QTcreator IDE来设计表单并使用pyuic4将其转换为python代码。
Rviz库使用python_qt_binding,其中inturn使用PyQT或PySide(在我的情况下,我只安装了PyQt)。
我正在尝试将Rviz初始化为QWidget并在我的应用程序中显示它。我的应用程序和Rviz小部件在单独运行时工作正常,但在我尝试将Rviz QWidget导入应用程序时显示以下错误。
Traceback (most recent call last):
File "./mainwindow.py", line 38, in <module>
from RvizInitializer import RViz
File "/home/parallels/Documents/eclipse/workspace/GUI/src/RvizInitializer.py", line 8, in <module>
from python_qt_binding.QtGui import *
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/__init__.py", line 55, in <module>
from .binding_helper import loadUi, QT_BINDING, QT_BINDING_MODULES, QT_BINDING_VERSION # @UnusedImport
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 252, in <module>
getattr(sys, 'SELECT_QT_BINDING_ORDER', None),
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 89, in _select_qt_binding
QT_BINDING_VERSION = binding_loader(required_modules, optional_modules)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 131, in _load_pyqt
_named_import('PyQt5.%s' % module_name)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 111, in _named_import
module = builtins.__import__(name)
RuntimeError: the PyQt5.QtCore and PyQt4.QtCore modules both wrap the QObject class
代码段:
Rviz初始化程序
class RViz():
def __init__(self):
self.Mainwidget = QWidget()
self.frame = rviz.VisualizationFrame()
self.frame.setSplashPath( "" )
self.frame.initialize()
reader = rviz.YamlConfigReader()
config = rviz.Config()
reader.readFile( config, "/home/parallels/catkin_ws/src/map-toddler/configuration_files/rviz_config_files/karto.rviz" )
self.frame.load( config )
self.Mainwidget.setWindowTitle( config.mapGetChild( "Title" ).getValue() )
self.frame.setMenuBar( None )
self.frame.setStatusBar( None )
self.frame.setHideButtonVisibility( False )
## Here we create the layout and other widgets in the usual Qt way.
layout = QVBoxLayout()
layout.addWidget( self.frame )
self.Mainwidget.setLayout(layout)
#self.Mainwidget.resize(500,500)
#self.Mainwidget.show()
导入Rviz Qwidget:
from RvizInitializer import RViz
class mainwindow():
def __init__(self):
.
.
other code
.
.
self.RviZ = RViz()
self.MappingFrameHndl.SLAMLayout.addWidget(self.RviZ.Mainwidget)
非常感谢任何帮助