Advertisement
Guest User

embed_terminal_7_urxvt.py

a guest
Jun 29th, 2020
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. import sys
  2. from PyQt5 import QtCore, QtWidgets
  3. import subprocess
  4. import os
  5.  
  6.  
  7. class EmbTerminal(QtWidgets.QWidget):
  8.     def __init__(self, parent=None):
  9.         super(EmbTerminal, self).__init__(parent)
  10.         self.resize(1280, 720)
  11.         self.process = QtCore.QProcess(self)
  12.         self.terminal = QtWidgets.QWidget(self)
  13.         layout = QtWidgets.QVBoxLayout(self)
  14.  
  15.         # Works also with urxvt:
  16.         if subprocess.call(["which", 'xterm'], stdout=open(os.devnull, 'wb')) == 1:
  17.             self.process.start('xterm', ['-into', str(int(self.winId()))])
  18.         else:
  19.             #self.process.start('xterm',['-into', str(int(self.winId()))])
  20.             self.process.start('urxvt', ['-embed', str(int(self.winId()))])
  21.         # self.setFixedSize(450, 340)
  22.         #self.setGeometry(1, 1, 495, 325)
  23.         #self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  24.         layout.addWidget(self)
  25.         self.setLayout(layout)
  26.         #self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  27.  
  28.     def close(self):
  29.         self.process.kill()
  30.  
  31.  
  32. class mainWindow(QtWidgets.QMainWindow):
  33.     def __init__(self, parent=None):
  34.         super(mainWindow, self).__init__(parent)
  35.  
  36.         central_widget = QtWidgets.QWidget()
  37.         lay = QtWidgets.QVBoxLayout(central_widget)
  38.         self.setCentralWidget(central_widget)
  39.  
  40.         #tab_widget = QtWidgets.QTabWidget()
  41.         lay.addWidget(EmbTerminal())
  42.         #self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  43.         # self.setMinimumSize(450,340)
  44.  
  45.         # tab_widget.addTab(EmbTerminal(), "EmbTerminal")
  46.         # tab_widget.addTab(QtWidgets.QTextEdit(), "QTextEdit")
  47.     # tab_widget.addTab(QtWidgets.QMdiArea(), "QMdiArea")
  48.  
  49.  
  50. if __name__ == "__main__":
  51.     app = QtWidgets.QApplication(sys.argv)
  52.     main = EmbTerminal()
  53.     main.show()
  54.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement