Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#!/usr/bin/env python
import sys, atexit
from PyQt4.QtCore import *
from PyQt4.QtGui import *
WIN_ID = object()
class EmbedApp(QX11EmbedContainer):
def __init__(self, cmd, args, parent=None):
super().__init__(parent)
self.cmd = cmd
self.args = args
self.process = QProcess(self)
self.process.finished.connect(lambda c, s: self.close())
atexit.register(self.kill)
def showEvent(self, evt):
args = [a if a is not WIN_ID else str(self.winId()) for a in self.args]
self.process.start(self.cmd, args)
if self.process.error() == QProcess.FailedToStart:
print('process failed to start')
def kill(self):
self.process.kill()
self.process.waitForFinished()
def sizeHint(self):
size = QSize(400, 300)
return size.expandedTo(QApplication.globalStrut())
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.setLayout(QHBoxLayout())
w.layout().addWidget(EmbedApp('xterm', ["-into", WIN_ID]))
w.layout().addWidget(EmbedApp('xterm', ["-into", WIN_ID]))
w.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.