Skip to content

archismanbiswas307-lab/Digital-Clock-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Digital Clock

A stylish digital clock application built with Python and PyQt6. Displays the current time in real-time with a sleek green-on-black design.

Features

  • 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

Requirements

  • Python 3.7 or higher
  • PyQt6
  • DS-DIGIT.TTF font file

Installation

1. Clone or download this project

git clone <repository-url>
cd Digital\ Clock

2. Install dependencies

pip install PyQt6

3. Ensure the font file is present

Make 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.

Usage

Run the application with:

python main.py

The clock window will appear and automatically start displaying the current time, updating every second.

Project Structure

Digital Clock/
├── main.py          # Main application file
├── DS-DIGIT.TTF     # Digital clock font file (required)
└── README.md        # This file

Code Overview

Classes

DigitalClock: Main application class that extends QWidget

  • __init__(): Initializes the clock widget and components
  • initUI(): Sets up the user interface, styling, and timer
  • update_time(): Updates the displayed time every second

Key Components

  • 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

Customization

Change Display Format

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

Adjust Window Size

Modify the setGeometry() parameters in initUI():

self.setGeometry(x, y, width, height)

Change Colors

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

Dependencies

  • PyQt6: Python binding for the Qt application framework
  • DS-DIGIT.TTF: Digital clock font (must be included)

License

This project is open source and available for educational and personal use.

Contributing

Contributions are welcome! Feel free to fork this project and submit pull requests for improvements.


Author: Digital Clock Project
Last Updated: April 22, 2026

About

A digital clock coded entirely coded in python , A beginners project to enhance their coding journey in python

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages