帮我用pyqt5编写启动exe的代码
时间: 2023-06-08 15:04:31 浏览: 44
好的,以下是使用 PyQT5 启动 exe 文件的代码示例:
```python
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton
from PyQt5.QtCore import QProcess
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.button = QPushButton("启动 exe", self)
self.button.move(50, 50)
self.button.clicked.connect(self.start_exe)
def start_exe(self):
exe_path = "path/to/your/exe/file.exe"
process = QProcess(self)
process.startDetached(exe_path)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
```
你可以将 "path/to/your/exe/file.exe" 替换为你的实际 exe 文件的路径。当你点击按钮时,它将启动指定的 exe 文件。