Arthur-101 / CTkClock

Tkinter and CTkinter Clock Widget . (My first Module)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CTkClock

A Library for CLock widget in Tkinter and CTkinter.

Installation

Since this Library is not yet ready, it's not published yet.
Download the folder and put it inside this directory to use:

c:\users\me\appdata\local\programs\python\python38\lib\site-packages

AnalogCLock

Usage:

Example 1:

from tkinter import *
from CTkClock import *

root = Tk()
root.title('Tkinter example')

clock = AnalogClock(root, radius = 150,)
clock.pack()

root.mainloop()

Example 1

Example 2:

from customtkinter import *
from CTkClock import *

root = CTk()
root.title('Custom Tkinter Example')
set_appearance_mode("dark")

clock = AnalogClock(root, radius = 150, font_color = "white", font=("Fira Code", 15, "bold"),
                    border_width=5, second_hand_width=3, minute_hand_width=5, hour_hand_width=7, 
                    hour_color='white', minute_color='white', start_time='05:15:49')
clock.pack()

root.mainloop()

Example 2

Example 3:

from customtkinter import *
from CTkClock import *

root = CTk()
root.geometry("800x700")
root.title('Custom Tkinter Example')

clock = AnalogClock(root, radius = 160, font_color = "black", font=("Fira Code", 15, "bold"),
                    border_width=5, second_hand_width=4, minute_hand_width=6, hour_hand_width=8, )
clock.place(relx=0.05, rely=0.05,)

clock = AnalogClock(root, radius = 150, font_color = "black", font=("Fira Code", 15, "bold"), border_color='#008000',
                    border_width=5, second_hand_width=4, minute_hand_width=6, hour_hand_width=8,
                    hour_color="red", minute_color="purple", second_color="green", 
                    start_time='03:45:55', shape='rectangle', )
clock.place(relx=0.55, rely=0.05,)

clock = AnalogClock(root, radius = 150, font_color = "black", font=("Fira Code", 15, "bold"),
                    border_width=5, fg_color='#d3d3d3', 
                    quarter_hour=True,)
clock.place(relx=0.05, rely=0.55,)

clock = AnalogClock(root, radius = 150, font_color = "black", font=("Fira Code", 15, "bold"),
                    border_width=5, fg_color='#d3d3d3', 
                    quarter_hour=True, quarter_symbol='*', )
clock.place(relx=0.55, rely=0.55,)

root.mainloop()

Example 3

Arguments:

Parameters Description
master widget or window where the clock will be placed.
radius (int): Radius of the clock in pixels.
shape (str): The shape of the clock face, either 'circle' or 'rectangle'. Default: 'circle'
border_width (int): Width of the clock border.
border_color (str): The color of the border.
clock_face_style (str): The style of clock face. Either 'Digit' or 'Roman' or 'Tick' or 'NONE'. Default: 'digit'
fg_color (str): The foreground color of the clock face or 'transparent' to match the parent's background. Default: 'transparent'
bg_color (str): The background color of the clock face or 'transparent' to match the parent's background. Default: 'transparent'
font (Tuple[str, int, str]): Font specifications for the clock numbers.
font_color (str): The color of the clock numbers.
hour_color (str): The color of the hour hand.
minute_color (str): The color of the minute hand.
second_color (str): The color of the second hand.
hour_hand_width (int): The width of the hour hand.
minute_hand_width (int): The width of the minute hand.
second_hand_width (int): The width of the second hand.
start_time (Optional[str]): The initial time in the format 'HH:MM:SS'.
quarter_hour (bool): If True, display only 3, 6, 9, 12 and optional quarter symbols.
quarter_symbol (Optional[str]): Symbol to be displayed instead of numbers not divisible by 3.
quarter_symbol_color (Optional[str]): Color of the quarter symbols.

Methods:

Methods Description
.get_current_time() Get the current time of the clock as a datetime object.
.get_current_strftime(format_string="%H:%M:%S") Get the current time of the clock as a formatted string.
.configure() To configure some options of the clock.