Python Forum
[Tkinter] How to adjust time - tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How to adjust time - tkinter
#1
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:

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()
Reply


Messages In This Thread
How to adjust time - tkinter - by Ondrej - Jun-20-2019, 09:40 AM
RE: How to adjust time - tkinter - by Larz60+ - Jun-20-2019, 01:16 PM
RE: How to adjust time - tkinter - by Yoriz - Jun-20-2019, 05:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to stop time counter in Tkinter LoneStar 1 4,412 Sep-11-2020, 08:56 PM
Last Post: Yoriz
  [Tkinter] Treeview automatically adjust it's size when pack inside frame Prince_Bhatia 1 27,912 Jul-25-2018, 03:24 AM
Last Post: Larz60+
  set time & date by user in tkinter gray 3 18,951 Mar-20-2017, 04:00 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020