In PyQt, how can a terminal be embedded in a window?

ぐ巨炮叔叔 提交于 2019-12-23 20:01:26

问题


I have a small script that is designed to embed an xterm in a PyQt GUI. On Linux, it works, creating a GUI like this:

However, running the same script on OS X yields two windows like this:

Does anyone know how to address this and prevent OS X from screwing up the GUI?

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class embeddedTerminal(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        self.resize(800, 600)
        self.process = QProcess(self)
        self.terminal = QWidget(self)
        layout = QVBoxLayout(self)
        layout.addWidget(self.terminal)
        self.process.start('xterm', ['-into', str(self.terminal.winId())])

if __name__ == "__main__":
    app = QApplication(sys.argv)
    main = embeddedTerminal()
    main.show()
    sys.exit(app.exec_())

回答1:


You could take a look at the qtconsole front end for Jupyter and try to use the bash kernel. Depending on your end goal, I know it is possible to embed an IPython kernel, in another application.



来源:https://stackoverflow.com/questions/33259533/in-pyqt-how-can-a-terminal-be-embedded-in-a-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!