当我使用pyqt5时,界面卡住了,启动mongodb和启动jupyter在同一命令行上运行。我不知道如何修改此代码。这是我的代码,两个启动命令都被执行,并且GUI卡住了。
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtWidgets,QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow,QMessageBox,QWidget
import os
import sys
import base64
class Ui_Dialog(QWidget):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(720, 543)
self.msgBox = QMessageBox()
self.mongo = QtWidgets.QPushButton(Dialog)
self.mongo.setGeometry(QtCore.QRect(10, 40, 111, 31))
self.mongo.setObjectName("pushButton")
self.jupy = QtWidgets.QPushButton(Dialog)
self.jupy.setGeometry(QtCore.QRect(160, 40, 101, 31))
self.jupy.setObjectName("pushButton_2")
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(330, 40, 131, 31))
self.lineEdit.setObjectName("lineEdit")
self.dj = QtWidgets.QPushButton(Dialog)
self.dj.setGeometry(QtCore.QRect(510, 40, 131, 31))
self.dj.setObjectName("pushButton_3")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)`
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "tools"))
self.mongo.setText(_translate("Dialog", "Startmongo"))
self.mongo.clicked.connect(self.run_mongo)
self.jupy.setText(_translate("Dialog", "startjupyter"))
self.jupy.clicked.connect(self.run_junpyter)
self.dj.setText(_translate("Dialog", "startdjango"))
self.dj.clicked.connect(self.run_django)
def run_mongo(self):
os.system('mongod --dbpath d:\data\db')
def run_junpyter(self):
starts = 'jupyter notebook'
os.system(starts)
def run_django(self,starts):
paths = self.dj_path.GetValue()
starts ='cd /d %s && python manage.py runserver'%paths
os.system(starts)
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = Ui_Dialog()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
我不知道如何启动或关闭多个进程