In PyQt, how can a terminal be embedded in a windo

2019-07-04 05:49发布

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条回答
smile是对你的礼貌
2楼-- · 2019-07-04 06:08

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.

查看更多
登录 后发表回答