在 Python GUI (PyQt) 中运行外部 exe

编程入门 行业动态 更新时间:2024-10-21 04:03:40
本文介绍了在 Python GUI (PyQt) 中运行外部 exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在 python gui (python 2.7 | Windows | PyQt) 中运行一个 exe(例如 calc.exe 或 cmd.exe).有人知道我该怎么做吗?(类似这样:

I want to run an exe (for example calc.exe or cmd.exe) inside a python gui (python 2.7 | Windows | PyQt). Have anybody an idea how can i do this? (something like that : www.youtube/watch?v=N6GWgxEvibE)

Thanks all in advance.

解决方案

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() ...

  • 01 create a process, run your exe
  • 02 use spy++ to get hwnd of the exe
  • 03 create QWindow from hwnd
  • 04 create window container

Result:

lose exe'menu

更多推荐

在 Python GUI (PyQt) 中运行外部 exe

本文发布于:2023-11-24 04:32:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GUI   Python   exe   PyQt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!