Hi there,
So i was experimenting and designing some gui i created in QT Designer. I converted the .ui file to a .py file and wanted to link a "Start" button to a test command i set up. I managed to do that, but now everytime i click on start and the command prompt opens, the gui just freezes until i quit the command prompt? Is there a way to fix this?
Full code:
main.py:
prompt.py:
So i was experimenting and designing some gui i created in QT Designer. I converted the .ui file to a .py file and wanted to link a "Start" button to a test command i set up. I managed to do that, but now everytime i click on start and the command prompt opens, the gui just freezes until i quit the command prompt? Is there a way to fix this?
Full code:
main.py:
from PyQt5 import QtCore, QtGui, QtWidgets
import prompt
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(600, 300)
Form.setMinimumSize(QtCore.QSize(600, 300))
Form.setMaximumSize(QtCore.QSize(600, 300))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(""), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Form.setWindowIcon(icon)
self.label_3 = QtWidgets.QLabel(Form)
self.label_3.setGeometry(QtCore.QRect(10, 10, 431, 141))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
self.label_3.setSizePolicy(sizePolicy)
self.label_3.setFrameShape(QtWidgets.QFrame.Box)
self.label_3.setFrameShadow(QtWidgets.QFrame.Raised)
self.label_3.setWordWrap(True)
self.label_3.setObjectName("label_3")
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(10, 150, 66, 31))
self.label.setWordWrap(True)
self.label.setObjectName("label")
self.label_4 = QtWidgets.QLabel(Form)
self.label_4.setGeometry(QtCore.QRect(10, 180, 71, 31))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
self.label_4.setSizePolicy(sizePolicy)
self.label_4.setWordWrap(True)
self.label_4.setObjectName("label_4")
self.label_9 = QtWidgets.QLabel(Form)
self.label_9.setGeometry(QtCore.QRect(10, 210, 61, 41))
self.label_9.setWordWrap(True)
self.label_9.setObjectName("label_9")
self.label_10 = QtWidgets.QLabel(Form)
self.label_10.setGeometry(QtCore.QRect(10, 250, 61, 41))
self.label_10.setWordWrap(True)
self.label_10.setObjectName("label_10")
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(70, 160, 211, 21))
self.lineEdit.setText("")
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(Form)
self.lineEdit_2.setGeometry(QtCore.QRect(70, 190, 211, 21))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(Form)
self.lineEdit_3.setGeometry(QtCore.QRect(70, 220, 211, 21))
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_4 = QtWidgets.QLineEdit(Form)
self.lineEdit_4.setGeometry(QtCore.QRect(70, 250, 211, 21))
self.lineEdit_4.setObjectName("lineEdit_4")
self.comboBox = QtWidgets.QComboBox(Form)
self.comboBox.setGeometry(QtCore.QRect(300, 160, 51, 20))
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(510, 0, 71, 71))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
self.label_2.setSizePolicy(sizePolicy)
self.label_2.setMaximumSize(QtCore.QSize(511, 16777215))
self.label_2.setText("")
self.label_2.setPixmap(QtGui.QPixmap(""))
self.label_2.setObjectName("label_2")
self.label_5 = QtWidgets.QLabel(Form)
self.label_5.setGeometry(QtCore.QRect(450, 10, 47, 13))
self.label_5.setOpenExternalLinks(True)
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(Form)
self.label_6.setGeometry(QtCore.QRect(450, 30, 31, 16))
self.label_6.setOpenExternalLinks(True)
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(Form)
self.label_7.setGeometry(QtCore.QRect(450, 50, 47, 13))
self.label_7.setOpenExternalLinks(True)
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(Form)
self.label_8.setGeometry(QtCore.QRect(450, 70, 141, 51))
self.label_8.setWordWrap(True)
self.label_8.setObjectName("label_8")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(420, 270, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(500, 270, 75, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.label_11 = QtWidgets.QLabel(Form)
self.label_11.setGeometry(QtCore.QRect(300, 190, 61, 20))
self.label_11.setWordWrap(True)
self.label_11.setObjectName("label_11")
self.lineEdit_5 = QtWidgets.QLineEdit(Form)
self.lineEdit_5.setGeometry(QtCore.QRect(360, 190, 20, 20))
self.lineEdit_5.setObjectName("lineEdit_5")
self.label_12 = QtWidgets.QLabel(Form)
self.label_12.setGeometry(QtCore.QRect(390, 180, 111, 41))
self.label_12.setWordWrap(True)
self.label_12.setObjectName("label_12")
self.pushButton_2.clicked.connect(self.cmd)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Yeetr"))
self.label_3.setText(_translate("Form", "<html><head/><body><p><span style=\" font-weight:600;\">Some more random stufffff </span><span style=\" font-weight:600; font-style:italic; color:#ff0000;\">Evern more renreifeawodom</span></p><p><span style=\" font-weight:600; color:#000000;\">More random</span></p><p><span style=\" font-weight:600; text-decoration: underline; color:#000000;\">Lol random</span><span style=\" font-weight:600; color:#000000;\"> Click here \'Hehe\'.</span></p><p><span style=\" font-weight:600; text-decoration: underline; color:#000000;\">More random</span><span style=\" font-weight:600; color:#000000;\"> RANDOMRANDOM</span></p><p><br/></p></body></html>"))
self.label.setText(_translate("Form", "MORE RANDOM"))
self.label_4.setText(_translate("Form", "RandomXTXTXT"))
self.label_9.setText(_translate("Form", "<html><head/><body><p>randomttz</p></body></html>"))
self.label_10.setText(_translate("Form", "<html><head/><body><p>Randomttxtxtxt</p></body></html>"))
self.comboBox.setItemText(0, _translate("Form", "Random"))
self.comboBox.setItemText(1, _translate("Form", "More random"))
self.label_5.setText(_translate("Form", "<html><head/><body><p><a href=\"https://google.com/\"><span style=\" text-decoration: underline; color:#0000ff;\">Googl</span></a></p></body></html>"))
self.label_6.setText(_translate("Form", "<html><head/><body><p><a href=\"https://google.com.au\"><span style=\" text-decoration: underline; color:#0000ff;\">GOOGEL</span></a></p></body></html>"))
self.label_7.setText(_translate("Form", "<html><head/><body><p><a href=\"https://forums.tomshardware.com\"><span style=\" text-decoration: underline; color:#0000ff;\">Lol what?</span></a></p></body></html>"))
self.label_8.setText(_translate("Form", "<html><head/><body><p><span style=\" font-style:italic;\">\'Random </span><span style=\" font-weight:600; font-style:italic;\">More random</span><span style=\" font-style:italic;\"> Even more random\'</span></p></body></html>"))
self.pushButton.setText(_translate("Form", "Stop"))
self.pushButton_2.setText(_translate("Form", "Start"))
self.label_11.setText(_translate("Form", "chchchchhcch"))
self.label_12.setText(_translate("Form", "<html><head/><body><p>random text</p></body></html>"))
def cmd(self):
prompt.commandpmp()
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
prompt.py:
import os
def commandpmp():
command = 'start "" /D "test batch file" /W hi.bat'
os.system(command)