Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在PyQT5 GUI应用程序内运行活动窗口_Python_Python 2.7_Pyqt_Pyqt5_Ros - Fatal编程技术网

Python 在PyQT5 GUI应用程序内运行活动窗口

Python 在PyQT5 GUI应用程序内运行活动窗口,python,python-2.7,pyqt,pyqt5,ros,Python,Python 2.7,Pyqt,Pyqt5,Ros,我使用的是PyQT5,我想在TabWidget中运行一个外部窗口,类似的东西,但这个示例仅适用于windows,我想在linux(Ubuntu14.04)操作系统中运行。我在这方面也发现了类似的问题,但答案不起作用。也尝试了解决方案,但也没有成功。可以嵌入一个终端,比如,但是我不知道如何使用RViz命令来实现。我下面有一些代码,他使用wmctrl选择RViz(我想嵌入到GUI中的应用程序)窗口ID,并尝试将其放入“fromWinID()”类中,但窗口在我的应用程序外部打开,同时收到错误: QXc

我使用的是PyQT5,我想在TabWidget中运行一个外部窗口,类似的东西,但这个示例仅适用于windows,我想在linux(Ubuntu14.04)操作系统中运行。我在这方面也发现了类似的问题,但答案不起作用。也尝试了解决方案,但也没有成功。可以嵌入一个终端,比如,但是我不知道如何使用RViz命令来实现。我下面有一些代码,他使用wmctrl选择RViz(我想嵌入到GUI中的应用程序)窗口ID,并尝试将其放入“fromWinID()”类中,但窗口在我的应用程序外部打开,同时收到错误:

QXcbConnection: XCB error: 3 (BadWindow), sequence: 415, resource id: -1222189812, major code: 7 (ReparentWindow), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 460, resource id: -1222189812, major code: 7 (ReparentWindow), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 461, resource id: -1222189812, major code: 8 (MapWindow), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 463, resource id: -1222189812, major code: 18 (ChangeProperty), minor code: 0
QXcbConnection: XCB error: 3 (BadWindow), sequence: 464, resource id: -1222189812, major code: 12 (ConfigureWindow), minor code: 0
有人能帮忙吗

# -*- coding: utf-8 -*-
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
import subprocess
from subprocess import call, Popen, PIPE, check_output

class Container(QtWidgets.QTabWidget):
    def __init__(self):
        QtWidgets.QTabWidget.__init__(self)
        rvizCommand = 'rviz'
        # Using Popen instead of Call to dont block the process
        subprocess.Popen(rvizCommand, stdout=PIPE,
                         stdin=PIPE, shell=True)
        # wmctrl to find the active hexadecimal   
        lookForID = "wmctrl -l | grep -i RViz | awk '{print $1}'"
        rvizID = subprocess.check_output(lookForID, shell=True)
        rvizID = str(rvizID.rstrip("\n"))
        print(rvizID)
        window = QtGui.QWindow.fromWinId(rvizID)
        container = QtWidgets.QWidget.createWindowContainer(window, self)               
        self.addTab(container, 'RViz')

app = QtWidgets.QApplication(sys.argv)
rviz = Container()
rviz.show()
sys.exit(app.exec_())