Code Monkey home page Code Monkey logo

python_clock's Introduction

python_Clock

1

'''
Creation of the Digital Clock in Python
'''
from tkinter import *
from tkinter.ttk import *

from time import strftime

main = Tk()

main.title('The Digital clock in Python')

def clock():
	tick = strftime('%H:%M:%S %p')

	clock_label .config(text =tick)

	clock_label .after(1000, clock)

clock_label = Label(main, font =('sans', 80), background = 'yellow', foreground = 'green')

clock_label.pack(anchor= 'center')

clock()
mainloop()

2


# importing the entire tkinter module
from tkinter import *
from tkinter.ttk import *

# to retrieve the system's time, you need to import the strftime function
from time import strftime

# creation of the tkinter window
main = Tk()
main.title('The digital clock in Python')

# This function displays the current time on the label defined herein
def displayTime():
	string = strftime('%H:%M:%S %p')
	clock_label.config(text = string)
	clock_label.after(1000, displayTime)


# creating an attractive look:  needs styling the label widget
clock_label = Label(main, font = ('calibri', 42, 'bold'),
			background = 'purple',
			foreground = 'white')

# defining how to place the digital clock at the centre tkinter's window
clock_label.pack(anchor = 'center')
displayTime()

mainloop()

3

# start by importing all the necessary libraries

from tkinter import *
import sys
import time #library to get the current time
 
#create a function displayTime and variable time_now
def displayTime():
    #show the current hour,minute,seconds
    time_now = time.strftime("%H : %M : %S")
    #clock configuration
    clock_label.config(text=time_now)
    #after every 200 microseconds the clock will change
    clock_label.after(200,displayTime)
 
#Creation of a variable responsible for storing the tkinter window
main=Tk()
#window size defined
main.geometry("720x420")

#First label - shows the time,
#Second label - shows hour:minute:second,
#Third label - shows the digital clock's title at the top
clock_label=Label(main,font=("times",72,"bold"),bg="yellow")
clock_label.grid(row=2,column=2,pady=25,padx=100)
displayTime()
 
#creation of a digital clock's variable
digital_clock_title=Label(main,text="The Digital Clock in Python",font="times 24 bold")
digital_clock_title.grid(row=0,column=2)
 
hours_mins_secs=Label(main,text="Hours        Minutes        Seconds",font="times 15 bold")
hours_mins_secs.grid(row=3,column=2)
 
main.mainloop()

python_clock's People

Contributors

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