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 : https://www.youtube.com/watch?v=N6GWgxEvibE)
Thanks all in advance.
PyQt is a Python binding for Qt, which is a set of C++ libraries and development tools that include platform-independent abstractions for Graphical User Interfaces (GUI), as well as networking, threads, regular expressions, SQL databases, SVG, OpenGL, XML, and many other powerful features.
Next it instantiates an instance of QMainWindow so that PyQt knows what to display as the main app starts. In my experience, I've put setupui() in the init method of the app class. In your case, in the init method of MainCustomerWindow Finally, window. show() tells PyQt to begin rendering the main window.
PyQt have a Qt Designer tool which we can use to build GUIs than get python code of that GUI using Qt Designer. It has no similar tool as Qt Designer for Tkinter.
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()
...
Result:
lose exe'menu
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With