Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = "paulogp"
- from tkinter import Tk, Frame, BOTH, Button, Label, StringVar, messagebox
- class Master(Frame):
- def __init__(self, parent):
- """
- Configurações gerais
- :param parent:
- :return:
- """
- frame = Frame.__init__(self, parent, width=510, height=330)
- self.parent = parent
- self.parent.title("4 COUNTDOWN")
- self.pack(fill=BOTH, expand=1)
- # máquina 1
- self.time_str_a = StringVar()
- self.time_str_a.set("00:00")
- self.aux_a = 120
- self.label_count_a = Label(self, textvariable=self.time_str_a, font=("helvetica", 40))
- self.label_count_a.place(x=93, y=20)
- self.timer_a = Button(self, text="Máquina 1", command=self.count_down_a)
- self.timer_a.place(x=127, y=90)
- # máquina 3
- self.time_str_b = StringVar()
- self.time_str_b.set("00:00")
- self.aux_b = 120
- self.label_count_b = Label(self, textvariable=self.time_str_b, font=("helvetica", 40))
- self.label_count_b.place(x=290, y=20)
- self.timer_b = Button(self, text="Máquina 3", command=self.count_down_b)
- self.timer_b.place(x=325, y=90)
- # máquina 2
- self.time_str_c = StringVar()
- self.time_str_c.set("00:00")
- self.aux_c = 120
- self.label_count_c = Label(self, textvariable=self.time_str_c, font=("helvetica", 40))
- self.label_count_c.place(x=93, y=180)
- self.timer_c = Button(self, text="Máquina 2", command=self.count_down_c)
- self.timer_c.place(x=127, y=250)
- # máquina 4
- self.time_str_d = StringVar()
- self.time_str_d.set("00:00")
- self.aux_d = 120
- self.label_count_d = Label(self, textvariable=self.time_str_d, font=("helvetica", 40))
- self.label_count_d.place(x=290, y=180)
- self.timer_d = Button(self, text="Máquina 4", command=self.count_down_d)
- self.timer_d.place(x=325, y=250)
- # acerca de...
- self.aboutButton = Button(self, text=" ? ", command=self.about)
- self.aboutButton.place(x=5, y=5)
- def count_down_a(self):
- """
- Máquina 1 - Contagem decrescente.
- :return:
- """
- self.timer_a.config(state="disabled")
- if self.aux_a == 0:
- self.timer_a.config(state="active")
- self.aux_a = 120
- else:
- self.aux_a -= 1
- sf = "{:02d}:{:02d}".format(*divmod(self.aux_a, 60))
- self.time_str_a.set(sf)
- self.parent.after(1000, self.count_down_a)
- def count_down_b(self):
- """
- Máquina 3 - Contagem decrescente.
- :return:
- """
- self.timer_b.config(state="disabled")
- if self.aux_b == 0:
- self.timer_b.config(state="active")
- self.aux_b = 120
- else:
- self.aux_b -= 1
- sf = "{:02d}:{:02d}".format(*divmod(self.aux_b, 60))
- self.time_str_b.set(sf)
- self.parent.after(1000, self.count_down_b)
- def count_down_c(self):
- """
- Máquina 2 - Contagem decrescente.
- :return:
- """
- self.timer_c.config(state="disabled")
- if self.aux_c == 0:
- self.timer_c.config(state="active")
- self.aux_c = 120
- else:
- self.aux_c -= 1
- sf = "{:02d}:{:02d}".format(*divmod(self.aux_c, 60))
- self.time_str_c.set(sf)
- self.parent.after(1000, self.count_down_c)
- def count_down_d(self):
- """
- Máquina 4 - Contagem decrescente.
- :return:
- """
- self.timer_d.config(state="disabled")
- if self.aux_d == 0:
- self.timer_d.config(state="active")
- self.aux_d = 120
- else:
- self.aux_d -= 1
- sf = "{:02d}:{:02d}".format(*divmod(self.aux_d, 60))
- self.time_str_d.set(sf)
- self.parent.after(1000, self.count_down_d)
- def about(self):
- """
- Dialogo com informação do responsável.
- :return:
- """
- messagebox.showwarning("About", "Paulo G.P., 2015.")
- if __name__ == "__main__":
- root = Tk()
- app = Master(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement