I have an issue trying to accomplish this situation.
I created a form with PyQt4 with a checkbox and a button. Program will run the script if you click execute and the checkbox has been toggle.
Can you please help me with that?
Sorry, Inglish is not my native lenguage
Thanks
import sys
from PyQt4 import QtGui, QtCore
import subprocess
class Window(QtGui.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setGeometry(200, 200, 200, 200)
self.setWindowTitle("Learning")
self.setWindowIcon(QtGui.QIcon('pythonlogo.png'))
self.home()
def home(self):
btn = QtGui.QPushButton("Execute", self)
btn.clicked.connect(self.execute)
btn.resize(btn.minimumSizeHint())
btn.move(110,160)
checkBox = QtGui.QCheckBox('Run script?', self)
#checkBox.isChecked.connect(self)
self.show()
def execute(self):
if checkBox.isChecked():
subprocess.Popen("script.py 1", shell=True)
def run():
app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
run()
Aucun commentaire:
Enregistrer un commentaire