Jun-20-2019, 09:40 AM
Hello everbody,
please help me to solve one issue with my tkinter clock. Time is imported from my cpu but sometimes I need to shift few seconds down or up, so I created buttons with command functions, the problem is that i don“t know how to set the def or those buttons properly (with print function, or transfor string to int and back?), Thanks for any advice. Bellow you can see code:
please help me to solve one issue with my tkinter clock. Time is imported from my cpu but sometimes I need to shift few seconds down or up, so I created buttons with command functions, the problem is that i don“t know how to set the def or those buttons properly (with print function, or transfor string to int and back?), Thanks for any advice. Bellow you can see code:
import sys, random from tkinter import * from tkinter import ttk import time def tick(): time_string=time.strftime('%H:%M:%S') clock.config(text=time_string) clock.after(200,tick) root=Tk() def callback(): time_string=time.strftime(chr('%H:%M:%S')) button1=ttk.Button(root, text="Add a second", command=callback) def call(): print("down") button2=ttk.Button(root, text="Remove a sec", command=call) clock=Label(root, font=("times", 120, "bold"), bg="green") button1.grid(row=1, column=1) button2.grid(row=2, column=1) clock.grid(row=0, column=1) tick() root.mainloop()