Kivy Tutorial: How to create a Simple Timer in Kivy Python ~ For beginners #5 (Detailed Explanation)

Petrina Ropra
22 Nov 202129:12

Summary

TLDRIn this tutorial, Petrina continues her Simple Clock App series by adding a timer feature. She walks through the process of setting up a new 'Timer' tab, arranging the layout with labels, text inputs, and buttons, and adding functionality for starting, pausing, and resetting the timer. Along the way, Petrina demonstrates the use of regular expressions to validate user input and explains how the timer works with Python's datetime and timedelta modules. Despite not being a professional programmer, Petrina's approachable teaching style makes this tutorial accessible for beginners.

Takeaways

  • 😀 The video is part of a tutorial series on creating a simple clock app, focusing on adding a timer feature.
  • 🛠️ The presenter is not a professional programmer but is teaching herself to code and shares her learning process.
  • 📱 A tabbed panel item named 'timer' is added to the app, positioned between 'alarm' and 'world clock'.
  • 🔢 A text input is implemented for users to enter time in a specific format: 'hhmmss' for hours, minutes, and seconds.
  • 🎨 The text and font properties of the label and text input are customized, including setting the font size and style.
  • 🔧 Regular expressions (re module) are used to validate the input, ensuring only numbers are entered and no letters are included.
  • ⏲️ The 'timedelta' function from the 'datetime' library is utilized to calculate the countdown.
  • 🔄 Functions are created for 'start', 'reset', and 'pause' to control the timer's operation.
  • 🔔 A sound is played when the countdown reaches zero, and the user can choose a different sound file if desired.
  • 🔀 A 'toggle' function is implemented to switch between starting and resetting the timer with a single button.

Q & A

  • What is the main focus of this tutorial video?

    -The main focus of this tutorial video is to add a timer functionality to a simple clock app.

  • What are the prerequisite videos recommended by Petrina before starting this tutorial?

    -Petrina recommends watching parts one, two, three, and four of her simple clock app tutorial series before this part.

  • What is the first UI component Petrina adds to the app for the timer feature?

    -The first UI component Petrina adds is a tabbed panel item called 'tab timer', which is placed between the alarm and world clock.

  • What layout does Petrina use for the timer tab and what are its properties?

    -Petrina uses a BoxLayout for the timer tab, setting its orientation to vertical, padding to 20, and spacing to 20.

  • How does Petrina set up the label for the timer input?

    -Petrina sets up a label with the ID 'show', adds text instructing to 'enter the time to count down', and sets the font to 'gothic bold' with a size of 17.

  • What is the purpose of the text input field in the timer feature?

    -The text input field is for users to enter the time in a specific format (HHMMSS) for the countdown timer.

  • How does Petrina ensure that the timer input only contains numbers?

    -Petrina uses regular expressions (importing the 're' module) to check that the input contains only numbers and no letters or empty strings.

  • What Python module does Petrina use to handle time calculations?

    -Petrina uses the 'datetime' module, specifically the 'timedelta' function, to perform time calculations for the timer.

  • How does Petrina handle the button clicks for the timer?

    -Petrina creates functions for 'start', 'pause', and 'reset' which are linked to the button clicks, allowing the user to control the timer.

  • What is the purpose of the 'running' variable in the timer functionality?

    -The 'running' variable is used to track whether the timer is currently active, helping to control the start, pause, and reset functionalities.

  • How does Petrina handle the timer's countdown and what happens when it reaches zero?

    -Petrina uses a scheduled interval to continuously update the timer's countdown. When the countdown reaches zero, a sound is played, and the timer resets.

Outlines

00:00

🕒 Introduction to the Clock App Tutorial Series

Petrina introduces part five of her simple clock app tutorial series, focusing on adding a timer feature. She provides links to previous parts in the series and emphasizes that she is a self-taught coder. The tutorial begins with the addition of a tabbed panel item called 'tab timer' between the alarm and world clock features. A box layout with vertical orientation, padding, and spacing is set up, followed by the addition of a label with instructions on entering the countdown time in a specific format. The label's text is set to bold using the 'gothic bold' font, and the font size is set to 17.

05:01

🛠️ Setting Up the Timer Interface

Petrina continues by adding a text input field for users to enter the countdown time. She creates a class rule for the text input to set the font size and alignment. A 'button box layout' is then created to house the start and pause buttons, using a class rule for consistency. The tutorial moves into the Python file to adjust the width to accommodate the new tab. The timer interface is displayed, but the buttons are non-functional as they lack assigned functions.

10:02

💻 Implementing Timer Functionality

The tutorial delves into coding the timer's functionality. Petrina creates a 'running' variable and a 'start' function to handle the countdown. She checks the input for validity using regular expressions to ensure only numbers are entered. The 'timedelta' function from Python's datetime library is introduced to calculate the countdown by subtracting the entered time from the current time. Conditional statements are set up to handle various input scenarios, such as empty strings or invalid formats.

15:03

🔧 Further Development of Timer Logic

Petrina extracts hours, minutes, and seconds from the input and converts them into integers. She creates a 'delta' variable using the 'timedelta' function to calculate the countdown. The 'running' variable is used to control the timer's state. Functions for starting, pausing, and resetting the timer are outlined, with conditions to change button texts and manage the timer's state.

20:04

🎵 Adding Sound and Final Touches

The tutorial concludes with the addition of a sound to the timer's functionality. Petrina demonstrates how to load and play a sound file when the countdown reaches zero. She also shows how to reset the timer and adjust the display to show leading zeros for a cleaner look. The final steps involve assigning functions to the buttons in the KV file and testing the timer's functionality.

25:07

🎉 Completion and Testing of the Timer Feature

Petrina wraps up the tutorial by testing the timer feature, demonstrating the start, pause, and reset functionalities. She encourages viewers to learn from mistakes and iterate on their projects. The video ends with a thank you and a teaser for the next video in the series.

Mindmap

Keywords

💡Tabbed Panel Item

A 'Tabbed Panel Item' in the context of the video refers to a UI component that allows users to switch between different views or pages within an application by selecting from a set of tabs. In the video, the tutorial is about adding a 'tab timer' to a simple clock app, which is a feature that will be accessed through a new tab in the app's interface, placed between the 'alarm' and 'world clock' tabs.

💡Box Layout

In the script, 'Box Layout' is a layout manager used in the app's design, which organizes child widgets in a single direction, either vertically or horizontally. The tutorial describes setting up a 'Box Layout' with vertical orientation and specific padding and spacing to hold the timer's components, demonstrating how to structure the user interface in a logical and visually appealing manner.

💡Label

A 'Label' in the video is a UI element used to display text. The script mentions creating a label with the ID 'show' and setting its text to instruct users on how to input time for the countdown timer. This label serves as a guide for users, indicating where they should enter the time in the correct format.

💡Text Input

In the context of the video, 'Text Input' is a UI component that allows users to enter text, such as numbers representing time. The tutorial includes adding a text input field where users can input the time for the countdown timer, emphasizing the importance of user interaction in app design.

💡Class Rule

A 'Class Rule' in the video refers to a styling rule defined in the app's styling language, which is used to apply consistent styles to multiple UI components. The script describes creating a class rule for 'text input' to set properties like font size and alignment, showcasing how to maintain a uniform look and feel across the app.

💡Button Box Layout

The 'Button Box Layout' mentioned in the script is a UI component that groups buttons together, typically used for organizing actions in an app. The tutorial adds a 'button box layout' to house the 'start' and 'pause' buttons for the timer, highlighting the importance of grouping related actions for ease of use.

💡Regular Expression

In the video, 'Regular Expression' is a tool used for pattern matching in strings. The script describes using a regular expression to validate user input, ensuring that only numbers are entered into the text input field for the timer. This is a practical application of regular expressions to control and validate user input in app development.

💡Time Delta

The 'Time Delta' in the script refers to a concept in programming used to represent a duration of time. The tutorial uses Python's 'timedelta' from the 'datetime' module to calculate the countdown timer's duration by subtracting the user-specified time from the current time, demonstrating how to manipulate time in a programming context.

💡Function

Throughout the video, 'Function' refers to a block of organized, reusable code that performs a single, related action. The script describes creating functions like 'start', 'reset', and 'pause' for the timer, illustrating the modular approach to programming where specific tasks are encapsulated in functions for clarity and reusability.

💡Schedule Interval

In the context of the video, 'Schedule Interval' is a method used to execute a function repeatedly at specified time intervals. The script mentions using 'clock.schedule_interval' to run the 'begin_cd' function, which updates the timer's display, showing how to implement timed, repeating actions in an app.

💡Toggle

The 'Toggle' in the video is a concept used to switch between two states. The script includes a 'toggle' function that switches the timer's state between running and paused, demonstrating how to create interactive UI elements that respond to user actions by changing states.

Highlights

Introduction to part five of the simple clock app tutorial series.

Adding a timer feature to the existing simple clock app.

Link to previous tutorial parts provided for context.

Disclaimer about the presenter's background in programming.

Adding a tabbed panel item named 'timer' between 'alarm' and 'world clock'.

Setting up a vertical box layout with padding and spacing.

Creating a label with an ID of 'show' for displaying instructions.

Instructions for time format input added to the label.

Styling the label text to be bold using 'gothic bold' font.

Adding a text input field for users to enter time.

Creating a class rule for the text input to set font size and alignment.

Designing a button box layout for 'start' and 'pause' buttons.

Adjusting the width of the app to accommodate the new timer tab.

Visual confirmation of the timer's placement and appearance.

Introduction to creating a function for the timer in the Python file.

Creating a 'running' variable to track the state of the timer.

Defining the 'start' function to handle timer start logic.

Using regular expressions to validate numeric input from the text field.

Importing 'timedelta' for time calculations within the timer function.

Extracting hours, minutes, and seconds from the input and converting them to integers.

Creating a 'delta' variable to calculate the countdown using 'timedelta'.

Scheduling the 'begin_cd' function to update the timer.

Defining the 'reset' function to stop and reset the timer.

Adding a 'pause' function to pause the timer.

Assigning 'on press' events to the 'start' and 'pause' buttons in the KV file.

Creating a 'begin_cd' function to decrement the timer.

Updating the display with the remaining time and handling time formatting.

Adding logic to play a sound when the timer reaches zero.

Defining a 'toggle' function to switch between starting, pausing, and resetting the timer.

Testing the timer functionality and making adjustments.

Conclusion and a thank you note to the viewers.

Transcripts

play00:00

hey guys this is petrina and this is

play00:03

part five of my simple clock app

play00:06

tutorial series so in this video i'm

play00:10

going to add a

play00:12

timer to my simple clock app if you

play00:16

haven't watched part one two three and

play00:18

four

play00:19

i'm just gonna put the links in the

play00:21

description below so you can go and

play00:24

check them out

play00:25

i highly recommend you do so that you

play00:27

can

play00:29

follow along well

play00:31

anyway i'm just gonna put a disclaimer

play00:33

out there i'm not a professional

play00:35

programmer i am just someone who's

play00:37

trying to teach herself how to code okay

play00:41

so the first thing we're gonna do is

play00:43

we're going to add a tabbed panel item

play00:46

and i'm going to put this step panel

play00:47

item between the

play00:50

alarm and world clock

play00:54

so i'm just going to call this

play00:56

tab timer

play01:01

now i'm going to put the box layout

play01:04

in this tab

play01:07

and i'm going to set the orientation to

play01:09

vertical

play01:17

the padding to 20

play01:20

spacing

play01:22

to 20

play01:24

okay now i'm gonna put a label in the

play01:27

box layout

play01:29

i'm going to give this an id of show so

play01:33

show is going to be the id of this label

play01:37

i'm going

play01:38

[Music]

play01:39

add some text to it and the text will be

play01:43

enter the

play01:45

time

play01:46

to count

play01:48

down

play01:50

as

play01:52

follows

play01:58

oh let's just say in this time format

play02:01

in this time

play02:05

format

play02:07

so

play02:17

hh for our hour minute minutes and a

play02:21

second second

play02:23

and we're just gonna say new line for

play02:25

example

play02:32

we're gonna set the

play02:35

text here to bold so we're just gonna

play02:37

say gothic bold

play02:40

so

play02:41

font gets gothic bold

play02:49

and we're just gonna put

play02:54

the time format that we want

play02:56

okay so that's it

play02:59

now we're gonna set the font size

play03:08

17

play03:11

excuse me

play03:12

so now

play03:13

let's put a

play03:15

text input

play03:17

so we're gonna add a text input

play03:20

and we're gonna give this

play03:22

um id of text input

play03:26

i don't know what else to put so i'm

play03:27

just gonna put it like that

play03:30

and we're gonna set the text inside

play03:33

like this

play03:36

so there you go

play03:38

and

play03:39

we're gonna set the font size okay so

play03:45

i'm just going to go up here

play03:51

and add a class rule for the text input

play03:53

because i want to set the font size but

play03:55

then

play03:56

it's going to be similar to the one in

play03:58

the alarm so might as well create a

play04:00

class role

play04:02

so we're going to create a classroom of

play04:03

text input and we're going to say

play04:05

multi-line

play04:07

gets

play04:08

false

play04:10

and

play04:11

font size we're going to set it to 50

play04:17

and we're going to set the alignment

play04:20

to center

play04:26

okay now let me check the

play04:29

alarm

play04:33

just gonna remove this because it's

play04:35

already

play04:36

there in the classroom so i don't have

play04:38

to write it again

play04:44

okay so now we'll go and create another

play04:46

box layout i want this box layout to be

play04:49

like the bot button box layout where the

play04:52

buttons inside so

play04:54

i'm just gonna write button box layout

play04:57

and it's up here

play05:01

here

play05:02

button box layout so i want all the

play05:04

properties here to go inside

play05:06

so yeah

play05:10

i mean i want all the prop i want it to

play05:13

have the same properties so yeah

play05:15

okay so i'm gonna put rounded button as

play05:18

well

play05:19

i'm gonna put that um

play05:21

use the class rule as well

play05:24

and i'm gonna set the text to start

play05:36

and rounded button one

play05:39

i'm gonna set the text to

play05:43

pause

play05:46

okay so now we're just gonna go here

play05:50

into our python file and we're gonna

play05:53

change the length i mean the width the

play05:56

width of it to 500 so it can take an

play05:59

extra tab

play06:01

okay so i'm just gonna run it and you're

play06:04

gonna see

play06:14

so there you go the timer is there

play06:17

and there you go

play06:18

the

play06:20

time is in the middle then the buttons

play06:22

are not working because they don't have

play06:23

a function yet but yeah

play06:24

this is the overall look of it

play06:27

so yeah

play06:28

okay it looks fine

play06:32

okay

play06:34

so the next thing we're gonna do is

play06:36

we're gonna add a function

play06:42

into this file here for the timer

play06:46

before we do that let's

play06:48

create a variable called running

play06:52

and we're gonna set that to false

play06:59

okay

play07:01

now we're going to create a function

play07:05

and we're going to call that functions

play07:06

dot

play07:16

so def start so

play07:21

okay

play07:24

so now we're gonna get the input and put

play07:26

it

play07:27

the text input whatever text is in this

play07:29

um text input box and put it inside a

play07:32

variable

play07:33

so we're going to say self dot

play07:37

we're going to say cd time

play07:40

which is like countdown time

play07:43

and we're gonna say

play07:44

citytimegetself.self.ids.root.text

play07:51

[Music]

play07:57

input

play08:00

dot text

play08:03

okay

play08:06

now we are going to create some if else

play08:10

statement

play08:11

so the first statement

play08:14

um the ether statement they're just

play08:15

going to check the inputs in the text

play08:18

input box i want them to be just numbers

play08:20

and i

play08:21

don't want letters inside and i don't

play08:24

want it to be an empty string and

play08:27

and yeah

play08:29

okay

play08:30

so

play08:31

next thing we're going to do is we're

play08:32

going to have to input re

play08:39

i'm gonna have to import

play08:42

re

play08:44

so this is a regular expression

play08:48

i'm just going to go online

play08:52

here

play08:59

so we're just gonna go online and check

play09:04

re

play09:05

um i want to explain it but

play09:09

i think online we're given a good

play09:10

explanation so yeah there it is

play09:12

so regular expressions

play09:15

are essentially a tiny highly

play09:17

specialized programming language

play09:20

embedded inside python and made

play09:23

available through the re module using

play09:25

this little language you specify the

play09:27

rules for the set of possible strings

play09:29

that you want to match

play09:32

this set might contain english sentences

play09:34

or email addresses or anything you like

play09:37

you can then ask questions such as does

play09:38

this string match the pattern or is

play09:40

there a match for the pattern anywhere

play09:41

in this string you can also use

play09:44

re's regular expressions to modify a

play09:47

string to split it apart in various ways

play09:51

so yeah that's the

play09:54

explanation

play09:56

so i'll be using this one to find

play09:59

letters inside of the text input i don't

play10:02

want people to answer enter like

play10:05

letters inside i want them all to be

play10:06

numbers so yeah that is why

play10:09

i'm putting that in

play10:12

okay so the next thing we're gonna put

play10:14

is we're gonna say

play10:16

we're gonna import

play10:19

time delta

play10:25

sorry about that

play10:27

so for time delta

play10:29

we're just gonna go online and we're

play10:31

just gonna

play10:32

see so python time delta function is

play10:35

present on the daytime library which is

play10:37

generally used for calculating

play10:39

differences and dates and also can be

play10:40

used for date manipulations in python it

play10:43

is one of the easiest ways to perform

play10:44

the date manipulations

play10:47

so

play10:49

i'm going to use this time delta to get

play10:51

the current time and then minus the

play10:53

hours and seconds and minutes from it so

play10:56

yeah

play10:58

okay

play10:59

so now let's go down to our

play11:03

code let's go into this function

play11:06

so now we're gonna create another

play11:08

variable and we're gonna call it check

play11:11

and we're gonna say read dot find all

play11:16

we're gonna put this in

play11:20

we're gonna say a

play11:23

sad a

play11:25

that so this will find all the letters

play11:29

inside and we're gonna say

play11:31

cd time

play11:34

so if there are letters inside it will

play11:36

return true

play11:38

so yeah inside the

play11:40

text input box so so we're gonna put the

play11:43

new statement here and we're gonna say

play11:47

sorry excuse me

play11:50

we're gonna say if cd time

play11:55

is equal to an empty string or

play11:59

length of cd time

play12:04

is not equal to

play12:06

8 or

play12:07

check

play12:09

so if this is true if there are letters

play12:11

in there

play12:12

and we say self dot

play12:16

dot

play12:16

ids dot text

play12:23

that show dot text

play12:27

is equal to

play12:30

please enter

play12:33

that time

play12:35

like

play12:36

this

play12:46

okay

play12:48

and then

play12:50

i least cd time

play12:54

is equal to zero

play12:59

zero

play13:01

zero then you say

play13:08

clock

play13:10

dot on schedule

play13:16

self dot

play13:17

cd

play13:20

begin

play13:23

cd

play13:26

another if statement again

play13:30

alif

play13:32

self

play13:35

dot

play13:36

is dot

play13:38

button

play13:39

dot text

play13:41

is able to

play13:43

reset

play13:47

then

play13:50

self don't reset so this is a function

play13:55

well i'll explain that later

play13:57

also this spot here i'll explain it

play13:59

later but what it does it is is it stops

play14:02

a function from running so

play14:04

yeah clocked on schedule will stop this

play14:07

function being cd from running

play14:10

so yeah there you go

play14:11

and then you create the house

play14:14

then you say else and then you say

play14:21

self.

play14:23

ideas

play14:25

button

play14:28

texts

play14:30

to

play14:31

reset

play14:33

so when

play14:35

the button the start button is clicked

play14:37

the text on the button will change to

play14:39

reset

play14:41

um for this

play14:42

one it will check if the but the text on

play14:47

the bottom is button is reset

play14:49

then it will stop

play14:52

stop the

play14:54

the clock

play14:56

if it's equal to reset then it will stop

play14:58

the clock but this will um

play15:01

change the

play15:03

text on it to reset

play15:05

okay

play15:07

okay so

play15:10

now we'll just get each zeros two zeros

play15:14

in

play15:15

there so we're just gonna say age

play15:17

h is shot for hour it's just a variable

play15:22

so yeah

play15:24

so we just say cd time

play15:28

0 to 2

play15:31

m

play15:33

cd time

play15:36

3 to 5

play15:39

s

play15:41

c time

play15:45

six to eight

play15:48

so

play15:50

each will get the first two zeros and

play15:52

we'll get the second two zeros and s

play15:54

will get the

play15:56

third to zero so we'll just convert

play15:58

these zeros into an integer

play16:01

so we're just gonna say like that

play16:04

m

play16:07

and it's m

play16:10

s

play16:16

and

play16:17

s

play16:18

so now we're going to create a variable

play16:20

called delta so we're going to say salt

play16:22

of delta

play16:24

yes we're going to say self here because

play16:26

we want to access

play16:28

um

play16:28

[Music]

play16:29

this

play16:31

variable here in another function so

play16:35

and we're gonna say

play16:37

daytime

play16:39

dot now

play16:42

plus times delta

play16:48

hours

play16:50

gets each

play16:52

minutes

play16:57

gets m

play16:59

in seconds

play17:02

gets s

play17:04

so yeah

play17:07

time delta will add

play17:10

this

play17:11

numbers here to the daytime don't know

play17:15

to the highways and the minutes and the

play17:17

seconds of

play17:18

the current time

play17:20

so yeah

play17:21

so now we're going to say if not

play17:24

self.

play17:26

running

play17:32

self dot

play17:37

running

play17:39

gets true

play17:42

and clock

play17:44

dot

play17:45

schedule into wall gets

play17:48

begin

play17:50

cd so i'm just gonna say self

play17:53

dot begin city

play17:58

0.05 so this will run

play18:01

the function self.begin city

play18:05

okay

play18:07

so now we create another function called

play18:10

preset so we say def reset

play18:13

so

play18:15

now in this function we're going to say

play18:16

self.

play18:18

dot ids dot

play18:21

button

play18:22

dot

play18:23

text gets start

play18:27

so this will change the

play18:29

text reset to start when it's the button

play18:32

is pressed

play18:33

so now the next thing is

play18:34

self.wood.ids.show.text

play18:40

will get exactly the same text here

play18:51

i think i'm just gonna put the new line

play18:53

[Music]

play18:54

here okay and then we're just gonna say

play18:57

self dot

play18:58

word dot

play19:00

ids dot

play19:02

text input

play19:04

dot

play19:05

text gets

play19:08

the zeros because it's resetting so it

play19:12

has to show the zeros again

play19:14

and now we're just gonna say

play19:18

if self.running

play19:24

self.

play19:26

running

play19:28

sequel to false

play19:32

and clock

play19:35

dot on schedule

play19:38

yeah on schedule

play19:42

begin

play19:45

cd

play19:47

okay we'll create another function now

play19:49

and we're gonna call it pause so this is

play19:51

going to pause the time

play19:53

this one is going to reset the time to

play19:55

it's

play19:56

um

play19:59

it's going to reset the time to 0 to its

play20:02

normal state

play20:03

you know when you started yeah

play20:05

and this one is going to just pause it

play20:07

so

play20:09

so we're going to say def pause

play20:12

self

play20:14

and we're just going to copy this

play20:21

and paste it here

play20:25

okay now we're going to go into our kv

play20:26

file and we're going to give the id

play20:29

set the id of this one to button

play20:33

and we're gonna say on press

play20:40

later we're gonna send a function to

play20:41

this one but for now let's just leave it

play20:43

like that

play20:44

and for this one we're just gonna assign

play20:46

the plus function

play20:48

so we're going to say app

play20:50

dot pause

play20:53

yeah

play20:55

now we'll add another function called

play20:57

begin

play21:02

cd

play21:03

we're gonna say self

play21:05

and

play21:08

we're gonna say cd start

play21:12

this argument here is gonna be

play21:16

accessed here you see

play21:18

it will run by

play21:21

this time here so that's a

play21:24

time that it will add on when it runs

play21:28

yeah okay now

play21:31

we're gonna say self

play21:34

the delta

play21:35

gets

play21:37

actually we're gonna create a variable

play21:39

called delta

play21:41

we're gonna say zelda delta

play21:45

minus

play21:46

daytime

play21:50

dot now

play21:52

so it will keep on minusing the time

play21:54

until it goes to

play21:56

zero

play21:58

as long as this function is running

play22:02

okay

play22:05

when this schedule interval is still

play22:08

on then it will keep on managing so now

play22:10

we're going to change delta into a

play22:13

string so we're going to say

play22:15

delta

play22:17

cancer cr

play22:19

delta

play22:24

and then

play22:28

we're gonna say

play22:31

self.root.ids.show.text

play22:34

[Music]

play22:36

we'll get

play22:42

change the size to 50.

play22:44

so i'm just going to add a zero in front

play22:46

of

play22:47

the original time

play22:50

it's usually just five zeroes so i just

play22:53

want to add a zero in front and make it

play22:54

like six so it looks looks pretty so

play22:57

yeah

play22:58

you don't have to do that if you don't

play23:00

want to but

play23:02

i'll just add another zero in front

play23:09

okay

play23:10

now we're gonna see

play23:12

if self

play23:15

dot

play23:16

delta

play23:18

sorry we're just gonna say delta

play23:23

0

play23:25

7 is equal to

play23:34

10.

play23:38

we're going to add a zero on top so

play23:40

we're gonna say

play23:42

zero

play23:45

plus delta

play23:49

seven

play23:52

and we're gonna play a sound so we're

play23:55

gonna

play23:56

get x do it exactly like the one up here

play23:59

seeing that alone

play24:04

right up here so we're just going to say

play24:06

self.sound gets unloaded

play24:09

you know so we're just going to copy

play24:11

this in

play24:13

here because

play24:15

it's the same thing so just going to

play24:18

copy this and paste it here

play24:23

and we're going to say

play24:27

it's not going to be the alarm clock wv

play24:31

so i'm just gonna check

play24:33

i want the

play24:36

rusto one

play24:37

see

play24:39

so we're just gonna open file location

play24:43

and i'm just gonna copy

play24:46

the title it's very long

play24:49

so i'm gonna go to properties and i'm

play24:51

just

play24:55

gonna go to properties

play24:58

just copy this one here

play25:03

i'm just gonna copy it

play25:06

paste it here

play25:08

and that's it and now i'm just gonna

play25:11

say self.reset

play25:14

so yeah it's gonna reset it

play25:17

okay now i'm just gonna add another

play25:19

function and say def

play25:22

togal

play25:24

sorry toggle

play25:26

toggle

play25:28

def toggle

play25:31

we're gonna see if

play25:33

self

play25:34

dot running

play25:39

self done reset

play25:43

else

play25:49

self.start

play25:53

so now

play25:55

sorry

play26:00

so now we're just gonna put it here

play26:04

and say i've got toggle

play26:08

and that's it so now let's try and run

play26:11

our

play26:13

timer

play26:27

oh

play26:31

supposed to be like this

play26:40

sorry my computer is a bit slow

play26:47

i'll just go here

play26:49

let's just try run it

play27:01

oh

play27:05

it's supposed to be self.root.ideas

play27:08

[Music]

play27:12

where is it

play27:15

where is it

play27:19

104

play27:21

it's a little bit up there

play27:33

okay let's try and see

play27:37

it's okay to make mistakes you know you

play27:39

learn from them so

play27:41

it's okay

play27:45

so there you go

play27:51

oh yeah

play27:53

i have to put um

play27:56

self in front of that so

play27:59

you say self

play28:01

that begin city

play28:05

okay

play28:07

now let's run it again

play28:30

okay

play28:37

i'm just playing around with it for a

play28:38

bit

play28:40

start

play28:42

pause

play28:44

reset

play28:46

if you want to use the mr crowing then

play28:49

we'll just do it like this

play28:53

yep

play28:54

and that's it

play28:56

so this is

play28:59

my simple clock app

play29:03

so there you go thank you for watching

play29:05

and

play29:06

i will see you in the next video

Rate This

5.0 / 5 (0 votes)

Связанные теги
Clock AppTimer TutorialCoding GuidePython CodingApp DevelopmentUI DesignTime ManagementProgramming TipsDIY ProjectTech Tutorial
Вам нужно краткое изложение на английском?