Advertisement
Guest User

embed urxvt

a guest
May 16th, 2021
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.62 KB | None | 0 0
  1. from PyQt5 import QtCore, QtGui, QtWidgets
  2. from PyQt5.QtGui import QMovie
  3. import os
  4. import sys
  5. from PyQt5.QtCore import Qt, QProcess
  6. from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QPlainTextEdit, QHBoxLayout, QVBoxLayout
  7.  
  8.  
  9. class Ui_MainWindow(QWidget):
  10.  
  11.     def __init__(self):
  12.         super().__init__()
  13.         #os.system('python3 lpav6dev.py')
  14.     def setupUi(self, MainWindow):
  15.         MainWindow.setObjectName("MainWindow")
  16.         MainWindow.setWindowFlag(QtCore.Qt.FramelessWindowHint)
  17.         MainWindow.resize(1248, 890)
  18.  
  19.         self.centralwidget = QtWidgets.QWidget(MainWindow)
  20.         self.centralwidget.setObjectName("centralwidget")
  21.         self.label3 = QtWidgets.QLabel(self.centralwidget)
  22.         self.label3.setGeometry(QtCore.QRect(136, 142, 800, 600))
  23.         self.label3.setScaledContents(True)
  24.         # self.label3.setObjectName("label3")
  25.         self.movie = QMovie("use/Rebound.gif")
  26.         self.label3.setMovie(self.movie)
  27.         self.movie.start()
  28.  
  29.        
  30.        
  31.        
  32.        
  33.  
  34.         self.Back = QtWidgets.QPushButton(self.centralwidget)
  35.         self.Back.setGeometry(QtCore.QRect(110, 80, 65, 65))
  36.         font = QtGui.QFont()
  37.         font.setPointSize(25)
  38.         font.setBold(True)
  39.         font.setWeight(75)
  40.         self.Back.setFont(font)
  41.         self.Back.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
  42.         self.Back.setFocusPolicy(QtCore.Qt.TabFocus)
  43.         self.Back.setStyleSheet("QPushBiutton{\n"
  44.                                 "    background-color: rgb(0, 0, 0);\n"
  45.                                 "}")
  46.         self.Back.setText("")
  47.         icon3 = QtGui.QIcon()
  48.         icon3.addPixmap(QtGui.QPixmap("use/Back.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  49.         self.Back.setIcon(icon3)
  50.         self.Back.setIconSize(QtCore.QSize(100, 100))
  51.         self.Back.setObjectName("Back")
  52.         self.Back.clicked.connect(MainWindow.close)
  53.         self.Back.clicked.connect(self.onStart)
  54.  
  55.         self.label1 = QtWidgets.QLabel(self.centralwidget)
  56.         self.label1.setGeometry(QtCore.QRect(0, 0, 1250, 900))
  57.         self.label1.setStyleSheet("")
  58.         self.label1.setFrameShape(QtWidgets.QFrame.NoFrame)
  59.         self.label1.setFrameShadow(QtWidgets.QFrame.Plain)
  60.         self.label1.setLineWidth(1)
  61.         self.label1.setText("")
  62.         self.label1.setPixmap(QtGui.QPixmap("use/BlackBG.png"))
  63.         self.label1.setScaledContents(True)
  64.         self.label1.setObjectName("label1")
  65.         '''self.VoiceButton = QtWidgets.QPushButton(self.centralwidget)
  66.        self.VoiceButton.setGeometry(QtCore.QRect(980, 340, 161, 161))
  67.        self.VoiceButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
  68.        self.VoiceButton.setFocusPolicy(QtCore.Qt.ClickFocus)
  69.        self.VoiceButton.setStyleSheet("QPushButton{\n"
  70. "rgb(0, 0, 0)\n"
  71. "}")
  72.        self.VoiceButton.setText("")
  73.        icon1 = QtGui.QIcon()
  74.        icon1.addPixmap(QtGui.QPixmap("use/TrainV.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  75.        self.VoiceButton.setIcon(icon1)
  76.        self.VoiceButton.setIconSize(QtCore.QSize(161, 161))
  77.        self.VoiceButton.setAutoRepeat(True)
  78.        self.VoiceButton.setAutoExclusive(True)
  79.        self.VoiceButton.setDefault(False)
  80.        self.VoiceButton.setObjectName("VoiceButton")'''
  81.  
  82.         self.FaceButton = QtWidgets.QPushButton(self.centralwidget)
  83.         self.FaceButton.setGeometry(QtCore.QRect(990, 650, 160, 120))
  84.         self.FaceButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
  85.         icon2 = QtGui.QIcon()
  86.         icon2.addPixmap(QtGui.QPixmap("use/FaceDetect.gif"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  87.         self.FaceButton.setIcon(icon2)
  88.         self.FaceButton.setIconSize(QtCore.QSize(180, 120))
  89.         self.FaceButton.setObjectName("FaceButton")
  90.         self.FaceButton.clicked.connect(self.onClick)
  91.  
  92.         self.ExitButton = QtWidgets.QPushButton('close', self.centralwidget)
  93.         self.ExitButton.setGeometry(QtCore.QRect(1040, 90, 60, 60))
  94.         self.ExitButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
  95.         self.ExitButton.setFocusPolicy(QtCore.Qt.NoFocus)
  96.         self.ExitButton.setText("")
  97.         icon3 = QtGui.QIcon()
  98.         icon3.addPixmap(QtGui.QPixmap("use/Exit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  99.         self.ExitButton.setIcon(icon3)
  100.         self.ExitButton.setIconSize(QtCore.QSize(60, 60))
  101.         self.ExitButton.setAutoExclusive(True)
  102.         self.ExitButton.setAutoDefault(True)
  103.         self.ExitButton.setObjectName("ExitButton")
  104.         self.ExitButton.clicked.connect(sys.exit)
  105.  
  106.         self.label1.raise_()
  107.         # self.VoiceButton.raise_()
  108.         self.FaceButton.raise_()
  109.         self.ExitButton.raise_()
  110.         self.label3.raise_()
  111.         self.Back.raise_()
  112.         # self.StartButton.raise_()
  113.         MainWindow.setCentralWidget(self.centralwidget)
  114.  
  115.         self.retranslateUi(MainWindow)
  116.         QtCore.QMetaObject.connectSlotsByName(MainWindow)
  117.         #p=QProcess()
  118.         #
  119.         #p.startDetached('python lpav6dev.py')
  120.  
  121.        
  122.     def onStart(self):
  123.         os.system('python HomePage.py')  
  124.          
  125.     def onClick(self):
  126.         #os.system('python3 facectrldev.py')
  127.         face=QProcess()
  128.         face.startDetached('python facectrldev.py')
  129.    
  130.     def retranslateUi(self, MainWindow):
  131.         _translate = QtCore.QCoreApplication.translate
  132.         MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
  133.         # self.StartButton.setToolTip(_translate("MainWindow", "Start"))
  134.         # self.VoiceButton.setToolTip(_translate("MainWindow", "Train Your Voice"))
  135.         self.FaceButton.setToolTip(_translate("MainWindow", "Face Detect"))
  136.         self.ExitButton.setToolTip(_translate("MainWindow", "Exit"))
  137.         self.Back.setToolTip(_translate("MainWindow", "MainWindow"))
  138. class Window(QWidget):
  139.     def __init__(self):
  140.         super().__init__()
  141.         self.process = QProcess(self)
  142.         self.terminal = QWidget(self)
  143.         layout = QVBoxLayout(self)
  144.         layout.addWidget(self.terminal)
  145.         wid = str(int(self.terminal.winId()))
  146.         self.process.start('urxvt', ['-embed', wid])
  147.  
  148.     def closeEvent(self, event):
  149.         self.process.terminate()
  150.         self.process.waitForFinished(1000)
  151.  
  152. if __name__ == "__main__":
  153.     import sys
  154.     app = QtWidgets.QApplication(sys.argv)
  155.     MainWindow = QtWidgets.QMainWindow()
  156.     ui2 = Ui_MainWindow()
  157.     ui2.setupUi(MainWindow)
  158.     window=Window()
  159.     window.setGeometry(100, 100, 700, 400)
  160.     window.show()
  161.     #os.system('python lpav6dev.py')
  162.     MainWindow.show()
  163.     sys.exit(app.exec_())
  164.     #os.system('python3 lpav6dev.py')
  165.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement