how to confine a xterm/rcvt/gnome-terminal to a specific region of screen

114 views Asked by At

I want to launch a QProcess and have it display / render in a specific region of the screen. The process is an xterm(1) or rcvt(1) or gnome-terminal(1) and I embed the rxvt(1) onto my main window.

   self.winIdStr = str(int(self.winId()))
   self.process.start('rxvt', ['-embed', self.winIdStr , '-e', './goo'])

But my main window looks like this: enter image description here

And I want to confine rxvt(1) to the QTextEdit area. Unfortunately I don't know Qt lingo well. So would I need to create a QFrame or some other thing to get this going?

1

There are 1 answers

0
eyllanesc On

You have to create a QWidget where you want the terminal to be placed and pass the winId() of that widget:

from PyQt5 import QtCore, QtGui, QtWidgets


class Widget(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.container = QtWidgets.QWidget()
        self.container.setFixedSize(600, 400)

        lay = QtWidgets.QVBoxLayout(self)
        lay.addWidget(QtWidgets.QLineEdit())
        lay.addWidget(QtWidgets.QPushButton())
        lay.addWidget(self.container)

        self.process = QtCore.QProcess(self)
        self.winIdStr = str(int(self.container.winId()))
        self.process.start("rxvt", ["-embed", self.winIdStr, "-e", "./goo"])


if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    w = Widget()
    w.show()
    sys.exit(app.exec_())

enter image description here