This Python program creates a digital clock GUI with a toggle button to switch between day and night modes. Built using the tkinter library, the clock displays the current time and allows users to switch themes seamlessly.
- Digital Clock Display: The main display shows the current time in a large, easy-to-read font.
- Day/Night Theme Toggle: A button allows the user to switch between light (day) and dark (night) themes.
- Automatic Time Update: The clock updates every second to keep the displayed time accurate.
-
Imports:
time: Used for retrieving the current time.os: Used for file path handling.tkinter: The GUI library for creating the clock display and toggle button.
-
Main Window Setup:
- Creates a
Tkwindow titledClockwith a unique icon (digital-clock.png). - Sets the initial background to light mode with a light purple color (
#9381FF).
- Creates a
-
Clock Label:
- The time display is a large label (
Lbel) with custom fonts and colors, updated every 100 milliseconds.
- The time display is a large label (
-
Theme Toggle:
- A
Buttonwidget (switch) allows switching between day (light) and night (dark) modes. - Clicking the button updates the background color and button icon based on the
switch_value(True for light mode, False for dark mode).
- A
-
Ensure the following images are in an
imgfolder within the working directory:digital-clock.png: Clock iconsun(1).png: Icon for light modesun(3).png: Icon for dark mode
-
Run the script. The digital clock will appear with the current time and an icon in the top left for theme toggling.
-
Click the icon to switch between day and night themes.
python digital_clock.pyconvert to programme laptop
1-pip3 install PyInstaller
2-pyinstaller -w app.py
# or
pyinstaller --windowed app.py
# or
pyinstaller --noconsole app.py
or
pyinstaller --onefile -w l.py```

