Giter Site home page Giter Site logo

shabir-mp / date-and-time Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 8 KB

This project is a simple graphical user interface (GUI) application that displays the current date and time using Python's tkinter library. The time updates every second and this application has a clean and easy to view appearance.

License: MIT License

Python 100.00%
clock-app clock-application date-and-time simple-gui simple-project time-app tkinter tkinter-app

date-and-time's Introduction

Date and Time App v1.0.0

This project is a simple graphical user interface (GUI) application that displays the current date and time using Python's tkinter library. The time updates every second and this application has a clean and easy to view appearance.

About

made-with-python GitHub license

  • Developer: Shabir Mahfudz Prahono - @shabir-mp
  • Application creation date: 16 June 2024

Features

  • Real-Time Clock: The application updates the time every second.
  • Current Date Display: The application displays the current date.
  • Neat appearance: Neat and tidy application appearance.

Preview

This is a preview of the date and time application by Shabir Mahfudz Prahono

Requirements

  • Python 3.x
  • tkinter library (usually included with Python)
  • Pillow library for handling images

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/your-repo-name.git
  2. Navigate to the project directory:
    cd your-repo-name
  3. Install the required packages:
    pip install Pillow

Usage

  1. Place your icon image: Ensure you have an icon image named icon.png in the same directory as the script. This image will be used as the window icon.

  2. Run the script:

    python your_script_name.py

    Replace your_script_name.py with the name of your Python script file.

Code Explanation

The main components of the script are:

  1. Imports:

    • tkinter for creating the GUI.
    • datetime for getting the current date and time.
    • PIL (Pillow) for handling images.
    import tkinter as tk
    from datetime import datetime
    from PIL import Image, ImageTk
  2. Update Time Function:

    • This function gets the current date and time and updates the labels.
    • It also schedules itself to run again after 1 second (1000 milliseconds).
    def update_time():
        current_time = datetime.now().strftime('%H:%M:%S')
        current_date = datetime.now().strftime('%Y-%m-%d')
        time_label.config(text=current_time)
        date_label.config(text=current_date)
        root.after(1000, update_time)
  3. Creating the Main Window:

    • Initializes the main window.
    • Sets the window title, size, and icon.
    root = tk.Tk()
    root.title("Date and Time")
    root.geometry("600x250")
    image = Image.open('icon.png') 
    icon = ImageTk.PhotoImage(image)
    root.iconphoto(False, icon)
  4. Labels for Time and Date:

    • Creates and packs the labels for displaying the time and date.
    label = tk.Label(root, bg='white')
    label.pack()
    time_label = tk.Label(label, font=('Kanit', 80), fg='black', bg='white')
    time_label.pack(pady=20)
    date_label = tk.Label(label, font=('Kanit', 24), fg='black', bg='white')
    date_label.pack(pady=0)
  5. Initial Update and Main Loop:

    • Calls the update_time function to start the update cycle.
    • Starts the main loop of the tkinter window.
    root.configure(bg='white')
    update_time()
    root.mainloop()

Customization

  • Change Font: You can change the font and size of the time and date labels by modifying the font parameter in the tk.Label definitions.
  • Change Colors: You can change the foreground and background colors by modifying the fg and bg parameters in the tk.Label definitions.
  • Window Size: You can adjust the window size by modifying the root.geometry("600x250") line.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


Github Footer

date-and-time's People

Contributors

shabir-mp avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.