I have a largeish application I'm developing in Python3 using PyQt5. I want to do something very much like what is being done here in PyQt4:
# -*- coding: utf-8 -*-
import atexit
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class XTerm(QX11EmbedContainer):
def __init__(self, parent, xterm_cmd="xterm"):
QX11EmbedContainer.__init__(self, parent)
self.xterm_cmd = xterm_cmd
self.process = QProcess(self)
self.connect(self.process,
SIGNAL("finished(int, QProcess::ExitStatus)"),
self.on_term_close)
atexit.register(self.kill)
def kill(self):
self.process.kill()
self.process.waitForFinished()
def sizeHint(self):
size = QSize(400, 300)
return size.expandedTo(QApplication.globalStrut())
def show_term(self):
args = [
"-into",
str(self.winId()),
"-bg",
"#000000", # self.palette().color(QPalette.Background).name(),
"-fg",
"#f0f0f0", # self.palette().color(QPalette.Foreground).name(),
# border
"-b", "0",
"-w", "0",
# blink cursor
"-bc",
]
self.process.start(self.xterm_cmd, args)
if self.process.error() == QProcess.FailedToStart:
print "xterm not installed"
def on_term_close(self, exit_code, exit_status):
print "close", exit_code, exit_status
self.close()
(from https://bitbucket.org/henning/pyqtwi...11/terminal.py)
- which is: Embed an X11 shell terminal (xterm) into a tab of my application.
I understand that QX11EmbedContainer is not in PyQt5, and that some usage of createWindowContainer may be the new approach, but I cannot find any example of this in action to follow.
I would ideally like to see the above code ported to a fully functional example using PyQt5 conventions and methods, but any assistance in any form will be helpful.
I have looked at Embedding external program inside pyqt5, but there is only a win32 solution there, and I need to run on Linux and MacOS, with windows being an unnecessary nicety, if there was a generalized solution to fit all 3. It feels like this is close, but I cannot find the appropriate replacement for the win32gui module to use in a general implementation.
I have looked at example of embedding matplotlib in PyQt5 1, but that pertains to matplotlib in particular, and not the general case.
All pointers and help will be gratefully acknowledged.