我想在python gui(python 2.7 | Windows | PyQt)中运行exe(例如calc.exe或cmd.exe)。 有谁知道我该怎么做? (类似的东西:https://www.youtube.com/watch?v=N6GWgxEvibE)
提前全部谢谢。
答案 0 :(得分:3)
import subprocess
import time
import win32gui
...
def initUI(self):
# create a process
exePath = "C:\\Windows\\system32\\calc.exe"
subprocess.Popen(exePath)
hwnd = win32gui.FindWindowEx(0, 0, "CalcFrame", "计算器")
time.sleep(0.05)
window = QWindow.fromWinId(hwnd)
self.createWindowContainer(window, self)
self.setGeometry(500, 500, 450, 400)
self.setWindowTitle('File dialog')
self.show()
...
结果:
输掉exe菜单