0% found this document useful (0 votes)
97 views14 pages

Python Sample

document
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)
97 views14 pages

Python Sample

document
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/ 14

Project Name:-

Create Stopwatch
The project that we deployed in the period of
our industrial training is ‘Create Stopwatch’
We create python ‘Stopwatch’ by using Tkinter
module in our project.
Aim of the Project:
A stopwatch is a handheld timepiece designed
to measure the amount of time elapsed from a
particular time when it is activated to the time when
the piece is deactivated.
Objective:-

1. First download python3.11 version.


2. Open IDLE and Create new File.
3. Write python code for create python
stopwatch.
4. Run the code & Display the result.
Advantages:

•A stopwatch is useful to measure the exact time


elapsed and also starting and ending of any time
duration.
•A stopwatch can provide greater accuracy than
a conventional clock.
Disadvantages:
•It requires a lot of observations to measure the
time accurately.
•Variation in task leads to separate measures
through stopwatch and it is remeasured.
•Human error occurs every time a stopwatch is
used.
What is tkinter?
 Python provides the standard library Tkinter(Tk
interface) for creating the graphical user interface for
desktop based applications.

 Developing desktop based applications with python


Tkinter is not a complex task. An empty Tkinter top-level
window can be created by using the following steps.
1.Importing the required libraries:
•Tkinter: Used for creating the GUI.
•datetime: Used for formatting the stopwatch time.
2.Initializing variables:
•counter: Holds the number of seconds elapsed
since the stopwatch started.
•running: Tracks whether the stopwatch is running
or paused.
3.counter_label function:
•Updates the stopwatch display label with the current
time.
•The function is nested inside count() to allow recursive
calling using after().
4.count() function:
•Checks if the stopwatch is running.
•Formats the counter value into a string representing the
time (hours:minutes:seconds).
•Updates the label text with the formatted time.
•Uses after() to call count() after a delay of 1 second
(1000 milliseconds).
•Increments the counter value by 1.
5.Start function:
•Sets the running flag to True.
•Calls counter_label to start updating the label.
•Disables the Start button and enables the Stop
and Reset buttons.
6.Stop function:
•Sets the running flag to False.
•Enables the Start button and disables the Stop
button.
•Keeps the Reset button enabled.
7.Reset function:
•Resets the counter value to 66600, equivalent to 0 hours, 0
minutes, and 0 seconds.
•If the stopwatch is stopped, disables the Reset button and
updates the label to "Welcome!".
•If the stopwatch is running, updates the label to "Starting..."
without disabling the Reset button.
8.Creating the GUI window using Tkinter.
•Sets the window title to "Stopwatch".
•Sets the minimum window size.
•Creates a label widget to display the
stopwatch time.
•Creates a frame widget to hold the buttons.
•Creates Start, Stop, and Reset buttons
inside the frame.
•Packs the widgets to organize them within
the window.

9.Enters the main event loop (root.mainloop())


to handle user interactions and display the
window.
Output:-
Thank You.

You might also like