我正在使用 ROS 为多机器人系统开发 GUI,但我对界面中最不想做的事情感到困惑:在我的应用程序中嵌入 RVIZ、GMAPPING 或其他屏幕。我已经在界面中放置了一个终端,但我无法解决如何向我的应用程序添加外部应用程序窗口的问题。我知道 PyQt5 有 createWindowContainer,使用窗口 ID 来停靠外部应用程序,但我没有找到任何示例来帮助我。
如果可能的话,我想将外部窗口拖放到我的应用程序中的选项卡式框架内。但是,如果这是不可能的或太难了,我可以在单击按钮后仅打开选项卡式框架内的窗口。
我已经尝试打开类似于终端方法的窗口(请参阅下面的代码),但 RVIZ 窗口在我的应用程序外部打开。
已经尝试翻译了附加/分离代码 https://stackoverflow.com/questions/54388685/issues-when-attaching-and-detaching-external-app-from-qdockwidget使用 wmctrl 命令将代码写入 linux,但不起作用。看我的代码在这里 https://pastebin.com/kWtKb4UN.
也已经尝试过rviz Python 教程 http://docs.ros.org/indigo/api/rviz_python_tutorial/html/但我收到错误:
回溯(最近一次调用最后一次):
文件“rvizTutorial.py”,第 23 行,位于
导入rviz
文件“/opt/ros/indigo/lib/python2.7/dist-packages/rviz/init.py”,第 19 行,在
导入 librviz_shiboken
导入错误:没有名为 librviz_shiboken 的模块
# Frame where i want to open the external Window embedded
self.Simulation = QtWidgets.QTabWidget(self.Base)
self.Simulation.setGeometry(QtCore.QRect(121, 95, 940, 367))
self.Simulation.setTabPosition(QtWidgets.QTabWidget.North)
self.Simulation.setObjectName("Simulation")
self.SimulationFrame = QtWidgets.QWidget()
self.SimulationFrame.setObjectName("SimulationFrame")
self.Simulation.addTab(rviz(), "rViz")
# Simulation Approach like Terminal
class rviz(QtWidgets.QWidget):
def __init__(self, parent=None):
super(rviz, self).__init__(parent)
self.process = QtCore.QProcess(self)
self.rvizProcess = QtWidgets.QWidget(self)
layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(self.rvizProcess)
# Works also with urxvt:
self.process.start('rViz', [str(int(self.winId()))])
self.setGeometry(121, 95, 940, 367)