Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Cronometro - gestoreForm.py

gestoreForm.py

Caricato da: Poggi Marco
Scarica il programma completo

  1. from tkinter import *
  2. from tempo import Tempo
  3.  
  4. class App:
  5.  
  6.      def __init__(self, root=None):
  7.           """Costruttore"""
  8.           self.crono=Tempo()
  9.           self.radice=root
  10.           self.btnStart=Button(self.radice, text=" Avvio ", command=self.BtnstartClick)
  11.           self.labTempo=Label(self.radice, text=str(self.crono))
  12.           self.btnStop=Button(self.radice, text='Ferma', command=self.btnstopClick)
  13.           self.boxIntertempi=Label(self.radice, text='Intertempi:')
  14.           self.btnIntertempo=Button(self.radice, text='Intertempo', command=self.btnIntertempoClick)
  15.           self.btnRiparti=Button(self.radice, text='Riparti', command=self.btnRipartiClick)
  16.           self.labTempo.grid(column=0, row=0)
  17.           self.btnStart.grid(column=0, row=1)
  18.           self.btnRiparti.grid(column=1, row=1)
  19.           self.btnStop.grid(column=2, row=1)
  20.           self.btnIntertempo.grid(column=3, row=1)
  21.           self.boxIntertempi.grid(column=0, row=2)
  22.           self.radice.title('Cronometro')
  23.          
  24.  
  25.      def aggiornaTempo(self):
  26.           """Aggiorna il tempo"""
  27.           if self.crono.attivo:
  28.                self.labTempo["text"]=(str(self.crono))
  29.                self.radice.after(100, self.aggiornaTempo)
  30.  
  31.      def BtnstartClick(self):
  32.           """Evento pressione comando"""
  33.           if self.crono.attivo:
  34.                self.boxIntertempi["text"]="%s\n%s ripartenza" %(self.boxIntertempi["text"], str(self.crono))
  35.           self.crono.avvia()
  36.           self.aggiornaTempo()
  37.  
  38.      def btnstopClick(self):
  39.           """Arresta il cronometraggio"""
  40.           if self.crono.attivo:
  41.                self.boxIntertempi["text"]="%s\n%s arresto" %(self.boxIntertempi["text"], self.labTempo["text"])
  42.                self.crono.ferma()
  43.  
  44.      def btnIntertempoClick(self):
  45.           """Intertempo"""
  46.           if self.crono.attivo:
  47.                self.boxIntertempi["text"]+="\n%s intertempo" %str(self.crono)
  48.  
  49.      def btnRipartiClick(self):
  50.           """Ripartenza"""
  51.           if not self.crono.attivo:
  52.                self.crono.riavvia()
  53.                self.aggiornaTempo()