Example #1
0
 def __init__(self, parent=None):
     QtGui.QWidget.__init__(self, parent)
     self.ui = Ui_watch()
     self.ui.setupUi(self)
     self.maximized = True
     
     self.rounds = 3
     self.round_actual = 1
     self.estado = Round(numero=self.round_actual, label=self.ui.lb_watch, window=self)
     self.ui.labelEstado.setText(str(self.estado))
Example #2
0
class VentanaTimer(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_watch()
        self.ui.setupUi(self)
        self.maximized = True
        
        self.rounds = 3
        self.round_actual = 1
        self.estado = Round(numero=self.round_actual, label=self.ui.lb_watch, window=self)
        self.ui.labelEstado.setText(str(self.estado))
        
    @pyqtSignature("")
    def keyPressEvent(self, event):
        key = event.key()
        # Start / Stop
        if key == Qt.Key_S : 
            if not self.estado.is_active():
                self.estado.start()

            else:
                self.estado.pause()

        # Vuelvo al Round 1 para cronometrar un nuevo combate
        if key == Qt.Key_R or key == Qt.Key_1 :
            self.round_actual = 1
            self.estado = Round(numero=self.round_actual, label=self.ui.lb_watch, window=self)
            self.ui.labelEstado.setText(str(self.estado))

		# Reiniciar en round 2 o 3 (categoria full)
        if self.rounds >= 2 and key == Qt.Key_2 :
            self.round_actual = 2
            self.estado = Round(numero=self.round_actual, label=self.ui.lb_watch, window=self)
            self.ui.labelEstado.setText(str(self.estado))

        if self.rounds >= 3 and key == Qt.Key_3 :
            self.round_actual = 3
            self.estado = Round(numero=self.round_actual, label=self.ui.lb_watch, window=self)
            self.ui.labelEstado.setText(str(self.estado))
        
        # Maximizar ventana cronometro
        if key == Qt.Key_M :
            if self.maximized == False :
                self.showMaximized()
                self.maximized = True
            else:
                self.showNormal()
                self.maximized = False
			
        # Exit cronometro
        if key == Qt.Key_Escape :
            self.close()
            sys.exit(0)
    
    def estado_timer_finalizado(self):
        if isinstance(self.estado, Round):
            if self.round_actual < self.rounds:
                self.estado = Descanso(label=self.ui.lb_watch, window=self)
                self.round_actual += 1
                self.estado.start()
        elif isinstance(self.estado, Descanso):
            self.estado = Round(numero=self.round_actual, label=self.ui.lb_watch, window=self)
            #self.estado.start()
        self.ui.labelEstado.setText(str(self.estado))