Sorry, I don't know if I understood you correctly, but I suggest trying this:
import sys
import subprocess
import threading
import time
import win32gui
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QWindow, QPixmap
from PyQt5.QtWidgets import (QWidget, QApplication, QVBoxLayout,
QGridLayout, QMainWindow, QLabel)
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.central_widget = QWidget()
self.setCentralWidget(self.central_widget)
self.widget = QWidget()
self.widget.setFixedSize(230, 280)
self.widget.setStyleSheet("background-color: yellow;")
self.label = QLabel(self)
self.label.setPixmap(
QPixmap('images/splash_.jpg').scaled(self.size().width()/2, self.size().height())
)
self.grid_layout = QGridLayout(self.central_widget)
self.grid_layout.addWidget(self.widget, 0, 0, 2, 1)
self.v_layout = QVBoxLayout(self.widget)
self.initUI()
self.grid_layout.addWidget(self.label, 0, 1, 1, 1)
def initUI(self):
t = threading.Thread(target=self.runExe)
t.start()
# Calculator
hwnd1 = win32gui.FindWindowEx(0, 0, "CalcFrame", "Калькулятор")
start = time.time()
while hwnd1 == 0:
time.sleep(0.01)
# Calculator
hwnd1 = win32gui.FindWindowEx(0, 0, "CalcFrame", "Калькулятор")
end = time.time()
if end - start > 5:
return
window = QWindow.fromWinId(hwnd1)
widget = self.createWindowContainer(window, self.central_widget)
self.v_layout.addWidget(widget)
@staticmethod
def runExe():
exePath = "C:/Windows/system32/calc.exe"
subprocess.Popen(exePath)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
ex.resize(550, 400)
ex.show()
sys.exit(app.exec_())
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…