I have the following:
when executing the file
main.py
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog
from PyQt5 import uic
import subvent
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi('conexion.ui', self)
self.boton.clicked.connect(self.invocar)
self.Sub = subvent.Subvent()
def invocar(self):
self.Sub.exec_()
app = QApplication(sys.argv)
ventana = Principal()
ventana.show()
app.exec_()
I press the connect button and open subvent.py
from PyQt5.QtWidgets import QDialog
from PyQt5 import uic
import time
class Subvent(QDialog):
def __init__(self):
QDialog.__init__(self)
uic.loadUi('ventana.ui', self)
self.valor = 0
self._auto(self.valor)
self.boton_parar.clicked.connect(self.ocultar)
self.boton_inicio.clicked.connect(self.inicio)
def ocultar(self):
self.valor = 1
#self.close()
#self.linea.setEnabled(False)
self._auto(self.valor)
def inicio(self):
self.valor = 2
self._auto(self.valor)
def _auto(self, dato):
for x in range (0,5):
if self.valor == 2:
#self.caja.setText('inicio')
self.caja.setText(str('x='))
print ('vuelta ', x)
time.sleep(1)
elif self.valor == 1:
#self.caja.setText('parar')
print ('llego parar')
self.close()
break
I leave you an image so you have an idea
Well the case is that when you press start and this is running the count of returns for now only 5 (but the idea is that they are more), you can stop that account. I have not been able to achieve it because when you execute the program and give it to stop, you only do it when you finish counting.
While the for (is counting) is running, the buttons and windows are disabled and it does not let me press stop.
can only be done at the end of the for