Embedding a terminal in PyQt5

你说的曾经没有我的故事 提交于 2019-11-29 12:56:05

In PyQt5. winId() returns a <sip.voidptr object at 0x7ff710025aa8> if you convert it to an integer then it will work.

Here's the working code:

import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class embterminal(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        self.process = QProcess(self)
        self.terminal = QWidget(self)
        layout = QVBoxLayout(self)
        layout.addWidget(self.terminal)

        # Works also with urxvt:
        self.process.start(
                'urxvt',['-embed', str(int(self.winId()))])
        print(self.winId())
        self.setGeometry(1, 1, 800, 600)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    main = embterminal()
    main.show()
    sys.exit(app.exec_())
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!