A stylish digital clock application built with Python and PyQt6. Displays the current time in real-time with a sleek green-on-black design.
- Real-time Display: Updates every second to show the current time
- 12-Hour Format: Displays time in 12-hour format with AM/PM indicator (hh:mm:ss AP)
- Custom Font: Uses the DS-DIGIT font for an authentic digital clock appearance
- Dark Theme: Black background with bright green text for easy readability
- Responsive UI: Built with PyQt6 for cross-platform compatibility
- Python 3.7 or higher
- PyQt6
- DS-DIGIT.TTF font file
git clone <repository-url>
cd Digital\ Clockpip install PyQt6Make sure the DS-DIGIT.TTF font file is in the same directory as main.py. This file is required for the authentic digital clock font.
Run the application with:
python main.pyThe clock window will appear and automatically start displaying the current time, updating every second.
Digital Clock/
├── main.py # Main application file
├── DS-DIGIT.TTF # Digital clock font file (required)
└── README.md # This file
DigitalClock: Main application class that extends QWidget
__init__(): Initializes the clock widget and componentsinitUI(): Sets up the user interface, styling, and timerupdate_time(): Updates the displayed time every second
- QTimer: Updates the time every 1000ms (1 second)
- QLabel: Displays the formatted time
- QVBoxLayout: Layouts the label within the window
- QFont: Renders the custom DS-DIGIT font at 150px size
Modify the time format string in the update_time() method:
current_time = QTime.currentTime().toString("hh:mm:ss AP")Common formats:
"hh:mm:ss AP"- 12-hour with seconds (default)"hh:mm AP"- 12-hour without seconds"hh:mm:ss"- 24-hour with seconds
Modify the setGeometry() parameters in initUI():
self.setGeometry(x, y, width, height)Modify the stylesheet in initUI():
self.time_label.setStyleSheet("""
font-size:150px;
color:#17e34d; # Change this hex color
""")
self.setStyleSheet("background-color:black;") # Change background- PyQt6: Python binding for the Qt application framework
- DS-DIGIT.TTF: Digital clock font (must be included)
This project is open source and available for educational and personal use.
Contributions are welcome! Feel free to fork this project and submit pull requests for improvements.
Author: Digital Clock Project
Last Updated: April 22, 2026