py-clocks 25.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_clocks/__init__.py +0 -0
- py_clocks/py_clocks.py +130 -0
- py_clocks-25.0.0.dist-info/METADATA +66 -0
- py_clocks-25.0.0.dist-info/RECORD +5 -0
- py_clocks-25.0.0.dist-info/WHEEL +4 -0
py_clocks/__init__.py
ADDED
|
File without changes
|
py_clocks/py_clocks.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import customtkinter as ctk
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
import pytz
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PyClocks:
|
|
10
|
+
"""
|
|
11
|
+
A class that encapsulates the clock application logic and individual clock widgets.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
# Constants for the application
|
|
15
|
+
WINDOW_WIDTH = 220
|
|
16
|
+
WINDOW_HEIGHT = 420
|
|
17
|
+
CLOCK_PADDING = 10
|
|
18
|
+
WINDOW_BOTTOM_HEIGHT_OFFSET = 100
|
|
19
|
+
WINDOW_BOTTOM_WIDTH_OFFSET = 15
|
|
20
|
+
WINDOW_TRANSPARENCY = 1.0
|
|
21
|
+
|
|
22
|
+
# Constants for clock widgets
|
|
23
|
+
TITLE_FONT = ("Arial", 20)
|
|
24
|
+
TIME_FONT = ("Arial", 14)
|
|
25
|
+
UPDATE_INTERVAL = 1000
|
|
26
|
+
INVALID_TIMEZONE_MSG = "Invalid Timezone"
|
|
27
|
+
GENERIC_ERROR_MSG = "Error"
|
|
28
|
+
|
|
29
|
+
def __init__(self):
|
|
30
|
+
"""
|
|
31
|
+
Initializes the PyClocks application.
|
|
32
|
+
"""
|
|
33
|
+
self.root = ctk.CTk()
|
|
34
|
+
logging.info("PyClocks application initialized.")
|
|
35
|
+
|
|
36
|
+
def configure_window(self):
|
|
37
|
+
"""
|
|
38
|
+
Configures the main application window and positions it at the bottom-right corner of the screen.
|
|
39
|
+
"""
|
|
40
|
+
self.root.title("py_clocks")
|
|
41
|
+
self.root.attributes("-alpha", self.WINDOW_TRANSPARENCY)
|
|
42
|
+
|
|
43
|
+
screen_width = self.root.winfo_screenwidth()
|
|
44
|
+
screen_height = self.root.winfo_screenheight()
|
|
45
|
+
x = screen_width - self.WINDOW_WIDTH - self.WINDOW_BOTTOM_WIDTH_OFFSET
|
|
46
|
+
y = screen_height - self.WINDOW_HEIGHT - self.WINDOW_BOTTOM_HEIGHT_OFFSET
|
|
47
|
+
self.root.geometry(f"{self.WINDOW_WIDTH}x{self.WINDOW_HEIGHT}+{x}+{y}")
|
|
48
|
+
logging.info("Main application window configured.")
|
|
49
|
+
|
|
50
|
+
def add_clock_widget(self, timezone, label_text, bg_color, text_color):
|
|
51
|
+
"""
|
|
52
|
+
Adds a clock widget to the application window.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
timezone (str): The timezone for the clock.
|
|
56
|
+
label_text (str): The label text displayed above the clock.
|
|
57
|
+
bg_color (str): The background color of the widget.
|
|
58
|
+
text_color (str): The text color for the labels.
|
|
59
|
+
"""
|
|
60
|
+
frame = ctk.CTkFrame(self.root, fg_color=bg_color)
|
|
61
|
+
frame.pack(padx=20, pady=self.CLOCK_PADDING)
|
|
62
|
+
|
|
63
|
+
ctk.CTkLabel(frame, text=label_text, font=self.TITLE_FONT, text_color=text_color).pack(pady=(10, 5))
|
|
64
|
+
time_label = ctk.CTkLabel(frame, text="", font=self.TIME_FONT, text_color=text_color)
|
|
65
|
+
time_label.pack(padx=20, pady=(10, 0))
|
|
66
|
+
date_label = ctk.CTkLabel(frame, text="", font=("Arial", 12), text_color=text_color)
|
|
67
|
+
date_label.pack(padx=20, pady=(0, 10))
|
|
68
|
+
|
|
69
|
+
self.start_clock_update(time_label, date_label, timezone, label_text)
|
|
70
|
+
logging.info(f"Clock widget added for timezone: {timezone} ({label_text}).")
|
|
71
|
+
|
|
72
|
+
def start_clock_update(self, time_label, date_label, timezone, label_text):
|
|
73
|
+
"""
|
|
74
|
+
Starts the periodic update of the clock display.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
time_label (CTkLabel): The label to update with the current time.
|
|
78
|
+
date_label (CTkLabel): The label to update with the current date.
|
|
79
|
+
timezone (str): The timezone for the clock.
|
|
80
|
+
label_text (str): The label text for logging purposes.
|
|
81
|
+
"""
|
|
82
|
+
def update_clock():
|
|
83
|
+
try:
|
|
84
|
+
tz = pytz.timezone(timezone)
|
|
85
|
+
now = datetime.now(tz)
|
|
86
|
+
current_time = now.strftime("%I:%M:%S %p")
|
|
87
|
+
iso_week = f"CW {now.isocalendar()[1]}"
|
|
88
|
+
time_label.configure(text=f"{current_time} ({iso_week})")
|
|
89
|
+
date_str = now.strftime("%A, %Y-%m-%d")
|
|
90
|
+
date_label.configure(text=date_str)
|
|
91
|
+
except pytz.UnknownTimeZoneError:
|
|
92
|
+
time_label.configure(text=self.INVALID_TIMEZONE_MSG)
|
|
93
|
+
date_label.configure(text="")
|
|
94
|
+
logging.error(f"Unknown timezone: {timezone} for {label_text}.")
|
|
95
|
+
except Exception as e:
|
|
96
|
+
time_label.configure(text=self.GENERIC_ERROR_MSG)
|
|
97
|
+
date_label.configure(text="")
|
|
98
|
+
logging.error(f"Error updating clock for {label_text}: {e}")
|
|
99
|
+
self.root.after(self.UPDATE_INTERVAL, update_clock)
|
|
100
|
+
|
|
101
|
+
update_clock()
|
|
102
|
+
|
|
103
|
+
def run(self):
|
|
104
|
+
"""
|
|
105
|
+
Runs the PyClocks application by creating the main window and adding clock widgets for specified timezones.
|
|
106
|
+
"""
|
|
107
|
+
self.configure_window()
|
|
108
|
+
|
|
109
|
+
# Time zones and their configurations
|
|
110
|
+
time_zones = [
|
|
111
|
+
{"timezone": "Asia/Tokyo", "label": "Japan 🏯", "bg_color": "#FFE5CC", "text_color": "#FF8000"},
|
|
112
|
+
{"timezone": "Asia/Kolkata", "label": "India 🌴", "bg_color": "#CCFFCC", "text_color": "#008000"},
|
|
113
|
+
{"timezone": "Europe/Berlin", "label": "Germany 🚘", "bg_color": "#CCCCFF", "text_color": "#0000FF"},
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
for config in time_zones:
|
|
117
|
+
self.add_clock_widget(
|
|
118
|
+
timezone=config["timezone"],
|
|
119
|
+
label_text=config["label"],
|
|
120
|
+
bg_color=config["bg_color"],
|
|
121
|
+
text_color=config["text_color"],
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
logging.info("Starting the PyClocks application.")
|
|
125
|
+
self.root.mainloop()
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
app = PyClocks()
|
|
130
|
+
app.run()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: py-clocks
|
|
3
|
+
Version: 25.0.0
|
|
4
|
+
Summary: The py_clocks package is a Python-based project designed for displaying multiple timezone clocks in windows desktop.
|
|
5
|
+
Keywords: python,clocks,timezone,desktop
|
|
6
|
+
Author: chaitu-ycr
|
|
7
|
+
Author-email: chaitu-ycr <chaitu.ycr@gmail.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 chaitu-ycr
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
Classifier: Programming Language :: Python :: 3
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
32
|
+
Requires-Dist: customtkinter
|
|
33
|
+
Requires-Dist: pyinstaller
|
|
34
|
+
Requires-Dist: pytz
|
|
35
|
+
Requires-Python: >=3.10, <=3.14
|
|
36
|
+
Project-URL: documentation, https://chaitu-ycr.github.io/automotive-test-kit/packages/py_clocks
|
|
37
|
+
Project-URL: homepage, https://github.com/chaitu-ycr/automotive-test-kit
|
|
38
|
+
Project-URL: repository, https://github.com/chaitu-ycr/automotive-test-kit
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# py_clocks
|
|
42
|
+
|
|
43
|
+
The `py_clocks` package is a Python-based project designed for displaying multiple timezone clocks on a Windows desktop.
|
|
44
|
+
|
|
45
|
+
By default, the app shows the time in the following timezones:
|
|
46
|
+
- **Asia/Tokyo**
|
|
47
|
+
- **Asia/Kolkata**
|
|
48
|
+
- **Europe/Berlin**
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
*Screenshot of the `py_clocks` application showing multiple timezone clocks.*
|
|
53
|
+
|
|
54
|
+
## Building and Running the Project
|
|
55
|
+
|
|
56
|
+
```.venv/Scripts/python.exe packages/py_clocks/src/py_clocks/py_clocks.py```
|
|
57
|
+
|
|
58
|
+
## Creating an Executable
|
|
59
|
+
|
|
60
|
+
To create a standalone executable for the `py_clocks` package using PyInstaller, use the provided script:
|
|
61
|
+
|
|
62
|
+
```pyinstaller --onefile packages/py_clocks/src/py_clocks/py_clocks.py```
|
|
63
|
+
|
|
64
|
+
**Locate the executable**: The generated executable will be located in the `dist` directory as `py_clocks.exe`.
|
|
65
|
+
|
|
66
|
+
## [source manual](https://chaitu-ycr.github.io/automotive-test-kit/packages/py_clocks/#source-manual)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
py_clocks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
py_clocks/py_clocks.py,sha256=4LFxgVlk9fadMNO4oH_MqLrI5nsvNF0_VdSEAUp9-0Q,5259
|
|
3
|
+
py_clocks-25.0.0.dist-info/WHEEL,sha256=5h_Q-_6zWQhhADpsAD_Xpw7gFbCRK5WjOOEq0nB806Q,79
|
|
4
|
+
py_clocks-25.0.0.dist-info/METADATA,sha256=MKCHbr2mG7J4iUjLUzBLdjHHDVrRUfLqj83oCOn6mZA,3041
|
|
5
|
+
py_clocks-25.0.0.dist-info/RECORD,,
|