from Tkinter import * import datetime now_time = datetime.datetime.now() cur_hours = now_time.hour cur_minutes = now_time.minute cur_sec = now_time.second def write_in_file(): global cur_hours, cur_minutes, cur_sec f = open('text.txt', 'a') f.write(now_time.strftime("\nyou went in %H:%M:%S\n")) f.close() root = Tk() mainLabel = Label(root, text='STATISTICK', width=20, background='red', font=("Arial", 20, "bold")) butCheck = Button(root, width=30, height=2, text='Click me when you go', bg='brown') cur_Label = Label(root, bg='red', font=("Arial", 15)) cur_Label.configure(text="now " + now_time.strftime("%H:%M:%S")) mainLabel.grid(row=1, column=1) butCheck.bind("<Button-1>", write_in_file()) butCheck.grid(row=2, column=1) cur_Label.grid(row=3, column=1) root.bind("<Control-z>", exit) root.mainloop()
разложу по порядку, в файл оно пишет, но пишет только один раз за запуск приложения
как сделать время обновляемым?