0% found this document useful (0 votes)
44 views

Python Report Final

The document describes a stopwatch application created using Tkinter in Python. It provides details on the key features and working of the application, including time display, start/stop/reset functionality, and the underlying code implementation.

Uploaded by

desaikrish713
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Python Report Final

The document describes a stopwatch application created using Tkinter in Python. It provides details on the key features and working of the application, including time display, start/stop/reset functionality, and the underlying code implementation.

Uploaded by

desaikrish713
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

A

PROJECT REPORT
ON
MINI PROJECT
ENTITLED

“Stop-watch”
SUBMITTED BY
Desai krish T. (226090307020)
Khatsuriya bhavya B. (226090307056)

To
COMPUTER ENGINEERING DEPARTMENT
C U SHAH GOVT. POLYTECHNIC –SURENDRANAGAR

GUJARAT TECHNOLOGY UNIVERSITY AHMEDABAD DECEMBER – 2023


C.U.SHAH GOVERNMENT POLYTECHNIC - WADHWAN
COMPUTER ENGINEERING

CERTIFICATE
This is to certify that the Mini Project entitled “______________________________” has been

carried out by ____________________________________. under my guidance in partial fulfillment of the

degree of Diploma Engineering in COMPUTER ENGINEERING 2nd Semester of Gujarat Technological

University, Ahmedabad during the academic year 2023

Guides:

Ms. B.B.Goswami/Mr.N.V.Limbad Mr. K.G.Patel


Internal Guide Head of Department
C.U.SHAH GOVERNMENT POLYTECHNIC - WADHWAN
COMPUTER ENGINEERING

CERTIFICATE
This is to certify that the Mini Project entitled “______________________________” has been

carried out by ____________________________________. under my guidance in partial fulfillment of the

degree of Diploma Engineering in COMPUTER ENGINEERING 2nd Semester of Gujarat Technological

University, Ahmedabad during the academic year 2023

Guides:

Ms. B.B.Goswami/Mr.N.V.Limbad Mr. K.G.Patel


Internal Guide Head of Department
Introduction to Project

Hello, its desai krish and bhavya khatsuriya . it is project of stop watch. This is a simple
stopwatch application with a graphical user interface (GUI) implemented using the
Tkinter library. The primary purpose of the program is to create a functional
stopwatch that displays elapsed time in hours, minutes, and seconds. Users can interact
with the stopwatch through buttons to start, stop, and reset the timer.

Key Features:

Time Display:
The stopwatch utilizes a label to display the elapsed time in HH:MM:SS format.
The time is dynamically updated every second, providing accurate and real-time
information.

Start, Stop, and Reset Functionality:

The program offers three main functionalities through buttons: Start, Stop, and Reset.
The "Start" button initiates the stopwatch, enabling the continuous update of the
elapsed time.
The "Stop" button pauses the stopwatch, freezing the displayed time.
The "Reset" button resets the stopwatch to its initial state, ready

User Interface:
The GUI is created using the Tkinter library, providing a simple and intuitive
interface.
The window is fixed in size to maintain a clean and compact design.
Working of Project:

1. Initialization:

• The program starts by importing the necessary


libraries, including Tkinter for the GUI and datetime
for time-related operations.
• Initial values are set, such as the starting time
(counter = 66600) and the running state (running =
False).

2. Counter Label Function:

• The counter_label function is responsible for


updating the display label with the elapsed time.
• Inside this function, a nested count function is
defined.
• The count function checks if the stopwatch is
running. If yes, it updates the label with the elapsed
time formatted as HH:MM:SS.
• The label is updated every second using the
label.after(1000, count) method.

3. Start Function:

• The Start function is called when the "Start" button


is pressed.
• It sets the running flag to True, enabling the
continuous update of the label.
• The "Start" button is disabled, and the "Stop" and
"Reset" buttons are enabled.

4. Stop Function:

• The Stop function is triggered when the "Stop"


button is pressed.
• It sets the running flag to False, pausing the
continuous update of the label.
• The "Stop" button is disabled, and the "Start" and
"Reset" buttons are enabled.
5. Reset Function:

• The Reset function is called when the "Reset" button


is pressed.
• It resets the counter to the initial value and updates
the label accordingly.
• If the stopwatch is not running, the "Reset" button is
disabled, and the label text is set to "Welcome!".
• If the stopwatch is running, the label text is set to
"Starting...".

6. GUI Setup:

• The Tkinter GUI window is created with a fixed size.


• A label is used to display the elapsed time, and three
buttons ("Start," "Stop," and "Reset") are included
in a frame.
• Button states are managed to control user
interactions.

7. Main Event Loop:

• The program enters the Tkinter main event loop


(root.mainloop()), where it waits for user interactions
and updates the GUI accordingly.
Code of project

# Python program to illustrate a stop watch


# using Tkinter
#importing the required libraries
import tkinter as Tkinter
from datetime import datetime
counter = 66600
running = False
def counter_label(label):
def count():
if running:
global counter

# To manage the initial delay.


if counter==66600:
display="Starting..."
else:
tt = datetime.fromtimestamp(counter)
string = tt.strftime("%H:%M:%S")
display=string

label['text']=display # Or label.config(text=display)

# label.after(arg1, arg2) delays by


# first argument given in milliseconds
# and then calls the function given as second argument.
# Generally like here we need to call the
# function in which it is present repeatedly.
# Delays by 1000ms=1 seconds and call count again.
label.after(1000, count)
counter += 1

# Triggering the start of the counter.


count()

# start function of the stopwatch


def Start(label):
global running
running=True
counter_label(label)
start['state']='disabled'
stop['state']='normal'
reset['state']='normal'

# Stop function of the stopwatch


def Stop():
global running
start['state']='normal'
stop['state']='disabled'
reset['state']='normal'
running = False
# Reset function of the stopwatch
def Reset(label):
global counter
counter=66600

# If rest is pressed after pressing stop.


if running==False:
reset['state']='disabled'
label['text']='Welcome!'

# If reset is pressed while the stopwatch is running.


else:
label['text']='Starting...'

root = Tkinter.Tk()
root.title("Stopwatch")

# Fixing the window size.


root.minsize(width=250, height=70)
label = Tkinter.Label(root, text="Welcome!", fg="black", font="Verdana 30 bold")
label.pack()
f = Tkinter.Frame(root)
start = Tkinter.Button(f, text='Start', width=6, command=lambda:Start(label))
stop = Tkinter.Button(f, text='Stop',width=6,state='disabled', command=Stop)
reset = Tkinter.Button(f, text='Reset',width=6, state='disabled',
command=lambda:Reset(label))
f.pack(anchor = 'center',pady=5)
start.pack(side="left")
stop.pack(side ="left")
reset.pack(side="left")
Screenshots

You might also like