Learn Tkinter from scratch to create desktop applications | Amine Mokhtari | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Learn Tkinter from scratch to create desktop applications

teacher avatar Amine Mokhtari, Developer & video editor

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

50 Lessons (8h 9m)
    • 1. What this course is about

      0:48
    • 2. Introduction

      2:56
    • 3. Create an empty window

      3:00
    • 4. Change the title

      2:06
    • 5. Change the icon

      3:22
    • 6. Change the background color

      3:40
    • 7. Create a label for the app

      9:03
    • 8. Create a button for the app

      6:30
    • 9. Make a command to the button

      7:38
    • 10. How to make an image as a button

      7:19
    • 11. Create an entry for the app

      11:44
    • 12. How to create frames

      20:30
    • 13. How to create canvas

      7:38
    • 14. How to put an image on canvas

      11:14
    • 15. How to draw a shape on a canvas

      7:03
    • 16. How to draw on a canvas using the mouse

      10:43
    • 17. How to draw canvas image

      5:18
    • 18. Include a picture in the app

      6:02
    • 19. Include a picture using pillow

      14:07
    • 20. The grid function

      18:31
    • 21. Application that open picture using dialogs

      18:24
    • 22. How to build a login page for the instagram

      21:12
    • 23. Create a second window

      8:39
    • 24. Pack some stuff in the second windwo

      7:49
    • 25. Make a simple application using the main and the second window

      26:43
    • 26. Following the creation of the app

      16:14
    • 27. How to create or connect a database

      5:30
    • 28. Create a table in the database

      6:23
    • 29. Insert data into the database

      6:40
    • 30. Select data from the database

      8:24
    • 31. Insert picture to the database

      9:46
    • 32. Select picture form database

      5:49
    • 33. Application that convert images from JPG into PNG

      4:10
    • 34. Creating the skeleton of our application

      16:07
    • 35. Opening the picture and puting it in the app

      10:16
    • 36. Function that convert from the png to jpg

      14:45
    • 37. Function that convert form the jpg to png

      6:09
    • 38. How to deploy a deep learning model in an application

      5:11
    • 39. Application that classify 225 kinds of birds

      12:43
    • 40. Third part of the application

      7:37
    • 41. Foorth path of the application

      8:05
    • 42. Final application

      20:08
    • 43. Audiobook | The tools that we need

      10:13
    • 44. Audiobook | The program that says something

      6:05
    • 45. Audiobook | The program that opens the PDF file

      11:14
    • 46. Audiobook | The program that read the pdf

      3:42
    • 47. Audiobook | The face of the app part 1

      8:07
    • 48. Audiobook | The face of the app part 2

      12:20
    • 49. Audiobook | The face of the app part 3

      15:10
    • 50. Audiobook | The final application

      16:11
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

80

Students

--

Projects

About This Class

Welcome to this Tkinter class.

We know that Python became the most popular programming language and a lot of like to share his work with friends professors... But sometimes it is a little bit ugly to share a script instead of sharing something more accurate like a GUI that could be used by anyone.

In this class, we will cover one of the best tools available in python to create desktop applications, which is called Tkinter. 

We will start with the basics then we will go to some professional tasks, using always Tkinter and some additional libraries.

What we will cover in this class?

In this class, we will cover all the stuff that you need to create a desktop application, starting from basics and we go step by step until you will be able to create a great GUI to share with your friends or your professors.

Who can follow this class?

This class is for anyone who wants to create a desktop application from scratch using python, even if he has never used python it is okay because we will see step by step how you can solve your problems.

What do you need to follow this class?

Actually, you need only a PC to write the code, it doesn't matter if you have windows, mac, or Linux as an OS because Tkinter comes with python by default and it is executable in any operating system.

Why should you learn Tkinter?

As a programmer, all the time you have to create some projects for your study if you are a student or for your boss if you are an engineer. And by the end of your project, you have to share your work so that they can supervise it, now here comes the role of Tkinter because I think that when you want to share your work it is preferably to share it as an application which is user friendly and anyone can use it instead of sharing only some scripts that not anyone can run it.

And once you finish your projects in your study or in your internship, it is a great idea if you have a portfolio that contains all the projects that you have made until now so that it will be easy for recruiters to understand what you did during your career.

What you will learn after this class?

After this class, you will be able to create your own GUIs for any project your are working on.

Meet Your Teacher

Teacher Profile Image

Amine Mokhtari

Developer & video editor

Teacher

Hello, my name is Amine I'm a computer vision student I love everything about electronics, coding, and video editing so I created a YouTube channel to share my knowledge then I wanted something big so I started doing courses on Skillshare.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. What this course is about: Either you are here because you want to learn how to win a desktop application using Python and Tkinter. As you know, Python is the most popular programming language in 2020 because it is very easy, simple to use for emphasis. I will be your guide in this course to show you the different functions that you need to build and customize your first desktop application. This course contains severe sections in each section and we'll do an example. Then in the last section, we'll wait. A full application does opens, resizes and converts results from the PNG to the GBG and vice versa. I hope to see you in class. Bye. 2. Introduction: Hello and welcome to this course. In this course, we will learn how to create a desktop application using Python. In this course, we will use Tkinter to wield GUIs, base it on Python. In this course, we have six sections. The first section will be an introduction, which is this video. And the second section will be about how to create a window and how to make some editing on it. Then the next section will be about how to fill this window or how to fill our AP, which means that we will put some labels, buttons and trees, etc. Then in the next section it will be about data basis, which is SQLite. Sqlite. So we will create it as a basis and how to insert something on a tau and how to select it. Which means that maybe it will help you to when you are creating your app. Then in the next section, I will show you how you can create a secondary windows so that you can use it in your project. Then in the last section, we will, we will put together all what we learned in this course and you will create our application. And then I want you to know that in this course, in every example that we will do, there is three steps that we will do. The first step will be how to create the skeleton of the up, which means the window and the buttons, labels, etc. Then the second step will be about functions, which means that the function does we run our application. So we will put it in the second step. Then the first step will be about finishing the app and testing it and make it ready for sharing. Then I want you to know that this course is divided in three important parts. The first part will be the window, how to create it, to create it, and how to make everything on it, which means the labels, etc. Then the second part, which will be about how to mix between Python functions and tick interrupts. Then the third part will be about examples. Because in every winning the finish, every section, we will do an example about it to understand it. Well. Then at the end, i o, I selected three examples that you will find in the course. The first example, we will, we will find this in the Chapter 2. It will be about how to create a login page for the Instagram. Then in the Chapter 3, you will find an example about how to create a login page of Facebook and Instagram to. Then in the last chapter, which interpreter five will create an obligation that will convert pictures from the PNG to GPG and from the GPG to the PNG. So I see you in the course, bye. 3. Create an empty window: Hi guys. As I told you, I will go with you step-by-step to show you how can you create your first application? So in this video, I will show you just how can you create an empty window without packing anything on it. Why I'm doing this? Because I think that as a beginner, this is the best way for you if you are creating an application and you will need a specific thing. You don't need to watch a long video for that, you will just search for this specific thing and you watch the video talking about and take what you need. Okay? So for my course, I am using PyCharm, but you can use any software rewards because it all works. So let's begin. First of all, we need to import the tick interlibrary. So do you want it you just read. We just need to write from Tkinter. Import. Star. Star means everything. So if we ride from Tkinter import star means from Tkinter import everything, then create an empty window. We just need to write TK. This TK function will create the window for us. But as we know in proclamation after that, we sure we will use this application. We will back something on it. We will change the title or something like this. So to work like this, we just need to put this window in a variable. So if we, if we want to make, to make anything on this window, we just need to work with this variable to make our work clean. So we will call it window. A variable called window will take the role of our window. Let me delete this. So if we run this program, we'll see that there is nothing. We can see nothing that is not in order, but there is, there is no window. Does we need y? Because we didn't put this window as the main loop. So just to fix this problem, we just need to put this window, which is window as a main loop after blood, we can see our window. So to do this with just need to write window, sorry, that main loop. If we liked this window, that's main loop, we will see our window. After that. We run. As we see here. This is our beautiful window. It is empty for the moment, but we will follow it after. As we see here, we have the icon, we have the title, and here the court does. We will put some buttons, some entries, labels, etc. So in this video, we'll stop here. We will do nothing with this window we just created it. But in the next video, I will show you how can you change this title and how can you change this icon, etcetera. So I see you in the next video. Peace out. 4. Change the title: Hi again. So in this video I will show you how can you change the title of your application, okay, so if you remember with me, the first thing that we need to do is to import from taking turn, taking journey, import everything, the library. Then we will create our window. Window equal TK. I am doing here, TK. Then we will make this window as a main loop. So here we have our window here. But as we see here, we have the tape. The title of our window is TK, is it is related with the function that we used here to create the window. But we can, we can change this because this is our application, so we'll give it a title for us, given by the function. So to change it, we just need to use the fund, sorry, window. But there is a function called title, especially to use to change the title of our application. So inside this parentheses, we will write our, our title, but this title is a string. So to make it, we just did to make this two quotation marks. And inside the quotation marks, we revise the title that we want. For example, I don't know up. So I will make a title for our application up. Okay, It doesn't matter. So as we see here, we have the title that we have put it here. So we can make an entitle we want. It depends to the applicant application that we are creating. So I know that this video was very short, but I prefer to make every single thing in a video so that it will be easy for you to make your application step-by-step. Okay, so I see you in the next video, Peace. 5. Change the icon: Hi guys. In this video, I will show you how can you change the icon of your application. So first of all, as always, we will create our application from the Tkinter, import everything. Then we will create window, will just make it with window then when that main loop. So to change the icon, we need to, there is a function called Icon bit map dysfunction. We've changed the width, will give us the access to change the at the title, the icon solid. So we just need to write W point, sorry, icon. So this function will help us to change the icon of our application. But there is some changes because as we know in pictures or logos, there is the extension PNG, JPEG, etc. So for the icon in the winter, when our picture or logo has needed to have the extension point, ECO. Okay, so to do that, we just need to convert this picture. For example, I will use this website. You can use this website. It is 43. So here we will take our picture. This picture, I will take this one. So start conversion. Then we'll download it. Here we have the logo point, it, ECO. This extension will give us the access to use it in our program. So we will show you something. Here. We have dysfunction in this parenthesis, we will write the path of our picture or our icon. So to make it very easy, we just have to put the picture in the same folder of our project as here. So if we will put it there, we will see that it is here. So here we just need to write logo point. So we're reliant this, which we don't need to add the path because it is already in the folder that we have our project, okay, to make it very easy. So if we, so I follow good to learn this rule. So as you see here, we have our icon. So to make our icon in our application, we just need to convert the picture of the logo in this website, for example, as I had shown you here, this is for free. You can use this website to convert your picture or logo, then you will put it here in your application. So I see you in the next video. Peace out. 6. Change the background color: Hi guys. In this video, I will show you how can you change the background color of our application. So first of all, as always, we need to create our windows. So we will, from sorry, from ticking, ticking, I import everything. Then the window equality k, then the window. Hello. I know that you are saying y is always repeating the same things, but I am doing this. So we will save it in your mind, all the steps that you will always use it to create an application. So for creating an application, we have always to do this, to import the library then created in and puts it in a variable, then make it as a main lobe. After that, we will start our own. So for this moment to change the color of our background, so we need to use, there is a function called configured. So we will put a W points, configure this one. So in this, inside this parentheses, we will put the color that we want. So we will just make BG for background, or we can recognize background, or we can just make BG for background. So BD background. Then we make these quotation marks. Inside the quotation marks, we can write the formulas we want, for example, will make it blue. So if we run our program, we see that the window is blue. Then I know that's the color that we now, blue, yellow, and red are not very good. So we can use this website I prepared for you, for you. So we can change here. We can take any color that we want. Then we will take this code. This code will work in Python. We take into, I mean, so for example, we'll take this color. I don't know, you can change it. It is for free too. So we'll take this code that here. We just need to add the hashtag. Then we will put the code so as we can see. So as we can see, that is the color that we have chosen. So if we want to change it, we can make this one. For example. Take this code control C, Then here, control V. Then as we see here, our color. So if we want to change the color of the bug, the background color of our application, we just need to use this function configured. Then here we can make the color, for example, red, blue, etc. Or we can mix our colors in this website, for example, there is a lot of websites for this, but we can use it for the scholars are for the HTML, but we can use it in the Tkinter library. So here we will put the color that we want that will take the code here than we put it in our program. As we can see, we stop it here. As we can see. This is the new column. So that was for this video, and I will see you in the next video, Peace out. 7. Create a label for the app: Hello everyone. In the previous video, I have shown you how you can create an empty window. Then we did some editing on it. In this video, I will show you how you can create a label, then do something, some editing on it. Then we will packets in the window. So the first thing that we have to do is to import tkinter library as we did above, as we did before. So we're right here from teaching term, import everything. Then we need to create an empty window and we put it in a variable. So we will call it routes or window is same thing. So roots equal TK, the window TK, the function GK that will create our window. After that, we will put it as a main loop point, Meno. Before we start talking about labels, we do some async on our window so we will change the title. So rot point title. Then here we code it up, for example. Then we will change the background color. So Rod's point configure. Then here. Sorry. Bg for background equal. And the blood will see what we have. So this is our window. I will change the icons too because I don't like it. So Lute point icon. Then here we'll call it logo points, PQ. As you can see, this is our AMT window as we did before. Now we start doing with creates a label. Then we will packet search, create L1. We have to watch it invaluable as we did with the window. So we will call it, for example, love equal. To create a label. There is a function called label. This function will create a label for us. So we will call it here labeled. This function has lots of parameters. The first parameter that we need to do is the name of the window. So if we want to put this label in the window root, so we will give, we will make here the name load. Then the second there is, there is no order between the other parameters. We have just to write. The first parameter is roads than the other. It doesn't matter. So we will make here the text that we want to write in label. For example, Hi, how are you today? So this is our text. If we will run our program, we will see that there is nothing in our window. Why? Because we didn't pack label. It is true that we have put here routes, the name of the window, but this doesn't mean that you will pack it in the window. This roots means that this label is special for the window roots, but it doesn't mean that we practice. So to package, we just need to call the window function back. So we will write the name of the label which is loved by it back. We are our program now we will see here, make it bigger. So we have here the window and the label, as we do. As you can see, the color of the, of the window is always block, but the color of the background of our label is white. Why? Because we didn't change it here. We will do, we will do it later. So as you can see, the size of the window is smaller as the size of labeled. But we don't like to do to lie to me, to let it like this. So we will make a constant size of the window, which is the width and height. So that's the size will be unchangeable. So to do this, we will use the function geometry, which is like this root polygons geometry. And here inside the parentheses we will put the quotation marks. And between the quotation marks will make the size that we want. So I will put it, for example, 500 by 500. So five, then x, then the width. Okay? So we will stop with them on it. As you can see here. As you can see, we have here the size and changeable. So it doesn't, it doesn't depend to the size of the label. Then we will do another thing. So we will know will start editing our label. There is lot of things does we can do, for example, we can change the background color and the foreground. We can change the style, the type of the font, and that is a lot of things that we can do. So we start by the color of the background. So the change, change to change the color of the background, we just need to use the function BG, which is background than equal. And here we would like the color that we want. So for example, when you take his blood as the background of the window. So six zeros. We'd run it and we will see, as you can see, there is no texts. Why? Because the color of the text is always black so we can't see it. So we'll change this to change the color of the text. It is same thing of the color of the foreground. So if we will change the color of the foreground, means that we will change the color of the text. So we will use the function F, G for foreground, then equal, then here, white. As you can see here, our, our texts. Hi there, How are you today? So here we have the function BG for background and the function f, z for the foreground. Then we can change the type of the font. So to do that, we will use the function called Font. Then a colon dysfunction font has two principal parameters. The first parameter is the type of the force, and the second parameter is the size of the font. So we can use it here. And if any fonts we want, there is some fonts that doesn't work with Tkinter. I don't know why. But you can use, for example, there is this website. It has a lot of forms and it is for free. You can download this and started then you would use it. So for this example, I will take this one called Ozone, don't left. So I will use this font for this example. We'll change it here. So here we will write the name of this font. So do a month, sorry. The name is amaz dawn than left. We are on. The programmer will see that the font will change. As you can see. To see it, very clearly will make it bigger. So here we'll make the size, for example, 20. Here we have our text with the font amongst the DOM left and the size 20. So as you can see here, we have not a lot of space between the text and the bar. Then here we can use a function called but why, for example, but why this function will give us a space between the label and what we have above it. So here we will make it just like this. Pad y equals that, for example, will make it 10. And you will see that we have here. And we can make more than this, for example, 13. And you can see we have here this space. So that's all what I will say about labels. So we can chain which here we have text. We can change the background, foreground, the font, and size, and we can change the different padding. And at the end we will packet with the function back. So that was all for today. And I will see you in the next video. And stay safe. Bye. 8. Create a button for the app: Hello everyone. In this video I will show you how you can create a button in using tkinter. Then you will buckets in your app. So the first thing that we need to do is to create the anti window as always. So from Tkinter, import everything. Then we'll make some editing some, so it creates and edits. Sorry. So here we're looking at it. For example, we may give it the name roots equal, sorry, root equals function TK. So we will change the background color. For example, roots bind, configure. Here. The BG equals six zeros. Week it's luck. Then we will change the title. Roots point here. Up. Then the icon. Here, we give its logo or equal. Then we will change the geometry of the up to give it a constant size. So geometry here, 500 by 500 and make it as a main loop. So root point, main loop. Okay, we'll see our function, our window, sorry, this is our window, it is to empty. So the first thing that we need to do, as we did with labels, we need to create the button. Then we will packets on the window. So we will give a comment here, creates the button. So to create a button, the first thing that we have to do as always, we will create, we create a variable. We'll give it the name. But for example, equals. To create a button, we will use the function button. So but independence is there is always parameters as we did with labels. So the first parameter is the name of our window, which is roads. There is lot of rows. So loads. Then here you give the text that we want to see on our button. So here we can type text equals. So for example, in May kids click, click me. This is the text as we will see on the button. Will do nothing for the moment. We'll pack this button. It looks after that, we will do the editing on it. So, but point. Back. Then the balances. As you can see, this is our button. So the first thing that I want to see, we can change the background and the foreground of the button. We can change the font type of the text, which is Click Me for example. We can do a lot of things. So I will show you some of these parameters does we can do. So here we can change, for example, at the background. So BG for background equals, we'll give it the color, for example, red. Then for the foreground, phi f g equal, I don't know, blue, for example. It doesn't look good, but just for this example. So this is, this is our button with these colors. We can change, as I told, you, can change the font type cell. We will use the function font as before. So fond equals here for example, I will take another font which called on Android, for example, on Droid. Then I give it the size of 27. We see as here we have our button, click me. So that is a function called state dysfunction. We control the state of our buttons. So in this case, for example, the function at the bottom is state normal because we can click it. But in some cases we want to, we want to our button to be clickable for just one time, for example. So we will give it the state. The first state is enabled, so we want to disable it. So to do this, we will use the function, as I told you, state equals disable. They bolt, which means that this function at this button will be disabled. So we see here that we can't click it because it is disabled. So That's what I can say. For the buttons, we can change. Here we have the text's foreground background, the font text and the font type, sorry, and the size. And that is another thing that I didn't talk about it. For example, if we want to change, I will delete this. If we want to change this, the width and the height of our water. So we would use the functions, but x equals, for example, we will give it to 13. Then for the y. But x, but x will change the width and pad y will change the height. So, for example, but why would we give it 20? So we will see if it does work. Okay, as you can see here, we have the bottom is bigger than before because we changed here the width and the height. So that's all I can see for the buttons. In the next video, I will show you how we can create a command for this button. So if we click this button, you will see something, create a label, etc. So thanks for watching, and I'll see you in the next video. And stay safe. Bye. 9. Make a command to the button: Hello everyone. In the last video, I have shown you how you can create a button and do some editing on it. Now I will show you how you can add or create a function that will be executed when we click in the bottom. So for example, if we want that, when we click here, when we click the button, we will see a label or a text here. So we need to add a function that will do this work. So before does I have notes? I want to tell you about the pad. X and y are functions. So if we write this functions inside the button function, which is when we are creating the button. It, it is not the same thing if we write this functions in the park. Why? Because here in the, in the, in the bottle function, if we write for example here, but x equality, liberty and patois equals 20, that means that we will make a space between the text. Here, the text and the border of the button. The same thing for the, for the labels. If we have a labeled and we will put but one X and one Y inside or in the creation of the button or a label. That means that we will make the space between the text and the border of the button or a label. Which means for that I told you that we will have the width and the height of the bottom memory controllers with the x and y. But if we want to make a space between the button and the border of the window, for example, we want to move it down, for example. So in this case we will use the functions that the padding functions inside the PAC function. So here in the park, if we were, if we want, for example, we make but y equals 20, for example. You will see here that we have some space between the button and the border of the window. Because if we use the padding in the PAC function, we will control the items between. For example, if we have two items that we will make a space between these two, these two items. But if we have just one item, in this case, we will make a space between the item and the border of the window. Same thing for the pathway, but the appendix. So if we write, if we use the padding functions in the pack here, we will make a space between the items or between the item and the bolded the window is the window of borders. But if we use the padding functions in the creation of the button or the label. In this case, we will make a space between the text and borders. Or we can say we will control the width and the height of this element, the items sewing. So we will back to our main subject, which is how to create a function or a command for this button. So as we, as I told you, we want, if we click on this bottom, we will have a text saying, for example, Hi, how are you today? So in this case, we will use the function called command. This function will execute, this function command will execute the function that we will write this text. So we will write, for example, command, then IC one after another. We will write the name of the function. So for example, or make it click for the moments I didn't define the function yet, but I will just write the name of the function which is click after that. So I will define it in the beginning of the program. So as you can see here, we didn't put the parentheses, but we know that in the proclamation, if we call any function, we need to add the parentheses. So that's, we will say that this is a function. But in this case we don't need it because if we write them just like this, come on, that equal then name of the function. We can't use the function with parameters. In this case, there is, there is another case that we can use the parameters, but in this case we can't use a parameters so that we can write the balances. So we write just the name of the function at each week note. So here we will write the function, that function, the click function for example. So def click parentheses then comes. So I told you that we want, if we click on this button, we will have a text. So inside this function which creates our label. Because if we write labeled outside, the function means that when we run our program, it will create the label without waiting for the clique or something like this. So if we want it to be printed or to be created after Clicking on the bottom. So we need to, to create it inside the creation or inside the function that will be pressed. Okay, So we will give this label a name. For example, love equal, labeled L1, then parentheses. We will make this labored in the root. Then the text equals 2. Today. So when we press we want that will replace the button. We will see this text, Hi Howard, Hi there hours a day. So this is the text. We make some editing on it. We'll use what we learned before. So here we'll use the font before. That's okay, okay. Phones. Sorry. Then use the left. For example, we will make it to 20. Then we'll do some padding to give you a difference between putting the padding function in the creation and in the pack. So here, but x equals 10, then add y equals ten, changing. Then after that we will pack this label. So love points back. And here we will do some padding in the y. So y equals, for example, I will put the 20. So in this case, when we press the button, which is this button, Click Me. When, when we press this, we will see this label. So we'll see if it works. So here our button, if we click here, we will see either hours a day. If we take another time, we will see the same thing as you can see. So in this program, we just, we just added a function which is click. This function click will. Inside this function we will create a label. So in every time we click the button, it will call this function and it will create a new label. So it was all for today. And I'll see you in the next video. And stay safe. Bye. 10. How to make an image as a button: Hi guys. In this video I will show you how you can put a, an image as a button. So for example, if you don't like the button for the default button for the heater, and you want to put a custom button, maybe you can create it using Photoshop or something like that or Illustrator. Then you want to put it here on, on your abrogated on your logic into application, so you can do that. So for example, I took this image here. So this image though I want to put this image as a, as a button of as a budget year intake interview. So you will see that it is very easy to do that. I will close this one. So here we should create an application as we did before. So you're from or every everything that we will need also below because if we will use images, so we need to do is below to open it and resize it if necessary. So here we have flown in an image CK like this. Now we will create a cold TK's than I am moving very fast only that, because we did this one before. All we did all the steps, but I live only to redo it again so we will see how you recognize and you will not forget the steps. Okay? So here is the application. I will change the geometry. Here. I will put a 300 by 400, for example. So here is our application like this. Lowery creates the button. Now, before creating the button, we should open the image. So here we have image, a color image dots open. And here the image icon called it click. Once. I can't type that here. We'll convert it into an image. Sorry what I am doing here. Image TJ, the photo image that you have image. So now the image is really, really created the bottom. So here we have D and the power button, the button, we'll put it on the application loads we have to do. We create the before that, I will start by deck so we can see the button after that. We'll convert this. So here for example, clique me. Then we'll add a command. So does we will see what if the button is working on large survey we have, for example, click. Now I will create a function, click. Maybe you create a label. So after you click on the button will bring something only for example. So here we have labeled, labeled. We'll put it in the application also. So here we have text equal. For example, this is my up, like this only for the deaths. So here we have label that back like this and we'll try it out. I don't want to see the button because I forgot to put, sorry. So here we have button, buck like this. Now. Here is our application and here is our to our button. So after each layer will see here, you can see that the button is not, that, it is not that visible because I am using mock. Sometimes the button by default format is very difficult to recognize. But you saw that using that in Windows it is very easy, but I am using Mark. I am using the operating system and windows and I will, I will use also Linux so that you will see that the Tkinter works on every, every machine. So if you were to use any system you want, every system you want, it will work even for a Mac or a Windows or anything you want. Okay, so for this I am using the tree systems so that you will have an idea and you will know that it worked for anything anyway, lots, you don't need to change anything. Only what you have to do is doing the same program. Only for a ticket, for a 12. For Linux, you should install tickling tell because in Windows or in on mark, when he will install Python tickled there will be installed with this. But in a 12, You need to install Tkinter by using pip install, okay, that's it. But all the other stuff are lots changeable. So here what we have to do, we wanted to change this into a, an image, which means that this custom button, this one. So too does it is very easy. All what we have to do is to change this here on. Instead of using text, we will use an image. So here I will delete this here. And we have image, which is the image that we have. And we'll see how does it look. Outbursts. As you can see, the button is very large because we didn't do the resizing stuff, etc. So we'll do the resizing here before, before creating the image. You should resize it because after that we cannot. So we have to resize it. We had to open it, then resize it afterwards, we'll convert these into GK. So here we have image equal image that's resize like this. Then here what we have to do, or we have only two, puts, the new sizes. So for example, I will put 100 by 15 for the height 50, sorry, then the root. Then here we have the image that's on the alleles like this. So we see how does it look now? Now it is little bit richer. We can see this color here because of I told you because of the mark. Because by default the button will be for all this area. So I couldn't fix this problem for the moment. But in Windows, on Windows or Linux, the buzzer will be clearly. So if you put an image here, it will be only the image. You will not see this, this stuff here. So if this wasn't works or not, so if I will click here, you can see that it's work on each click, it will print that this is my up. So that was for this video. I hope that you enjoyed. I see you in the next videos. Bye bye. 11. Create an entry for the app: Hello everyone. Today I will show you how you can create an entry and put it in the app. As you, as you know, the entries are very useful with any application you can create. So the first thing that I will show you is how to create an empty entry without doing anything. So what we did before, we created labels and buttons. So to create a label, we just use a function called L1. To create a button. We used a function's called buttons. The same thing here. To create an entry will use the function called entry. So to do that, we will put it always, we have to put it any variable. So we will give it a name, for example, ENT for entry. So equals entry here. Then this entity is for the roots. So the first parameter is rules. We can just stay here and we will pockets, as you can see here, he and T. I will show you the problem that I told you about E13, about packing in the same line, I will show you the problem here. So we have here, we will put it directly back that hockey puck. And you will see here we have our Angie, you can write anything we want. So if we want to change the width and height of this entry, we can't use as before, the functions pad in here, but x and y, because it doesn't work with the address. So to change the size or to change the width, we will, we'll use the function called with or we can just write w, w for width. And we will give it a value. For example, we give it the value 30, okay? But for the height, we can't, we can't control the height with a function, but we can control it with another thing, which is, we will control the font size. If we control the font size, this thing will control the HA. So I will show you just here for the width. As you can see, we have here for the width. But if we want to change the height, we can't, we can't use, for example, high equal 10 for example, we have narrowed about this. As you can see, even if we use the function y, we will have the same error. So to fix this, we'll use the function fault equals. Here we can change the name of the font. I will let like this. If we write none, means that it will take the fonts by default, okay? So we will write naught then the size. I will take the size 20 to make it bigger. So you can see this is our space to write was removed. But if we want to make a space, for example, between this entry and this border of the window. We can use it here in the park. So we will make y. Equal 10, for example. So we will have this little space. This is an algae, but it does not think so too. To make it more useful, we will add the bottom. Then I will show you what we do is we will create a button. Then we want from this button, if we press this button and we have a text inside this injury, we will print it as a label. Okay, So the first thing that we need to do is to create a button. So for example, a coiled button. Sorry, what if there's a lot of spaces button? Then here we'll make it routes than text. We give it print. Then formed. What we do is we give it on Android. On the way. Then the size we're making, it's 15. But for the, for the, for, for the budding, we will give it some part, but x equal 10 and y equal to. Then we will packet. So, but that park, we'll have it here. So we want that if we press this button, we will have labeled here, which has the text that we have written here. For example, if we write here high, we add, we press this button, we will have high here, okay? We will do it like this. To do this, we have to add a command to this, to our buttons. So here we have command equals, for example, clique as before. Then we have to, to have to define a function called click. So def, click, parentheses, then columns. And here we will, here we create a label. But before that, we, as we, as we did before, I will show you the L1 equals label. Then here root two and put it in the roots. And here text equals, for example, high, I will changes after. Then, I will give the phone APK ones, for example, does do then left. I think that this is the phones that we used before. Then I will give it here 30. Okay. Then we will pack this label, name. Or back. Here, we will give it some padding. But x those I will just use bad y equals 10. Then here we will give it x, y to equal equals 10 to, okay? I will see if there is no, okay. No. For this. Now, I want you to know that that is, if we have a text here, if we will put text here, and we want to get this text and use it for another thing. In this case, we want to take this text and printed here in a label. So that is a function called get. This function will get this text and store it in a variable as if you want, then we will use this function or this variable which has the value here for this example in Vc, Vc. Okay, so to do this, we will call the function get. And this function will work with the entry because we have the text that we want to stay to take is written in the anti. So here to put it, I will show you something. Before that we do this. I want you to know that if we have, for example, a variable called var, for example, that has the value Hello. How are you? This, we have a variable called var that has, has the value Hello, how are you? So if we want to, if we want our labeled data, if we want to put this text, which is hello, how are you in our label? We don't have to write this sentence two times in the variable and here. So we can just, in the place of this, of this text, for example, we'll make, we'll give the name of our variable, for example, variable var, as we have here, var equals hello, how are you? We will put here the name of the variable. And dysfunction texts will take the value of this variable and put it into labor. Okay, it works where I am. I am saying this because we need it. Now. As I told you to get the texts that we have in the antennae, I will take this off. Make it harder before, it will change after. So here if we have if we want to take the value or the texts that were written in the entry, we would use the function again. But we want to store this value in a variable. So we would call it, for example, texts takes value called text equals, equals this entry which is ENT dot, dot gets. But as you can see, if we use this function gets, we will have, we have a Netherlands I will show you. So this will have an arrows here. I don't know why they are doing these arrows, but to fix this error, we need just to do this as we have here. And three, here, we have Andrey that back. If we write the entry that's part in an underline, you will see that there is no arrows. I don't know, I don't know why they are doing this. But the problem is in this line, if For does I told you that preferably you need to write this decline, this definition or the creation of the entry or labeled as Israel in one line, then the packing in another line. Okay? So as you can see, we have high because, because we're just here, we just put the text height. But if we want that, the, we will print or we will give the label, the text that we have in the anti. So the texts that we have an entry is here. It is stored in the variable called text data. So we just need to write here text, the name of the variable texts. Here. If we have text, this text is the function for the label function, then the text. This text is the value of the variable that has the value written in the entry. We will try it out. So here we have this engineer for example, right? How are you? For example, sorry. So if we click here print, we will see it. Hi, How are you with the font that we have chosen here? Amazon left charity window, size of 30. And with the padding as we put here, we can change a lot of things. But as you can see, we have here the texts, the same text. The text is in our label here because we have storage the volume of the oft texts in the vial with the variable text. Then we took that this variable and we put it in the function texts inside the label so that it takes the value, which is the text and put it into labor. So that was all about entries. And we'll talk about more things later. So I see you in the next video, and stay safe. Bye. 12. How to create frames: Hi again. So in this video, I will show you how we can use the frames indicator. So what is the role of the frames? Maybe I don't know if you've heard about it or not. But I will show you some examples. Imagine with me you have this window. You can see we have these four buttons. And here we have some texts and something like that. So we can see that these buttons are a group of items on this bar, for example. And the same thing for this part and this part, et cetera. So if you have an application and you want to put some items on a group, which means you want to, if you have an image with a button or image with text with buttons, something like this. And you want to put them in a group. So in this case, this group, we call it a frame indicator. So maybe we say that if we can do this without using frames, we can create a window and put them as a group, without creating a frame and put them on the frame, etc. And you are right, but sometimes add you in some steps. You will need this frame because I need this and I will, I will tell you why we need it. So imagine with me if you have an application, for example, that will display some images or display some texts, etc. And you have button or something like this. Add that in. Each time you will click in the button, you will change the image or you will change the text or something like this. So in this case, you have first to delete the first image and you need to post the new image. If you want to display the new emissary, you need to delete the previous one and puts the newest one extra. So in this case, sometimes you will have lot of problems. For example, if you have started your application and you haven't displayed any image yet. In this case, maybe if you will, if you will do a condition to delete the file and the first image, and the image doesn't exist for the moment. So you will have a problem. Or if you have a window, if your window have a lot of a lot of items between these items, you have the image, and if you want to delete the image, it will be very hard to refer these in the program. But if you put some, only some few items or in frame, which means a group in a frame and another group in frame, etc. So in this case, it will be very easy to refer to one item in the application to delete or to change color or something like this from that, from the application. So here we will use the frames. I will show you step-by-step how we can create it, how you can change the size, etc. And I will show you how you can use it. So before that we have to create application server year from Tkinter, import everything. Then here I will create the empty application as we did before. So I will call it, for example, when for window. Then here we have TK. Then I will put this as a main window, main loop, sorry, here we have a main loop like this, and this. And we'll see how does it look here. So this is the application or the empty application that we have. Now, as I will do, I will only change the geometry because I need to have a little bit bigger so we can see the frame after. So here I will geometry. Then here I will put this 300 by 300 for example. And that's it. Now what we will have, what we have to do is to create the frame. So we will create the frame as we created anything before. As you can see the tags as we created a button, entry, etc. We'll do the same thing to create a frame. So there is a function, especially for the frame. So here I will create a variable. For example, I would call it frame with small case here. But the frame for the function is with uppercase like this. Now, what do we do? We put the frame in the application so you have to put the name of the application. She's win for window. Then. Now we can do, we can do any parameter we know we want. We can control the width, hide the color of the background, etc. So that's what I will do. I will control, I will change the width and the height. Same thing with a 100. And for the background, I will put it. I said thanks for this block like this. Now we have to grade this auto park to bucket. I will do back after that, will change as before because we need something, but we will talk about it after. So here we have back like this. Here is the image, here is the application, and here is framed as we have created. You can see it does, is, it is just only one zone or something like that, that is influence of the application here and the do nothing. You can see. Now, what do we have to do? For the module? You will not understand why you are using this. But my idea is if we want to put an image or a tag or something like that, we put them all on this frame. And if we want to control the dimensions, and also they imagined a world control the position of old items. So we will control the position only for the frame and all items will be, will change the position with it. Okay, So here, this is one advantage, but there are a lot of advantages of the frames. But we will, we will do, we will do next steps. You will see that it is very helpful. Okay? Now, here, here is the application as you can see. Now, if we want to change the color, we can change it just here. If we want to change the width and height, you can change them here, etc. Now, I want to put, I will put some texts on it so that we can see it. After that, we will do the other stuff. Now. I would create, for example, texts. I would call it text one. So here we have labeled. Then, now before that's why we created some stuff or some items and we put them in the application. We put here the first parameter, we put win for the name of the window that we had, which is the main window. Here we have, we want to put this text on the frame. So we have to create to put the name of the frame that we have, which is framed this one with the lowercase Mao. Create text, something like either. Then I will, I need to change the color because if I will leave it like this, it will be black and we cannot see it here. So I need to change. Suddenly. I didn't spark for the mode was I went bucket here we have text. One that takes one the park, like this. We can do PUC or we can do the same thing. Here is an obligation, and now you can see that we have this texts but the frame disappeared. You can see that we cannot see the frame. But why we are seeing this? Because the frame and change the sizes or change the dimensions. Now, the frame is at the same size of this text, but we cannot see it black because the background of this text is white, so it will cover the color of the frame. But in reality, the frame exists here, but it changed the dimensions. So here we can see that the frames will fit all will feed the size of all the items. So if we have another item here, it will fit for the other item and the third etc. But in some cases, if you want to use this frame, in some cases, this I think is helpful. But in other cases, maybe you want to see the group here or you want to see That's window order, that's black window here. So we don't want you don't want it to fit the text or any item on the window here. So in this case, you have to freeze the dimensions of this frame. But before that, we'll talk about this part here. Now. What I was saying, now here we have this text. I want to add another text. So it will be very easy to say what I want to say. So here we have texts to label that will do the same thing in the frame. Then here we have text equal, for example. And the same thing here we have texts to that. But now we see both Texas, we have this one, this one, and this one. Now, the idea why I'm using this, because I told you that if I were to delete one item from the window, for example, using the frames, it will be very easy because you know that you have a group of items. So if you want to delete something from this window, only what you have to do is to go only to that group and delete that item. You don't have to refer to hold the window because the window is very big and it may contains a lot of, a lot of things. But if you need only one thing from the window, so you have to go to the group that contains that window and deleted. The same thing in the class or in a school or something like that. If you need. One, if you really want students from a class. So we have to go to that class and to take all choose that students. It doesn't have to go on the whole school and search for the US today. It would be very hard to do that. But if you would go to only through the class where students study, it would be very easy. So the same thing for this one. Imagine with me that this frame is class. These are two students. So if I need one of the students, I have to go to this class and choose students that I need, students that I need. So you can see that distinct here, the small black here because of this text is smaller than this one, is a little bit smaller. So the frame is in this size. So for the moment, this area is covered by background, the white background of the text. But this small hears more small part doesn't haven't been covered by the background of the text. So we can see the color of the frame, which is this one. Okay? Now, I told you if I want to delete this one or this one, it is very easy. There is only one function that we'll refer or that's when you return a list of all the items that we have on the frame. So here I will give you how does it look? So here we have frame, which is the frame that we have. Now, if you have two frames, three frames or something like that, you can only type type the name of the frame that you worked or name of the group. Does you want to return the item from? Now, this function that we will use cold wind and four, in four children. So this wing in fortunately that children means that we'll return a list of all the children or all the items of the frame. So this is the function, this one will return the items. So if I want to refer to one item from the first item, from this, the, this one. I will do it from this frame. So if I want to refer to this one, so this one will be the first item of the list. This one is the second item, etc. and so on. So if I want to do this one, so I will use the index 0, which means the first item of the list. For that, I will write here I will add the brackets, square brackets as a list. And here we have 0. So this, in this line will return only the first item or only the first text that we have in the frame. Now if I want to delete it, we can use the function destroy. This function district will destroy this item. So here we have returned it. Now if I want to destroy it, I will only click here that destroy this choroid like this, then that's it. I will run it here. And you wish it does. We have only the second texts, which is this one. The first one is gone, is destroyed. Because we use this one. If I want to destroy the second one, we have to do the same thing here. I will do frame. When 4, 0. And now I will stop here. If I were right here, 0. If I write one means that I am talking about the second one. It will give us an error. Why? I will, I will write it and I will talk about this after the execution. Now here you will see that we have an error here because this children one doesn't, doesn't exist. Why it doesn't exist? Because if we will run this line, first means that it will destroy the first item, then this one will not be the second item. It will be the first item because we will update the list. So if we have two items in the list which will delete the first one. So the second one will be the first, which will be moved to the first place. So in this case, we will have problem with this one. So if we want to delete both items in the frame, here we have only two. So we can write this 100, so it will delete this one. And the second texts will be the first in the first place in the other line. So in this case we really neat, It's another type. We will see it here. Where is it? This one, as you can see now we have, we don't have any any text in this frame because we delete them all. But you may tell me if we have more than more than two, if you have 10 items or 20 items or something like that, and you want to delete them at will have this problem because if we leave 0 and we want to delete the 24 example, the index will be changed so it may cause a problem. So in this case I was, I recommend you. You may use this one. You have to start by the, I will take this lines command X. I will go. Now, if you want to delete this here, we have only two. So if you have imagined with me this one is index 0 and this one index 20. Now if I want to delete the 20 than 0, so we have to start by this one. You have to start by destroying this text or this item. After that, you will destroy the lower one. In this case, you will not have the problem of indexs Because if you will delete one, this one, the index of this one will not change. It will be always in index 0. So here if we will do, we will apply this here. I will. Back. Now. I can start by the first one, so we will delete the first one. And afterwards we delete the second one, which is this div with the lead. Sorry, we'll delete the second one, then we'll go back to the first one. Like this. Here is the same thing because we started it by the second one. And for this one we deleted said both items. So if you have 20 item and you want to delete them all, you can do this line by line or you can do only one loop. So I can do like this for item in and know I will, I will write frame. That's the same window because this one is a list. So in, from four item in this list. Now we'll delete them. So here we have an item that destroys like this. Now we don't have to see any index. We don't need the indexes because, because here in this case we delete all the items. But if you have, maybe you will use, maybe in our, in your case, you will use the frame, choose only one item. So we can use this here because you don't need the index. You have only one item. So we were destroyed. And that says you can see if we have 20 item will destroy them like this. Now we'll go back to the other problem, the problem that we had before, which is the size of the frame. Now if I run this here, you can see that the frame, we cannot see it because it had been resized. It fits the size of these two taxes texts. So here we need to put the, or we want to free it to phrase the size of the frame. So it will go, it will stay here like this. And after those who can use the any size, any size we want called texts. So to do that, it is very easy to. But before that we need to change this park, this backroom functions. We need to change them by grid, but we go here and we will do it line by line. So here we have great. Because if there is a function, the function that will help us to freeze the dimensions need to be used by this function is green, so we need to put them all at the same function. So we need to put the grid for all the items. But before that here I need to create, to add another function which is grid. But here added breed propagate. So this function will help us to the phrase the dimensions. So it can, we can use two parameters, either 0 or one, so 0 for freezing the dimensions. But if you don't have, if you don't need to freeze them, you can put one. But in this case, if you don't want to freeze them, you don't even need to use this one. But if you have two buttons, you want to use one button for freezing, add another button for letting the dementias change. So here you will need to put 01041 button and one for the other button. Now if I run it here, we see that we have always a problem. Even we have this. The frame have moved here because we use, great, we are not using pack. But if we want to use here, we can only use some padding or something like this, or we can put Center. But now we don't need it here. But this is not our idea or our, what we are looking for. But the problem here is we don't have always, we don't have the size of the frame. The the right size auto frame for that. I told you that we need to change this to functions varied. And this one will have to put this grid like this. And now you can see that we have this little window with this freeze frame like this and two labels. And that was for this video. I hope that you like it. Or if you have any problem using this frame, you can leave a comment like that and I will help you for that. And I'll see you in the next video. Bye. 13. How to create canvas: Hi. In this video, we will talk about Canvas in Tkinter. So I will tell you, I will give you a quick introduction about what is a Canvas, then we will start coding it. So we saw, we saw before how to use frames and how to create it, how to put anything on it. Now, the canvas is little bit. If you put this in the application, it will be something similar. It will be a zone which, which has a column which has width and height, etc. But when we use this Canvas, because if you want to draw something on the application, maybe you want to create an application as paint or anything like this. Or you want to draw on an image so you can put an image on the canvas and draw anything on it. Or you want to crop or bring something from the image. So you will draw, you will extract the coordinates of all the x and y of the image of the object from the image and all this stuff you can do. You can do it with Canvas into the window. So in this video, we'll start by creating canvas, a simple Canvas. But in the next videos we'll say restart doing some images on the campus, etc. So here we'll start by creating a, an empty application. So as we did before from the Tkinter in or have written. Then here we have window because TK, the world poses as a main loop. Lou, like this. Then here will, I don't want to change the geometry of this application because after putting a canvas on the application, we need to, we need to have a really little bit bigger window so that we can see the canvas. Okay? So here we have geometry. Then here I will put 300 by 300, like this. Low. Here is our application. Application. Now also we have to do, I will create the canvas. So to create a canvas, we will do the same thing as we did before. There is a function called Canvas that will do the work for us as we did with the frames and juries, buttons, etc. So here I will create the variable which is cannabis, then the function with a uppercase, which is this one canvas. Now, the same thing, we want to put it in the application. So here we'll put wind folder window, window that we have and when to precise the width and the height of this canvas. So here we have with, Hey, call it call or a 100 as well, that I will change the color also. So here we have bug around it, one, black. And for the backing the same, you can use the park or the, the great function depends to you how, how you want to. I would say that how you want to push your items if you have only one item which is 0, only the canvas. So you can use the venue is just the function. But if you have a lot of items and you need to create columns, a lot of columns. Preferably you need to use the grid function. You know, now what are you going to use the grid and what you can use the back function. Now, here is the application and here is the canvas. You can see it does, it looks like exactly like the frame. Nothing. We can see a difference here. But in reality, this canvas has helped us to, if we want to draw something or we want to put an image and draw on that image, etc. That has low, there is lot of things that we can use we can do in Canvas, okay? But for the moment, I read exhibits began. Now, you can see that by default it will be here in sensor as the frame. Now if we want to use to move it right or left or something like this, we can use the, the bad phone could depart function, okay? But there is something that is a function that we can use also inflamed called the aggrecan. So we can choose the anchor when rule where we want to put this application, this canvas story. So here we can call the function anchor, then we can resize which side we want to place the application. So here, for example, Northwest, I like this and you can see that's will be here at the beginning, lowest. And if I can write here center and two would be incentive, but by default, it's just in sensor. And we can control any place we walls and even, even putting gates here, we can use the merge function, the padding function, sorry, and we can move this window here to two, to the right or to the button, etc. Now, if you want to expand or you want to pause this canvas into hole in the whole row here or on the whole application we can use. That is the simple way which is to pause The same. The same width and height of the application receives 300 by 300. Or if you want to make it to tomorrow, if you want to optimize your program, which means you don't need to change this width and height in each time you will change this geometry. So for this case, you can put it at the same size of this one without resizing the width and height. Okay, I will show you how you can do that. That is two functions. The first function called failed. So if I will do fill, then bought, that means that I will feel boats both sides, which means it will fill the whole row like this. We see it here. It will fill the whole row here. Now if I wanted to fill the whole application, so I need to expand this frame, this color, this Canvas, sorry. So if I read expanded, it will take this whole REO. So same thing here. I will use the function expand than equal one, mean by wanted to expand, I want us to be expanded. So here is, as you can see, here is the Canvas. Now, what I will stop here. You can see that theory, we could create a canvas and you know how to control the width and height manually, or if you want to put them automatically. Here, I can delete all this because using this two functions, we don't need to resize the width and height. So here is, as you can see, here is our Canvas. Now. You can see how if you want to change the color, you can change it here. If you want to change anything you can do. Here. In the next videos, we will start doing some, some editing or we can start putting image here, or you can start drawing something on the Canvas, etc. So I See you next video. Bye bye. 14. How to put an image on canvas: Hi again. In this video, I will show you how you can put an image in a canvas. So you will tell me That's why, why do we need this kind of stuff? Even if, because we can put an image in the application we're using labels or frames. So aware why we are using this canvas for the image, for example. So I will tell you why. So for example, if you are working on a project or something that you should use Tkinter to draw something on an image or to extract a, an object from the image or something like this. So doing this kind of operations on the image cannot do that using labels or frames. Okay, so to do this kind of stuff, you have to create a canvas. So this Canvas helped you to draw something or to extract something from the image, etc. So I will show you in this video how you can put only the image on the Canvas. And in the next video, we'll see how we can draw something on the canvas, add on the image. So here we have, we will create the application as we did before. So a year from G to G or import everything. Then he would read out a TK like this. Then we will put its main loop like that. We'll see how does it look. That's it, our application. So I will do some resizing I O, which is laser, but it's bigger, so we're geometry than 300 by 300, like this. So here's our application. Now, what we have to do, we had to create a normal canvas that we, as we did in the previous video. So we'll create an old my canvas. After that creates, Oh, we put the image on it. So to create a canvas, it is easy, like this was. Then within the application. Then I will change the background color. I will put it blocks of it will be visible. Now, I don't want you to put the sizes, the width, and the height of this Canvas. So I will directly failure and expanded. So we have Canvas the back. Then he will do fill. Then here we expand equal to 10. We have talked about this bill and expand what does do. We're all it will only fill and expanded the canvas for the whole size of all, all, for the whole body of the application. Even if we would resizes, it will be resized with this not fixed, only 11 side. Okay? So now we have to create the image. So do use images in Hinter will use the applicant, the library that we used before, which is below. So I would include below. So from BI, import image and image TK like this. So these two functions or these two classes when we need them. Now what we had to do, I will only to open the image that we will do the other operations. Here I will call it for the global image. Here is my image is at the same folder of my project. So I would only write the name but if your imagery in another folder. So we have to put the path as we did before. So here we have image, the open. And here we need to put the path of the image. So I will, for my case, the image is at same folder. So I will, yes, I think like this. Now here I would add that comment, your pools, an image like this. Now what do you have to do? I will only run this one. You have, you have always to run your program to see if you have any errors or something like that. So it will be easy to correct your errors if you have, if you will run it after two or three lines, better than you will run it at the end. So it's at the end. It will be, sometimes it wouldn't be very hard to know what is the problem. Okay? Now, here we have the image nodes we have to do. I will create a, because if you want to put this image on the takings of application, so we have to, we have to use this image SDK to convert. It was before that. I will do it and do other stuff. So here we have the same, that's the same variable. So here we have this one image. So UK, that photo image. Then you will put the image. Now the image is ready like this. We, we, we, we did this before when we wanted to put an image in label. So we did the same thing here. Now, to push the image in a canvas, always you have to do is write the name of your Canvas that you will call the function called create image. So this function will create an image for your canvas. So Create Image. Then here I will push the, there is some part of, there are some parameters that we have to do. So the first parameters are, for example, x and y. I am writing this only to show you. So this x and y, I would put this in common so I can run the program. Here. Here is our application. So this first, for example, is 00. So if we want that starting point of the image will be this point. So we have to put it 000, so the image will start from here. But the other stuff that we have to know is the image. If we are talking about the starting point, the starting point of the image, by default will be centered. So imagine with me if this is our image. So the starting point of the image or the, yes, the starting point or the center point of the image will be this point. For example, this is the center. So if we say that the starting point should be at the point 0, 0 of the application. So this starting point will be here, so the image will be moved. So just imaginary group but we will do is allow USE. Now here. So this x and y are the first parameters of where the image will start. Then there is the other parameter which is the image, and we give the name of the m. Yes, the volleyball image. So here I will delete these two. So now 0, 0. Now here we have image, as we had in labels. We use labor to create an image. You have to use this parameter image. Then you create, you put the name of the variable that has the image. So in this case, we have imagined the same thing here. We have created the image. If I were to run the program like this, USE that imagery. It is in the application, but we cannot see it clearly because the size is very big. This is the first thing. And second thing is that the image is moved. Because I told you about that image is born because the center of the image is 000. We put center of the image in 0000 so the image is moved, then the size is not. That size is bigger than application. So to fix this problem, you have, the first thing that we have to do is to resize the image. And we need to put it at same size of this application so that we can see it clearly. Then we have to move it. So start by resizing the image. So here is the image, but we should resize it before this line, because after this line we can loss use the resize function. So after opening it will resize it that called vertices into TK image. So here we have reproduced at the same variable. Now here we have emerged than here, image that re-size like this as we did before. Now here the first parameters are the new width and the height of the image. So was it 300 by 300? Because the application needs to be handled by 300, so it will be it will fit the application. Then the second parameter is a marriage. Does the areas that we had we talks about before? Now, we will run the program. You will see that we always have this problem. So the image is resized now, but the center of the image, as you can see, is at the 0-zero. Now, to see the image clearly, we should move the image into this display so that we will see how we see the whole image. So to do that, we have to change the anchor of the image. So here we have the image low, like this here. So here we need to change the anchor. So here, if I will do the anchor lowest as we did before for the applicant, for the, for the canvas. When we created the canvas, it was in the center. So if we want to put it at the first of the application or we want to, That's the center or we don't want, because here, when we adults, I will take this off. Now. Here is the application. Now without using anything center of the application, by default is the starting point of the update of the image. So this starting point or the center of the image will be the starting point of the MSO. It would be here. Now we want to change the position of the starting point. We won't, That's the starting point of the image will be at the 0-zero of the image. So in this case it will be 00 of the image. The point 0, 0 will be at the same place of the 00 of the application so that we can see the whole image. Now, to do that is we have to do what I was writing, this one, so we have to change the outcome. We would just add as northwest. So here we see the whole image like this. As you can see here is our image because we moved it. So the starting point of the image now is here, and the starting point of the application is here, so that we can see the whole image because the size is the same size of the application. And the starting point of application is the same of the starting point of the image. So that was how to put an image in a canvas. Now we stop here and next video, I will show you how you can draw something on the application. So buh-bye. 15. How to draw a shape on a canvas: Hi. So in this video, I will show you how you can draw something on a canvas. For the moment, we will start drawing something without the mouse, which means we create the program. Then after running it will see that what we, what we drove like, I me show you how you can draw a line or how we can draw a, we can say a circle or we can say a OVN oval stuff. So we'll do that here. After that. In the next video, I will show you how you can do it using the mouse. Okay, so as we did before, we have to create the application. So here we have import everything. Then we have the TK, then the main loop like this. Now what I have to do, I want to change size of this obligation Soviet geometry. I can type your material like this then here we have 300 by 300 or yes, I will leave it like this. Now we have to create the Canvas. So you may have Canvas. Canvas is India and I will change the background as well. I will block like this. Then we bucket it's guy was the buck and we'll read it's failed. Both expand equal 1. Now we'll see how close this is our application. Now, I want to create a line, for example, from here to here or from here to here or something like that. So we will see that it is very, very easy to do that here there is an application that is a function, as we had an uptick and a function that will create the image. Because we wanted to put an image on the canvas. We used a function called create image. So here the same thing that is a function called creates line, and there is a function called create over, etc. So to create a line, we'll do the same thing. Here we have Canvas that create a starts by allowing create a line like this. Now, this function has some parameters. The first parameter will be the x and y for the two points. So if I want to draw something from this point to this point, so I have to give the coordinate of this point, the coordinate of this point, which means the coordinates of the starting point and the coordinates of the ending point. So, which means, for example, eg x one, y one means the first. Then here we have x two, y two like this. Now, we didn't define this x and y's, but Here it will be something like this. So this coordinates for the first and this coordinates 1 second. Now, for example, I want to start from 00 into, for example, to handle 99. I forgot the comma will do for the 299 subject like this. Now, if I run it, I think that we will see nothing but the line is here, but the color of the line is black with the background is black. We can't see it. Now we should change the color of this line. So to change it here we have a function call. So this function fare, which means we will fill which color or which, yes, Which color we'll use to fit this line. Severe, for example, I will put it red. And we will see here is our line like this. So this line is red one. So it starts from 00 into two. Had a 1992 either nicely light. I didn't want to try 300. I think that it will not work because we have to 300 means it's starts from 0 to 100 and lightening by 1909. Sorry. So here is our line so we can't change any stop here. If I wrote it here. 22, I'm out. We see here is our line, etc. So we'll put the starting point and the ending point. It will draw a line for us. Now if I want to change the size of this lines, which means the width of this line. We can change it also. So I read God's saving here, I will leave it like this. So if I want to change it, that is the function with, then we will give it, for example, tree and you will see it as three, little bit bigger that I can put it five like this. And it is more bigger like this. So this is how we can create a line in tkinter. Now I will show you how you can create a oval or a circle on at the same, using. The same parameter is only the function will change. So here with a base of using or instead of using line, we will use the function over like this one. So this one will create a circle or an oval shape in the image. So we will see, I am not sure that this coordinates will give us something visible. What we would see here. So this is the image, this is the overlaps we had. I will put it a little bit smaller. One hundred, one hundred. So this same thing. We have the center point or we have the starting point into the center point of the circle. So the center points, for example, will be this one. And the ryan, all the outputs point of the circle will be this one. So here we start with 00 into this coordinate, this point also. So here is our small uptick as Mohr circle for example. And you can change the position of it so you can pause it, for example, here or here or here, anywhere you want, change using these coordinates. So that's how you can create a shape like lying or oval or something like that in Canvas. In the next video, I will show you how you can do this stuff. For example, how we can draw something using the mouse. So why? 16. How to draw on a canvas using the mouse: Hi again. So in this video I will show you how you can draw anything on the canvas using the mouse. So we have, as you can see here, we have the same application that we had before. Now we need two other functions to functions that will do this drawing. So the first function, we'll save or store that. So if I will click here, for example, if I want to draw something from here to here, so I will click here, then move the mouse. For example two here. So in this case you draw a line, something like this here. So the first click will store the coordinates of this point. And the second click for second function, sorry, the first function, sorry, the first function, we'll store the first click here. And the second function will draw the line from this, store it coordinates into the next one. So we'll do it here and you see what I am talking about. Now, as I told you, we should to create two functions. The first function that we installed the x and y's, and second one, we'll create the line. Now, I will call the first function, for example, it gets x and y, for example. Like this means that it will guess the x and the y or the previous x and y's. Then the second function will go to it after. So here we have a parameter events. This parameter events, we had the role of the event, which means the click of the button. So the click of the button will be this event. So if we have, for example, the space here, if we have events that's x and events that y. So this event That's x will return the x, x coordinate of the button of the place or when we click the puzzle. So if I click here, so this event x will return the value of the x and this event, That's why we return the coordinate of the y button or the white, the white point. So that's what's, how does it does work. Mao here we have, we will go to the, the update to the function. Now as I told you, we'd have two points, starting point as we did before and the last hour, the ending point. So the starting points, we will call them, for example, the last points or the first. So I would do for example, here we have starts, eggs, which means the starting x. And the second one is the start. Why? Then we need to put them as global. Why? Because we work with them in the next function. So we should have these two variables as global, so they will be recognized in the other functions because if I will leave that here without this global, so they would be a local, will be local variables. So in this case, we cannot work with them out of this function. For that, we should put them as global variable. Now. We have to do where I was. We said Michelle, we should store the first click, which means the first. So here we have start x, start y equals two events, the events that Y. So if I will click the first click here. So I will have, after the click, I will have events x and I will have event Y. So I have to store them as the, these two variables. In this case, we will have the coordinates of the starting point. Then after the second click will have a new x, a new X or new events x and new event Y. So we'd use this seconds to draw the line from the start into the newest one. Now, for this function does what all was, we need only to store this x and y. Now, the second function, we use it to draw, so I will call it, for example, globe. And we need the same thing here, event. Now, what I will do here, I will create, I will call these two variables and I would only copy them. We should always use this global here. So this means that if we do some changes, some changes on this function, they will be updated in this one also because they are, they are global variables. Because if I will not, this one here, if I will change them here, they will not be changed here. So in this case can only use them here. But if I want them to be updated, means if I will change them here, they will be changed here. And otherwise the same thing. So here i, in this case I should put global in this function and global and dysfunction also, if I will use another function, I have to the global world, okay? Now, now what we have to do create only line that we did before. So we have Canvas that create a line like this. Now we should give it the coordinates of the starting coordinate and coordinate. So starting coordinates, as we said, we have starts eggs, stars. Why? I am doing you start y like this, then the ending points or the new click. We knew that the nucleus is events, does eggs and that one. So if I will click here the first click before dropping like this. So if I click here, the first clique will be starting x and starting y. If I will move the mouse like this. So if I will leave the mouse. So here we'll have the second which is the f at x and event Y. So in this case, we will draw this line from here to here. Which means if we will do something like this, if you will move little bit by little bit. So we'll have small lines from this point to this point to this point to this point. So idea, do you have large or a long line? Now here I will change only the feeling or the color that we will fill the application. So we will not have that problem with black, with black. So I will put this red. Then that says I will leave it like this, what we would now once we have to do, we have to update the new x and y. Because if I will click here from this point to this point without leaving or without releasing the mouse means that we will have a new x and y, or we will have new starting point. Because from here to here this one is, but for those I didn't release the mouse. So here we have the first X and second X. The same thing for the y. Now if I will move it again, and which means that I will have a new X and Y. The same, same thing here and here and here. So when I will have a new X and Y, I need, I need updates, the latest or the previous x and y. So the previous x and y are, these two, are the starting x and starting y. So I need to update the after each click or after each row. So I will copy them here. And like this. So now we have drawn the line and we have updated the x and y points. Now what we have to do only to call these two functions, because here when we did this, we didn't call them, so we need to call them. How to call? It is very easy. We should do it here, absolutely, creation of the Canvas. So, so here we have that is a function called bind. So this function will help us to call these two functions mean after HE click will call the functions we're using this function. So using this function, we'll call this one and this one. But as we said, we have to call this 1 first to store the first X and Y. Then we call this want to draw the line using this coordinates with the new one. Now here what we have to do there is some parameters which are the points. So I will most points, which is the, which is the button. So here I would for if I will use the first button of the mouse, so I should rise the main button. So here we have a button that I should choose, the one, which means the first button. Then here I will call the function which gets x and y, this one. So after doing this, we'll call this function to store the x and y. Now, we need to call the other function to draw the x and y. So you have Canvas that's buying the same thing. And here we have to put this be one, which means the first button. Then motion does means that this one we only store the x and y. But the second call, withdraw the line. So here I will close this one here. I, we should call this the function dots will draw. Okay? So this keyword means that only we will only call the function. But this keyword means that we will draw something. We'll do something on the canvas. So now we'll try it out and see if it will work. So here is the application. Now, if I will do anything here, you can see that we drew, if I will do, is it will draw anything we want using the mouse. You can change the color or you can change the width. Here we can change the width. For example, I will put a tree and it's a base bigger. So here is the application and you can see that I am using only the mouse. I can't draw anything. You can't do anything with this. You can change the color, you can change the way you can do anything with this stuff. So that was for this application, how you can draw anything using the mouse. In the next video, we will show you how you can do the same thing but on an image, and you will see that it is very easy to do it. So well, Bye. 17. How to draw canvas image: So in this video, I will show you how you can draw something on an image using Canvas always. So here in the previous video, we did this application that you can draw anything on the canvas. Now we want to draw something on an image. So that's maybe after does require you if you want to save it or something like this. So before that, I wanted to tell you that using this in an image, it is very easy because we saw how we can put an image on a canvas. Then we saw how we can draw something on the campus. Now, only what we have to do is to put the image and we do the same program to grow and it will draw on the image. So here is our program. Now what you have to do, we import the image, then we'll resize it so that it will fit the canvas as you remember with me. Then we will run it. Before that I have to import below because we needed for the opening and for resizing. So for PIL image, the image as well. So this hour glass that we need here, we'll open the image. So here I will call it, for example, the image. Imagery does open. And here I have the image here at the same path as always. So I will write only the name tag like this. So this our image now I will resize it. So here we have image, then image size. Here, the first one because as you remember, it made the new with the new height. Then we have a image dots on the ideas like this. Now we have the new image with the new size. What do we have to do when we convert it into a TK image? So does we can put it into Canvas. So here we have image, we put it at the same variable. Then here we have the image TK, that photo image. Then you would put the new image. So this image is ready to be used for the Canvas. Now what do you have to do is only to do canvas that create, creates image, this one. Then here we have to put the x and y, which is 00 than you would the image. This one a CT image like this. Now we see how does it look. Here is as you can see, what we have to win or we have to change the anchor of this image. So it's very easy. Also, here we have an K4, L4 West like this. So here we can see that the image is on the whole canvas. Now if I want to draw something, you can use, as you can see, you can draw anything on the canvas because we are using the same program, because this program means that we will draw on the canvas no mature if the canvas is only one color or an image or anything you want. So you can do this stuff and using andro or something. I am using this because there are you can, you can need this stuff into cases. Maybe you will need to import an image in Canvas. All you are creating an application, then you will have an image and you want to draw something or I don't know, then you want to save that image with the draw. So you can use this stuff and you can save it's also, or for example, if you have an image and you want to crop, or we want to return or anything from the image. Maybe I wanted to crop only this cat for example. So what you can do, you can use the same, the same program, but in this case you will do, you will add a, an array or a matrix of something that will store all the coordinates of this drove for example. So if I will do, I will run it again here. Now. So if I, if you need only this kid, so if I will draw here for all over the cat, I am not good painter, so I'm only showing you. So if I want to return only the sketch, for example, I want to crop it from the image. So what do you have to do? You can add a, an array or a matrix or something, or a list here in this, these two functions, or only for this one for example. So when after, only if, after each click, you will store the x and y of that click here means that you will store all the x's and y's for the cat. After that, you can use this x and y's to return the objects or here, for example, the cat from the image. So these are two, only two examples that you will have in your mind. Maybe we need them. Otherwise you can use this feature in anything you want. So I am only showing you how you can do it. Then it's up to you how where you can't use it. So I see you in next video. Bye-bye. 18. Include a picture in the app: Hello everyone. Today I will show you how you can import a picture, then put it in your application. So to do that, we will use just the Tkinter library. We don't need another library because there is some functions that are already included in the ticking celebrity. So we will use it. But there is some conditions I will tell you about. So the first thing that we need to do is to create our, our window. So from Tkinter, import everything. Then we will create the roots, root equal TK. Then we will put it as a main loop. Now we will change the size of our window. It puts it. So for example, geometry, here we'll put it's 500 by 500. Okay? Now we will start our program. So we will run it to see the window. This is our window. Now, if we want to import the picture, we will use a function called photo image. This, this function is already included in the Tkinter library, so we will just use it. But the condition is if we have a picture with extension, PNG or JPEG or etc, we can't use it with dysfunction, dysfunction. Accept just the seed, the extension GIF. So if we have a picture with the extension give, we can use it with dysfunction. But if we have another extension, we can't use it. But there is no problem for this. There is, for example, this website. You can convert any picture you have with any extension. You can convert it to a give and for free. So because using a picture in application, we don't need to have a PNG, et cetera. We just need to make a picture. So you can, you can convert it then use it for your app. You that you don't need to have to use another library and you will make it so difficult. So we will import the picture. And after this, I will show you how you can bucket. So to use the function photo image to import our picture, we need to pause this picture in a variable. Then we will work with this variable as always. So we will call our variable, for example, picture. Then we will use the function photo image. So photo image, this is the function here. We just need to write the keyword file, sorry, five equal. Then here we would write the pack of the path, sorry, the path of our picture. So here we have, this is my picture, for example, for Instagram. So this is our, my picture I just, I already converted to give extension. So here I would like just the name of this picture which is end stop point, if this is our picture. So here we have, we have included the picture and we put it in the picture variable. Now, we just need to put it in a label aftertouch, we will packets to the application. So as we did before, a label, we use the labels to put a text and make some editing on it. But we need, we can use the label function even with the pictures. So here we will give it a name. For example, IQ equal the function label. Here. As always, we just need to route, which means that this label is special to the roots roots application or root window. Now here we write the P word image before we just before we're not text and we put the text, but now we will use a picture or an image. So we just, we just write the keyword image. Now here we will write the name of the variable that has our picture. So our pressure is stored in the variable picture. So we just read just right here picture. So we have the labeled function, then the roots, which means that this label is special for the roads. Then the keyword image equal picture, the name of the variable that has our picture. Now if we run our program, we will see nothing because we didn't packet. So we just need here to write, pick that puck. And here we will see our picture in the, in the, in the window. We can make some padding, or for example, x, I will use, but y equal, for example, 10. I will move it down. Then without our program, as you can see, we moved it down. So that was for today. I I I shown you how you can use pictures he with your app, but without using any other libraries, you can just use this library which is tkinter and this website, for example, to convert your pictures. There is a lot of website that you can use. But I found this, it is very useful and for free. So you can use this for your images. And after that you put it in a variable here. Then you use label function and call it here, then pockets. So I see you in the next video, and stay safe. Bye. 19. Include a picture using pillow: Hello everyone. In the last video and I've shown you how you can import or include pictures in your app. But it was not very, very professional because we had to use just give pictures. But now I will show you how you can use a library that allows you to it, that will allows you to import any type of pictures you want. For example, PNG, JPEG, ECO, etc. So to do this, the first thing that we have to do is to install this library, which is below this library called pillow. So to do this, we have to go here to the CMD. Then we will we will type PIP which is piped to install. So pipe install, sorry, installed. Then we will write name of liability, which is below here, as you can see, which he tries, it goes already already installed because I have already installed it before. So follow your case. You will have here a stunning, then you can start after this. If you will use, for example, another IDE, for example, if we will use Sublime Text, etc. You want to have an error for this, but if you are using PyCharm like me, you will have little arrows. So to fix it, you have to go here, for example, than the settings. After that we will have, you will to your projects, which is this one projects interpreter. Here you will see in my case, I have already faces. So I can see below here. But if you can't see it, you will you will type, for example, you would come here then plus Danny will type the name of, sorry, the name of the library. But sometimes even if you will use it here and you will install it, it will work. Why? Because diversion of your Python. For example, if you are, if you start a lot of versions, for example, 3.83.7. So maybe you have installed below in the version to be 0.7. But in this project you are using 3.8. So in this case, each one's work, you have just two came here and changed the version that you start on the library pillow. So now after that you established we have to include it. So here we will write from, sorry B, I, L, Sorry, PIL is the last name of this library. It was PIN, now it is below, but they save the name. So we will write from PIL, import TK image, then impulse image two. We will use it after, sorry, what is this image? Now, if I will let it like this image and I really want to use it for my program that wants work. I don't know why, but I don't know how I know how to fix it. So to fix this, you have just to change the name of do you want to use this like this image? You will just import it as another name. For example, I would take it with a lowercase. Then we will use it as this image. We want to use this one. Because if we use this one, we can't access to the functions that we have. I don't know why, but I know how to fix it just to just to change the name, for example, you will do will import it as another name and not this one. Okay? Now we have this little window. Now I want to change the geometry so I will put its roots geometry. Now I will put it 500 by, no, I will put it for a 100 and by 5. I see this is our window. Now. Before that we will start including pictures. I don't want to put a button. So if we press this button, we will close this window. So to do this, we have to, just to create a button, will give it a name. Close Dan button. This one. Then we'll put it in the roots and he will give it the name, the text, sorry, texts equal, sorry, close. Now we will give it a command that will destroy it. Or I already gave you the name. This. We have a command that will destroy or we'll close our window, which is already, we have already used this one for labels for example. So we will use this with the up, which will work. So roads that destroy. So this function will take this off because as we said here with you, with the function, with the function of the parameter command, we can't use the balances just if we use here, we add here lambda, etc. So in this case where we didn't packet, so this close that. But now we will see it. This is our window. So if we press the button, it will be destroyed, which is closed. So if we press it close, which means destroy. So now the first thing that we have to do is to include our picture. We have a lot of pictures here. As you can see, we have picture with give ECO BAG. It is same picture but just the different types. So here we have PNG JPEG extra. So to do this, we have the first thing that you have to do is to use, we'll put it in a variable, we'll call it, for example, picture. Than we make it equal. He had there is a function. We will use this, this dysfunction or this object which, which, which is a solid which is included in the PIL library. So image TK here that we will use the function for your image. Then inside the function we will write the bath of our image, which is for this one. This is, we will take for example the PNG. So my make file equal. Then here, B, sorry, not this one. New picture that PNG, this one. So in this line we have included the picture and we have storage in this variable. Now we have just to make it as just put, create a neighbor. Then we will put it in the library, in the labor side. So this is label, we'll call it, for example, name, no label. Here. We'll put this in the roots. After that, we will write image than equal picture, this one. And we will packets at the end, picture that back. Not picture, sorry, LA, and they've labeled will pack label. So here we have park and this one. So as you can see, we can see on the picture, here is the new 3D picture. This is me. This is the picture. So if we use it as you can see here, the AP, we can see all the picture. Why? Because the size is too big data. So data can see all the picture in the app. Even if we are limiting the up with this function. But if we take it off, you will see we have a big, very huge picture here. But in this case we can see on the picture, but we don't want this. So if we want to see the whole picture, picture, we have to resize it. So some of us, I taught this before. I will make here for example, with I will change the width. I will put it, for example, 300 than the HIV. I will put it for example 400. And you will see that this is the picture we didn't give. We didn't resize the picture, we just resize the label. So in this case we have decided that the labeled, but we caught the picture so we can see all the picture. So if we want to see the whole picture, we have to resize it. To resize it. It is too easy to several used this function which is included in this object, which is image. So here we will give it another name, for example, picture to equal image. But here we can, as I told you, we can't use this one. We'll use this one to have the access to the functions that we have in this object. Sorry, so we have an image that open. As you can see now here we will write the path which is this one, control C, control V. Here you have, you can see that we have this image, two, pictures to picture two, sorry, here we have Image.all this one open, and this is the part of the picture. Now we want to resize it to. So to resize this picture, we have just to use a function called resize. So before that we have to write, we had to put it in variable. We'll give it a name, for example, big, resize it to size it. So we'll give it like this, resize it. So picture to that, resize this. And here we will put the new sizes that we want to change. So as parameters, we have two parameters. The first parameter is when we put this in parentheses, which is the new size that we want. So I will this command, this one. To have a constant size of our label, of our roots. Sorry, So we have here 475. So we will put this one example here, 350 by and by. I will give it 450. So this is the first one meter. Then we will make a comma. After that, we will make image that on this 12 alleles, this one will take off 4D aliasing that we have in the picture. So just to clean the picture if we have some errors of etc. So this picture, this is the new picture with the new size. So if we want to print it, we have to just two changes here. We will make it big, resize it. This one, you see here that it doesn't work. Why? Because we have to put a picture in this parameter. We have to pass it by this function because this function is special to convert a picture and the picture to convert it so that we can use it in the Tkinter library, ticking up, sorry. So to do this, we have just to copy this one. Control C for example, then Control V. And to give it, for example, picture three. And here we will change this one to the peak, resize it this one. So now if we make here picture tree, as you can see, this one would work. So here we have our window and this is the picture, resize it. As you can see, this is the picture. We have resized it. With. This one, we'll have resized it and we have put it here. We can change any. As you can see, if we press U to close it, we can make any size we want. If we wanted in the whole absolutely. We'll put it here 400 than here. Fine. As you can see, we have this one. Sorry, by the way, it is not working because I think that's the size that it works with. The picture is not the same for the sorry, I know why. I have to put this off. Like so now you can see that we have, the size of the picture is the same size for the app because we have here 400 by five and we have here 405. So that's what the Vd for today. I have shown you how you can use different pictures. Sorry, I forgot something we have here, PNG, if we have, if we change it, for example, if we will put it here, for example, GPG, G, PG, because I have, I have here already a picture, same picture with the, another type which is GBD, will make it the same thing here, G, B, G. And you will see that it is the same thing. It will work because as you can see, because this function, this function and this one allows us to use any type of pictures we want. We can use it with the, for example, ECO if we want to import this one and put it directly without, because this picture is only the small. Where is it? Not this one. This one is already small so we don't have to resize it, so we will print it directly here we have this one, this one. We'll chain just here. I will make file than equal. Here we have logo that EC50. So as you can see, we have here, this is the up and this is the logo we have. We hadn't we don't have to resize it because it is already small and we can see it in the hole up. So that was for today. I have shown you how you can use any have you can include any type of pictures in your app. So I see you in the next video and stay safe. Bye. 20. The grid function: Hello everyone. In this video, I will show you how you can use the greet function. In the previous videos, I have shown you how you can create buttons, labels, entries, and how you can pack it. In this video, I will show you how you can order it in application. Because if we use just the function pack, we can't order it because if we have, for example, two buttons or a button and label, and you would use the function pack. So we will have the first item which is for example, labeled Dan. If we will park button which will have its in second place, etc. But if you want to put it in same line, for example, in like this up, if we want to win like this up, for example, we won't hear the label. And here the entry. We can't use the function back because the function pack doesn't order our items. So to do this, we need to use the function grid. So the first, the first thing that we have to do is to create our application. So we will use the Import, the tick and your library to him. Sir, port everything. Then we're going to create the root equals TK. Then we'll put it as main loop. Just here we will change the some women do some editing on our app. For example, you will change the configuration, will change the background. The VG equals I, pick this corner, 26 tree. The 42. Then we'll change the title. Routes that tighter. Call it hello, for example, like this app that I have shown you, like this one. Okay? So then we change the icon here, no good that ACO. Then we'll change the geometry of our route. Geometry. We'll put it to 100 by 4400. And sorry, we will see how does it look? We can see antic, sorry, I didn't turn it here. Good. So this is our window. Here. We want to pack the entry like this. For example, this entry and this text, so we can't use the function up back, sorry. So the first thing that we need to do, we will create it. After that, we will packet to create a label. For example, we'll call it text label. Then here we'll put it in the roots. Text equal as we have the, say hi, for example, then formed a corn, which although it then here 50. After that we will do some, some padding. So x equal 10, then y equals 10. That's it. Then we will create an entry. So ENT or we call it a box, for example, books a, Q1 and Q3 than what is in the root forms. We'll give it the size. For example, here we have, we will put it none, then the size 152, then the width. Equation 20. Okay, Here we have created Laban and an entity in the previous video to pack these items. For example, this label and this entry, we used the function pack. But in this case, we want to put it like this in the same line. So we have to use another function which is given the function grid will define the defined. I will execute it another time to show you the grid function. We'll define the row and the column where we want to put our item, for example, label or the entry. So we will use it like this as before, for example, texts, point grid. This is the function that we want to use. Here we will have the parameter, for example, Rho equals. We will put it in the first row. Is there unlike arise and like tables, etc. Then we have the columns, so we will write it column equal. For example 0. We would want to put the, this text, which is hi, say hi. We will want to put it in the row 0 and the column 0. Then here we will make some padding. I will put it after. We will see how does it look after we will change it. So as you can see here, our, our text or label say hi, we will change some things. We changed the background and the foreground will change. The background, will put it like the background of the app. So 263, the 42, then the foreground. We will put it's white. Okay? Now, really run it another time. As you can see, this is our text. Now I want to change. I want to make some padding on it to make some space between it and the, and the, the border of the window. So here we make, but x, x equal 10, for example, then y equal 10. We will see how it does it. No, that is not big changes but recedes into answering. So now we want to pack the anterior. So same thing. Google puts books. That great. Now here we have the row, this is, they are in the same row, so row 0 and the column it is in the next column, so the column equal one. Then we will make some padding, but x equals 10 and y equals 10, 10. So we see this is our, our label and this the attribute change some, which you need a width here. To say it more clearly. For example, 15. Okay? This is our text and our entity. We can write anything we want here. Now, what we want to do, to do like this, we will just add some buttons. So when we click on this button, for example, if we have a text here, when we click on this button, for example, we will print that text here in another label. And if we click in this, in this button, we will clear this text. Okay, so we will try to do it now. So we will do the same thing for the buttons. We will created here for example, the first button is to print a coil button. Then we'll put it in the root. Then text, sorry, texts equal. We'll make it print or not. Then here, the way change the font. For example, equal left. Then you put it, for example, 50. I think it's great. Actually you will use this one. But usually after, then we will make some padding here, but x equal ten, then y equal to 2. Then we create the other button which will clear our label. Mix some spaces here. Then here, college Clear button. We will put it in the roots, then takes equal clear. The same thing for this parameter is we will just copy it. Control c or B. So in these two lines, we have created the print button and the clear button. Now we just need to pockets or we will use the function bleed. Because as I told you, we can't use the function greed and the function back in the same program, we will have an arrows. So we have just, we have to use the function pack or grid. We can't use it in the same time. Okay? So here we will put, we will grade the first button which is print. Prints dot grid. Here. Here we'll che, will choose the row 1, then the column 0. And we will do some padding, but x all we don't need it for the moment. Now, the second button which is clear, or it, great. Then here the row true, because we're just next, is then the column 0. Now if we run our program, you will see that this is our buttons. But the problem is that these buses are not in the middle of our from our application. So to do this, we need, for example, to span two columns. So we will have a great looking for our buttons. We will see, we will use it in this functions. For example, if sodium at this here, if we want to span two columns, we will use it in the function grid. It is one of these parameters. So the function to do this called column, sorry, column span than equal. Here we were right, how many columns we want to span? So for example, in this case we have two columns and we want to span to Spanish. So we will write two, which means that we will, I will show you here. This means that for example, this is the up here, we'll divide it into sides. This is the first column, this is the second. So if realize span two means that this person will be in the middle of these two buttons to make it more great. Women may hear more span with more padding here, for example, x. We'll put it up. Josie, the same thing here. And same thing here we will do, we will do the span function Control C. And here, as you can see, this is our buttons will just add some padding here to make it the same thing. Where is it? Here? For example, I would pose it 21. Why not to G2? Okay, now we will just add some padding here to make a space between the, these two buttons. So bad. Why equal ten? It works, I think, just for one budding. So our main program will do if we arise here, something we want. If we pray, if we press this button with this, the program will take this text and put it in a label here. Then if we press this button, it will clear this label. So what I did here, for example, when I write the comments of the buttons. So here we will make it, I don't know. Command. Equal P for prints. I just want to make it like this. And here we may command equal c for clear. Okay? Now we will define these two functions. So the p. Then here, what did we say? We said that if we want to, if we, if we click or press the button print, will take the text that we have in this entry and bridges in a new label. So the first thing that we have to do is to bring that text. So we'll call it, for example, T for text. I don't know why I am using these names, but to make his TH1 books that get okay. After that we will create the label. We will call it, for example, label, a. Label. Here. We'll put it in the root. Texts equal t. Then we will grade, we will package or we will use the function grid. So love labeled points grid. Here we are in the no tree, I think yes, the tree. Then the column, column equals 0, then we use the column span. We respond as we did with the, the buttons. So column span equal to like this. That's what we will do. We'll add some padding in the y Excel, but y equal 10, and that's it. So we will try it. We'll see what we have here. I forgot to define the desc function. We just defined c, a equal return. Okay? Just to try our program. So for example, if we're right here hello, if we click Print, we see here hello, okay, now we need to program this button. So if we click the Clear button, we will clear this label. So we'll make some changes in this iodine forms it like this. So for example, high-end, say May 4th equal, for example, I don't know. I like this forms on Droid, on oil than the size. I will make it 20. Which way? And that's it. I will change the background color. Bg equal the same color of our background. So this is 26. I don't know, three, the 42, we will see, no. So here we have, for example, hello or say hi. So we say Hi, print. Here, our text. Now we want to, we will program the clear button. So here we will. The clear button will just destroy what we have in the label. So it is too easy. Just right here. The name of our labor, which is lug point destroy. But as you can see, we can't use it because this function doesn't know that destroy variable, because this variable destroy and Sony, the variable labor is a local variable for the function P. So to fix this problem, we just make this very what as a global variable. So we just write here global than love and we fixed the problem. So here we have the lub is a global variable, so we can use it in this function and in the other functions. So we will see if it works or not. So for example, here we have high print, we have this high clear, we have cleared it. So for example, when I something else, so for example, hello prints, this is our hello, then clear it, clear, which means that it will destroy labeled. So that was the video for today, and I'll see you in the next videos. And stay safe. Bye. 21. Application that open picture using dialogs: Hello everyone. Today I will show you how you can create a file dialogue using Tkinter. So if we have, for example, a folder or a lot of folders does has some pictures. And we want, for example, to take this picture and put it in our app. How do we do this? So the first thing that I will do, I will show you how you can take the path of how you can open a dialogue file to see where, where we can find this picture. After that, we will put it in our app. So the first thing that we have to, we have to use Tkinter, use an objects from the ticket a liability which is File dialog. So from ticking, hello, I'm sorry. T, Tkinter. Import file dialogue. Now we will import the Tkinter to from Tkinter import everything. Now the first thing that we have to do is to create the root. Root. It will TK. Now we work out what it's for the moment as main loop because I don't want to open it for the moment. I will let it like this. So what we want to do is to it when I want that, when I run the program and the program, the program will show me a window. Ask me to choose a file. For example, in this case, we will choose a picture. After that, we will use this picture for our app. So to this, we will use the function. For example, root function is routes.js file name equals. Here we will use the file, the file dialogue, as we said, from using Tkinter. So File dialog that here we have asked fine name. This function will help us. This function will open the window that will ask which file does we want and which type, etc. So here we will type what we want. For example, if you, if we will have a new window, this window should have a title. So for us, we will put it here title for example, I will put it, for example, open picture. When we will have a window, as we did with roots with Tkinter, have ruled that Title and we change the title. If we have, if we do this, we will have a new title for our app. Same thing here. This title is for the window that will ask us to choose, to choose the picture, sorry. So the first parameter is this one titled Dan. Second parameter is the file types. Which types do we want to open and put it in our program, etc. So we will make his life this file types. And here we will open this parentheses. Inside the parentheses, we mean we make any type we want. For example, if you have to, if we want to select two types of images, for example, a will take PNG and JPEG. So to do this, we have to put every type in parentheses services. This is the external parenthesis, and here we will make another one's, this one, for example, this for the PNG. Then we may cover then the second one for GPG. If you want to use a lot and other types, we can just add the comma, et cetera. So for the onwards we will use just this 21 and this is one for the PNG and 14 GBT. So inside this parentheses, there is two parameters that we have to do. The first thing is the title. I will show you where we find this title. I can show you for the moment because we didn't finish the program. So we make it for example, this is a PNG file. This is the title of which type we want to open. And here we will write the type that we want, which is that PNG. But before that we have to write, for example, if we want to open a specific photo or picture or something like this. So here we will write the name of this picture or something like this. But if we don't, there is no specific thing we will make. Star means everything, everything that's PNG, we want to see it. After that. We will open it. Or I don't know if you can use it wherever you want. So the second file type that we want is the DPG. So we will just write here the title, which GPG files or file doesn't matter because it's just a title. Then here we will make emulating that GPD. If you want, for example, if you want to open everything. And we, every time we have I just star like this star. That star means everything, every name that every time. But for the moment I don't want to use it. I will let it just like this. I want to open just the PNG and JPEG. If we run our program, you will see there is a problem here. I will see why. And there is started. It is always a program which is, I think that's, I forgot here, parentheses. I will, okay, it is working. Now. As you can see, we have, this is the title that I told you about. For example, here we have PNG files. So here this is the title that we want. Then if we want, the GPG will just changes here. For example, GPG, we have these pictures are in GBG side. It doesn't matter if we do this. We have we will see nothing because we didn't do nothing do you just open it and we just took the path of this picture. If you want to see what's really dysfunction. If we printed out from, you will see by yourself print routes that filename. You will see what we have. For example, if I will choose this one, you will see here, this is the path of the picture. This is the folder and the D and the folder projects and the picture. So as you can see, we can use this thing and we can always use this path to open a picture and put this in our app. As you can see, when we use the function, the library, the TK image, image SDK, sorry. We use the path to open a picture. So you can use this same path to open a picture and put it inside our app. So we will do this. The first thing that we have to do is to make a button because I don't want, that's where I went. I run the program. This picture opens directly. As you can see, this is the picture that we've chosen here. I forgot to tell you about this is opened picture as you can see here. So I will do, I will make a button in the roots so that when I press, when I click the button, after that, the way you will have another window to ask me for the fight. So to do this, we will have, we'll just click, sorry. We'll just create the button. I will call it, for example, open up an equal for example here button will put it in the root. After that, we will make it text, which says open. I will make some but X. But X I will give it, for example, 40 but equal 10. Then after that, I will packet. But open was I am doing here that part and the parenthesis. So here we have to make a command because as I said, I want that if I click in this button, I will execute this fine. Which means I will, I will create a window that will ask me to choose the file. So here I will call it, for example, open, open pig for open picture. So here we will take all this lined control eggs and we will define a function, the open pig. Then here we have the parentheses, then columns, and this one slide. I think that it works like this. I didn't know. I have to put it in the main loop like this. So here we have this is too small. If we resize it like this. Sorry. It doesn't matter. If I click here, you will have this window. I will make a site to make it make it better. I will give it geometry. I will give it four by, four by five. So here we will have this window. Now I want this button in the bottom here. So what do we do? I have I have to use something I didn't told you about the frame. It doesn't matter. We don't use it a lot. But in this case I have to put a frame here. So that's if we have frame here, we can have the button, the button here in the bottom of our window. So to do this, we have just to create a frame as we created a lot of things like labels, etc. It is very easy. So we'll make it like this will give us a new frame. Then there is a function frame. We will put it in the votes than there is nothing else. We will just choose the width and the height will make it like the window as we have, so that we will push the button down. So here we take the width, will put it for 100 as the window. And for the high. I've, I will give it 450. Now. Sorry, I didn't spot the packet here. Frame that back. As you can see, this is the frame. Now. You can see that the button is in the bottom of the app because we have frame here. If we want to see it very clearly, I will change the color so that you can see it. So I will make it BG equals red just to see it. So as you can see, this is the framed as we have created in color red. But if we don't use it, we will just, just to push the button. I don't need it to do another thing. So now what should we do is we have just your create or to create. The first thing that you have to do is to import the libraries. So from PIL, import image TK's, sorry, multi image, image TK than image, as, as I told you about image. Now, you can see that we have these two libraries that we use, the library below as always. So now what should we do is just to use this object to open a file using the path that will dysfunction return. So we will use the return of this function as a path to open the picture as we will transform it by using image SDK. After that, we will packets in the window, which minimum packet in the frame. I will show you how to do this. So here we have. The first thing that we have to do is to open the image. So I will call it, for example, big picture. Picture equals for example, image. This is the object, that problem. And here we will put the path, as we said, this route, that's fine. Name, when we print it, we should have seen that was a path. So we will put it just here to, to open that image that we want. So here we have roots, that filename. So if we put this one, this function open, we'll have the path which is what we chosen here. So in this case we have opening an image and we put it in the variable here. Now, if we want to put this in the indie up, so we have just to use it in the function which is image dk. So we will make it like this. For example, the new big Omega, just new. Here we have image TK. Image, dk, sorry, TK dot photo image. And here we will pause the picture that we want, which is this one. So if we do this afterwards, we have just to put it in a label which is labeled equals label. But before that, we have put the label inside the root. But now we want that. We want that the labeled with B upside the frame that we have created because we don't need, we don't need the frame for the moment. So we will put it just like this in the frame. Then here we have, we have, we don't know, we don't want to meet to make a text. So we need an image and here we put a new actor dots, pockets. So new that back. What's passed back like this. So we will see if it works or not. So we have, we will put this one. As you can see, there is an error here. Why not parks, not new, which is five, want to pack the label, not the image. So here we have bark like this. So we'll run it and we have here, we'll select this one. It is not opening. Why? Because I know why because the problem is in the size because of we have the size of the picture is too big in this one. In this case, we have to resize it. We have to make it small so that we can see it in the app. So to do this, we have just two. Use the functions that we have. For example, here we have picture. Now I will make a picture, for example, I will resize it. I will put it in another, in another variable. So before does I want to tell you that there is something I talk, talk about. If we will use frames and not frames. If we want to put pictures inside, inside the app, but we will create the picture inside another, another function which is, in this case this picture is a local variable. It is not a global. So we have to put his global so that we can use it in the root here. So we will make it just like this, just here. Global. Then have the picture which is new. Mona glow, which is this one. Global new, which is this one. I always see if it works. This time. You can see this is the picture, but as you can see, we can see the whole picture because it is, the size is too big so we have to resize it. We will put it in the same size of the hour window so that we can see it. So we will use the function which is this one. Picture. Dots resize it. Then here we will put the functions that we want. So what we, what we have here, we have the, we will change. We will give it as the same thing here, not we would put it at the same, same size of the frame because we want to put it out upside the frame. So we will put it like this one. Where is it size? The size, which is 400 and by 450, then the second parameter will be as much as we did before. Image dot D alleles. So in this case we have decided the picture and you need just to put it here, for example, I will put it in the new, what's new? And opposite? Peak, resize, resize it, picture this one. So if we want to put this new picture inside label, we have just to put it here. The first thing, we have to make it like this. To make it you're ready to put it in the tech engine up. Here we have this one and this new, I think that's it. So here we have, this one will open this picture. As you can see. Picture is resize it and put it in. And it is put in our window. So if you want to choose another picture, as you can see, you will just pull press here and this picture for example, et cetera. So that's it for today. I hope that you like it and I see you in the next video. Stay safe. Bye. 22. How to build a login page for the instagram: Hello everyone. In this video we'll put together all what we learned before, like buttons and trees and labels. We'll put it all together and create a simple application. So the application will be about the Aztec ground, the login page. So we will put the a window which will ask for the username and the password. If we will. After that, we will make a program that will compile if the username is, if the username exist. So it would rights, for example, high ID and username, or it will write, try again. So let's start. The first thing that we have to do is to create an undoing them. So we will do it from 0. So we will import tkinter from taking term. So import everything. So here we have imported the window. Now we will create the root, roots equal TK. Now we'll put it in the main. We may look. Now the first thing, we will do some changes on our app. So we will make the window, for example, geometry. We push it for 400 by five. We will see there is, sorry, I forgot to run the correct project. So this is our project. As you can see, this is the window. Now. I will make it changed after if we, if we weren't. So now we will change the color of the background, which mean configure. Now, sorry, BG equals I changed. I choose this color of the mine. Benign. We will see this color. Okay. This is like a pink or purple. Now we'll change the title. So roots point title, we make it as tight as tight. Now we changed the icon. I have already converted this picture to an ICO extension, so we will put his in the icon. Now root point, I can, here we have I done that. A, sorry, ACO. What it is. Now, we see our window. This is the window, this is the background color. And here we have the icon and the name, which is Instagram. Now we start putting something, some, some items on it. The first thing that we will do is to import the picture. We will, I will use this picture for example. Now. We will use it as we did before. So peak for example, of picture, acorns, photo image. Now, write the name of this picture which is star dot gif. Sorry. Now we will make it in the label, equal label. Now we'll put it in the root, then image, a colon and picture. We see how does it, how does it look? Sorry, iPhone get two buckets. But we will start using the function, the function grid. So I will use it here. We have les dot grid than rho equals 0, then the column, column equals 0. Then I will do some span on this. I want to, I want this picture to be in two columns. It will span two columns. So who is right? It's like this code. Column span equal to. We see how does it look? Is not here, why? Law? But we see we have here image, kuan picture. Sorry, I forgot to write here file. Now we have this picture. We will make some padding on it, sir, We will make here. But x equal. For example, tutti I receive, if it is cool, we will add some, remake it. For example, 50, ten II, which is okay, now 70, 75. I want to produce in the middle. We make it's 85. Okay? This is a good one. So we will add some padding on the y. And so bad. Why? Just add this? Cool. Okay. This is, for example, the page. This is a picture which means, which says Instagram. Now we will create, I will make this here. Now we will create the label which we say is the username, which asks for the username and password. And we will create the entries too. So the first label is, we will call it user name. Pick one, labeled. Here we have, we'll put it in the roots than text. Text equal username. Now will make here, will create the password were equal label. Then we put it in the roots than text a password. Then we will. Use the function greed to package in the winter. So the first thing is username dot grid. Here we have the row equal one, then the column equal 12, column equals 0, sorry, because we want to put it in the first column. Then we have the password plus word. Post-war dot grid. Here we'll put it in the third row. Several equal to 0 because 0, 1, 2, then the column, sorry, equal one because we want, sorry, column equals 0 because we want to put it in the first column. So we will see how does it look. Here we have the username and password. We will make some changes. Here. We will make some padding in the, in the x and the y in the y because we don't need it in the x. So y equals 10. The same thing here. But y equal ten. We'll see how does it look. Here we have our two labels. We will make some edits ink on it here. So we will use the font, for example, the less it like this, None button will change the size. For example, we will take it 50 and we will see the same thing for this one. Control C, control V, me see, is good. For the moment. We'll change the background. So Vg equals, we copy just this one. Control C and Control V. Same thing here. Vg equal this one. So we have here these two labels and we need to add the boxes here, the box to enter the username and the bookstore enter the password. So the books, which means the address. So here we will make user name, then Box equal entry. Here we will put this in the root. Then the fonts will change the size of the font, so equals 50. Then here we will change the width. The width equal, we'll make it 20. The same thing for the other box, which is the word box, a, Q1 and Q3, repossessed in the roots, then forms a cone. 50 and the width, the same thing, 20. We will see how does it look? Solid? I forgot her. Two packets. So here we have this two labels. No, now we will make, we will use the same function which has agreed to pack these two boxes. So here we will use, we've changed, we would make the row one. But the column, the row one, column. I'm writing a equal one because we want it next to the, the, the label. And the same thing here, user, sorry, did not use the bus were books that grid. Row equal to column equal one, sorry, one. We will make some padding here to make it in the same line with the labels. So bad, y equals ten. Same thing here. But y equal to. We will see how does it look. So here we have this entry to enter the username and this entity to use to enter the password. But as we know for the security or the password, we don't want that. The password will be shown, for example, as we see in the Instagram, etc. The postwar, the latest of the password will change, will be shown as stars. So we'll do this thing in our app. So to do this, we just need to use a function as a parameter. Here, password here. In the creation, sorry, the condition of the post-war here. There is a function called show. This function will show, for example, if we write four liters, it doesn't matter what, what is this letters dysfunction, we'll show in our entity, there's just the symbol that we will use it here, for example, we will make stars. So if realize name or something with four letters, our dysfunction, we show us just stars in the box. So we would show, we'll try it here. For example, if realize anytime we want it, we see it as stars. Okay? So that's what we want, for example, for a security or the password. Now, we will make some changes. We'll make the functions that we compound, the username and password. So we will make it here, for example, when j, we just need to create a button. For example, button for login. So login button. And here in the roots text login. Now we make x 81. I don't know, jersey, for example, contagious, too big. I think. I'll make it 20. Then bod y equal to, I don't know why I put it 12 months. I will change it after if I don't, not, 1212 is two, I will put it eight, for example. Then here, the font. I don't want to change the font. I will list it like this. Then we will graded here. So we have here the login, login, that great. Now rho equal to three, then the column equal 0, and we'll respond it. We will just, we wouldn't want this button to be in the middle. So column span equals two, then we want to make some padding. But why a coin 10? I will see if I need some padding on the x, I will. I will just make it bigger here. Where is it? Where is it? Where is it? Here? Here. But why? Login? Login. Where is the Logan? Did we create the login button? Password and green, this is the real positive 30, 13 or so as we can see, this is the button. Now, what we want to do to do if we write here for example, amine, then here we will write some, I don't know, for example, admin or something like this. The password here. If we, if this username with this password exists in our program, we'll see Hello. I mean, for example, as we will see, try again. So we will use it like this, really make function or a command for our bottom. Then this function will come and show us what we want. So here we will make it. Sorry, I am writing command equals. I always call it luck. I will call it just not. Okay? Now we will define this function. Here. We have the long, now. You have here, define it. So the first thing that we have to do is to get these two to Texas that we have in the username and labeled. So you can make it here for example, user equal username box. That gets, we have here we get the username. Then the pass. We'll just add w because if we just use the past, That's what that word is already reserved. So we can't use it for our variables. So we make it pass W for a password for example. So here we have password box dot get. Now here we have the username and the, and the texts that we have in the books of username and password. Now we will compare it for example, we will make variables, for example, u equals for a sample mean. Then before the password equal, same thing. I mean, now we will compile if the username is that we have in the, in the box is equal amine and the post-war economy. In this works, we will write, for example, hello, I mean, as we will try, we will write try again. Now, here, what should we write? For example, if user equals u and plus w equals b. Then here we will write for here when I create the label, for example, lay equals label. And we will give, will put this into roots. Then here we will give it the text. I will make the text here before that's really creates. For example, call it text equal, for example. Hello. Then plus the user name. For example. Call it the name or the user, record user because the user is equal to username, point gets. So if we want that, this label will write hello, the username, for example, hello, I mean, so here we have labeled texts equal text. And we changed the font equal. For example, on tolerate I like this font. Then here we would put it in 20. Why not? And we'll make some padding on x equals 10, then Part 1 equals 2. Now, we will make, we would use the function grade two packets. Now legal gray grid, for example, row equal in which row we are in the row 4. Row 4, then column equals 0. There will make column column span equals two, n equals 2, and that's its rights. And after that we will make some changes. So for example, here we have amine and the same thing. I mean, we see Hello army. Now we need to do to write the LS function. So here we have, this is the if. Now we will rise the else. The same thing here, just we have, we will copy this one and sorry, we create a label here and we will give it the texts try again. So we see we would make another tank here and another thing here. So we see, Try again, this is not what we want. But if we are right here and same thing here. I mean, we see that we have hello amine. And if we were, if we have a lot of users, for example, the campuses in July and we will make a loop that will chain, will compare every single item or every single user with the user last we have undulates in the buses. After that we will write, for example, hello user or it will write try again if the user is not yesterday in our program. So that's the example for today, and I will show you another things for, for your app in the next videos. So stay safe, and I'll see you in next video. Bye. 23. Create a second window: Hello everyone. Today I will show you how you can create a second window using the first one, which mean that we will have doing those or more than two. So the first thing that we will have to do, we need to create the first window, which is the main one. So from ticking, sorry, ticking. Import everything. Then we will create the roots or the first reader or the many there. We can call it anything we want. So TK, then we put it in the main loop. Just a remark we can, we can write routes points main loop or we can just write may mainly without using this because we have just one project here. We know that this may look is for this window, okay? We can write anything you want, or if we want to write it as roots point meno, or if we want to make to write it just main loop, it will works. Okay? So we will make some changes. For example, routes, that title. We will call it main. Then we will change the geometry. Geometry. Here, for example, we make it 300 by 400. Then we changed the icon. So root that icon. Here, we have logo dot c 0. So we seem hour window, this is our main window. Now we will add new window. For example. We can add any, if we want to add three or four, anything we want we can add is for this moment, I will show you how you can use, how we can add just one or two. But you can use any window you want. It depends to your projects. So to add new window, we will use a function called top-level. The function top-level, we'll create a new window for us. So for example, we will put it in a variable as always, we'll call it new. So this is the function top-level. This function will create a new window for us if we write this line two times or three times, if we use this function two times, we will have junior windows. If we use it three times we have three new windows, etc. So here we have, this is the main window and this is the second. As you can see, we have the same name as the main because we didn't change it, but we can make lots of changes here. For example, the same functions that we used for the roots. We can use it here. For example, new butt tighten. We'll call it the second. Then if we want to change the icon for the moment, I have just the Instagram icon that we used before, ACO. So you can see here, this is the new, the new title and this is the new icon. Then we can change event the geometry, for example, mu that geometry. Then he would put it, for example, I don't know, Cherry 300 by 300. And here we have our window. We can change the background color, etc. If we want to add another new window, for example, we will call it new to, for example, reuse the same function top-level here. And you will see that we have, this is the first, this is the main window, this is the second. This is the third. We can change the name and the icon. We can change everything we want as we did with the main, the main window. Okay. When we close, as you can see, when we close the main window, the other windows will close automatically. But if we close just the second or the third window, the main window will stay here. So I will show you how, for example, if we want to put to add the new window, after that, we press on, we click a button. So we will do is we will take this all because we don't need it for the moment. Now, we will do this. We have to create a button. After that's when we press or click on this button here, Create the new window. So we would use it like this for example, but it will. But then here we'll put it in the root because we want it in the root. Now, we will make to attest taste. We call it here, for example, add. Then the font. Formed a equals. For example, drawing. Then the size I will produce 25. Then I will make some padding here because I want it. Big, big button. So, but x equal, I don't know, 20 or 30, 30, then y equals 20. Now we will back this, sorry, this button bug, but that back and make some padding. But the y equals 40, we see our button. So this is our button we want. Then if we click on this button, this will create this new window. So I will change the background of this, of this window because I don't like the white one. So roads that configure. And here we will make six zeros to make it black. Wait, sorry, I forgot to break BG for background. I put 700. There is no code with seven zeros. So this is our button Add. Now I want that. This window shows after that I click on this wasn't, if I don't click this button, we want have this window. So to do this, we just have to make a comment here. And this command will create a new window. So we call it Create. Then we will define it. The Create, then the parentheses. What we said, we said that we want after that, we, we click in this button, we will create the new window, which means after that. After that we will click on this button. We will call this function. So the creation of the new window, we will put it in the function, which means if we call the function, we will create a new window. So we will put it like this. Control X. Control V means that when we press this button, we will call this function. So this function, what we will do, it will create a new window, then change the title and I can add geometry. So we will see if it works. So here we have, if we click this button, we have this window. If you click another time, we will have another one, etc. Because in every time we click the button, we will call the function for another time. So when we call it, we will create a new window, etc. So that's it for today. How to create a new, a new window. That how to put his in, how to create it. After clicking the button. In the next video, I will show you how you can make some editing and some buttons in the new window. And I see you there. Bye. 24. Pack some stuff in the second windwo: Hello everyone. In the last video, I have shown you how you can create a new window, which means a second window, adding, adding it to the main window. Now, I will show you how you can pack something on this new window, for example, a label or button, etc. In this video, I'll show you how you can use or how you can add a label. But it is the same thing for the other items. You can use. Same thing for to use a button or accidental. So to use to add a button labeled, sorry, the first thing that we have to do is to create it as always. So we'll create a label like label. Here, sorry the function. And here before, before that we had, we were will not hear the name of the launch window because we had just one window, but in this case we have two windows, but our projects that we write this label or we put this label in the second window, which is the new window. So here we'll write the name of this new window, which means which is new. Because if we write this, as I told you before, if we write here the name of the window, for example, you miss this does label is special to this new window. So, so here we have the name of the window which is new. Now, the other parameters is the same thing. For example, here we make the texts. For example, Hi, how are you? And you will do nothing for the instinct for the fourth exercise like this. But because it doesn't matter for the moment, now we will packets. So we just write here loved point pack. In this case, we will pick this label in the new, new window. So we will have the same thing here. We have this, but this window and the button, if you press the button, will have this new window with this label, which is Hi, how are you? But if we press the button another time, we will have new into another window. And if we press another thing, we have new window. But it's not professional because the project saved us. If we press here we will have new window. But if we press another time and this window is always, always open it, we can't, we want, we don't want to have another window. So if we have, there is two cases. If we have no window and we press the button, we will have, we will create one. If the window is always opened. If we press here, we don't want to have another one. So to fix this, we'll make some changes in our program. The first thing does we have to do is to declare a variable, a temporary variable that will take the role of the opening window or closed. So we will call it, for example, up, or I will call it B for example. So I will make it global, so global variable b. And here I will put it outside the function. I will give it the value 0, initialize it to the value 0. Then this new window, I will put it global tool because we need it to be global for the conditions. Does roots come next? So we'll call it here nu. Same thing here. We give it, give it a place in the memory. So we will give it the value none, which means empty. So here we have these two variables. The first variable is B is a temporary variable. We will take the role of the closed window or opened. Then we have here this global variable which is new. We have the value of this window, the new window. So i, we cut all this fourth moment. Now at all, this, we'd labeled because the lead, the creation of labor is included with the creation of the window. So we got all this. Now as we said, we want that if this temporary variable, for example, if this b equals 0, means that we haven't created any. If, if the v equals 0, that means that we haven't created any windows yet. So here we will create a new one. So we will put these lines of code which will create the window and give it the name. And I can exedra and labeled two. Then if this b doesn't equal 0, means that we have created a window. But if we face the window, there is true and other cases, there is the first case which is we created a window, then we closed it. And there is another case which is we created doing there, but it's all always open it open. So in this case, we will create, will make another. For example, here we have Else, else means does this b doesn't equal 0? Now we will do this, will do a condition to verify these two cases, which is we have created a window, then we close it, or we have created a window, but it is always created. In this case, I forgot something here if we create a window, so in this case we have created a window. So we'll put B equals 1 means that if b equal 1, that means that we have created a window. Now. Here we will make a condition that is a function called Info Windows info exist means this function we will return true if the window is open, so we will use it here if knew that info exists, means if the window exist, it is not a closed, it's always opened. In this case, we will push b equal 1, sorry, equal one. But if it is not, it doesn't exist, means that we have created a window, but we closed it after this. In this case, we will create a new window, which is we will put these lines of code so it see if it works. Here we have the main window. If we press the button, we have this new window if we present at the time. So if we run our program here, we see that this is the first window. So there is a problem here. We will see the frog. So we run our program. Here, our window. So up. So if we run our program, you can see this is our main window. If we press the button, we have this new window. If we press another time, sorry, there is new window, there is a problem in the code. We see it here. This is the problem, the equals here. So we will run it another time. This is the window. If we press another time, there is no other windows. This is just where there is just one window. If you close it and we press another time, we will have this new one. So that was the code of today. How to make a label in a new window and how to fix that problem too. Don't open a lot of windows in when we press the button. So I see you in the next video and stay safe. 25. Make a simple application using the main and the second window: Hello everyone. In the previous video, I have shown you how you can create a second window using the top-level function. Now, we will, I will show you how you can do some work on that second window. In this, in this case, I choose to take this project or this part as a simple project. In this project we will create a window, which is the main window. Then we will put two buttons in this window. The first button will create a window to sign in, in the Instagram. And the second button will we create a window or open a window to sign in on the Facebook? So the first thing that you have to do is to create that's main window. So we'll do as always, from taking the import everything. Then we will create the roots. Or we will call it, for example, Maine or not. We can't use this route. Now here we will take the function t k, then we will make it, sorry, we make it as main loop routes, that main lobe. Now we will do some changes in this main loop in this window. So we changed the title. For example, we give it S. And for social media, then we will give it a logo. Or I can, that I can. Here we'll put logo dot ECO. Now we will change the background color. So it puts routes that Configure. Then here we will put the background. So a BG, which shows a color here you can use these websites, for example, I will choose this color. Why not this one? Now we'll take the code and put it in our program. Here. I forgot the condition marks. Control, control V. Now we will change, it, will make a change geometry. So roots that geometry. And here we'll put, for example, 400 by 400 by 400. We will see the window. Sorry, I didn't run it here. Run than this one. This is our main window. So we will put here a title, for example, social media. And here we will put the first button and second button to open the window for the ethogram and the Facebook. So we'll create that logo or the title. So we'll make it as label. So we'll make it as, as, um, okay, and he will change label. Then we'll put it in the root. After that, we will take the text equal social. Media. Then we will change the font, will put it as on Android, my favorite. I'm sorry. Then we'll put the 25 and that's it. I will change the background color to forget this BG equal than this. I will take the same word, the same color of our background. Then I will change the color. I will see how does it look. Sorry, I forgot to. Packet. Packets will say we will take the reduced the function grid. So as m dot grid, we put this in the row 0, then equal 0, then the column 0. And we will do some column span. So column explained equal to, we will see how does it look. This is our width. We'll do some padding here. So it make x equal 10, then y equal 20. We see how does it look? Of K will add five here. We make it 15. Now, it is great. Now we will add two buttons here, but the first button for the Instagram for example, and second for the Facebook. So to do this, we just need here to create the buttons. For example, the first one is Facebook Equal button here in the room than text equal Facebook. And same thing for the Instagram. So Instagram equal button. Then here we'll put this into roots, then the text, a stagger. And we'll make it in the grid and you will see how does it look too. So we have here facebook, that grade. Then we will put it in the row, a cold one, sorry, one. Then the D column equals 0. Then we will make column span to put this in the middle. Span, a cold to the same thing for the Instagram. So we will just copy this and paste it. So here we will instagram. And so we will see how does it look. Sorry, I forget to change here. So this is the first button, is it second? We will make it more nicely. So here we will do some padding. So but y equal, I will take it ten, just 10. But padding. Won't change the pathway. But so I will add some padding here to make the button mode bigger. So I will put it, but x equal, for example, Jersey. Then bod y equals temp. I will see how does it look? This is a good one. We'll do the same thing for the other button. So like this console, see the Control-V. Here, our two buttons. Okay, now we will create two, we will create two windows. Window for the bad Facebook and window, second window for the Instagram. So what we want, we want that if we press that button, will create this new window. Which means that the creation of this new window will be in a function. And this function, we will make it as a command for the buttons. So for this one, we will make a command equal. For example, we'll call it creates F for failure. Facebook creates Facebook. Now, for this one, we'll call it, for example, command equal creates and I for Instagram. So here we will create these two functions. So def, create and F for Facebook. Then we created here. What did we say? If we want to create a new function, a new window means that we will use the function top-level. So if call it for example here phase and sorry, phase equal here, top level. Then same thing for the other function. For the moment I didn't change anything. Then cell death, dying create. Here for Instagram than the parentheses column and stop, Sorry, as the top-level. Same thing. So we will see here our two windows. If we feed here, we will have this one. And if we click here, we have the second one. So we'll make some changes on the icon, etc. So for the Facebook, I have already created an icon for it must create. I have just converted here, what is it? What is it? Facebook. This is I have downloaded from Google and I convert it to the ECO extension. I have shown you that website that you can use for free to do this conversion. So I will just write here face that I can. For example, I can then I will put the name Facebook, that's ECO. Then the title, I will give it Facebook. So if I face that title, and here we call it Facebook, sorry, Facebook. The same thing for the other one. We give it here for example. And start that title. We'll start by first one. So here we give it the name that you see o then announced. But title. We'll give it the name. So we will see how does it look. This is the main, the first one, and the second one will change the geometry of this Jew windows. So we will put it in the same of this one. We will just copy this Control C, Then here, phase control V, sorry, months here in the new line. The same thing here. And then Control V. So here we have this new window, and this is the second one. We will change the background colors. We will put this one and blue and this one some purple or pink. So we will use just this website. I think I will take just this one. I will take this one. So copy this. And here we will make it to Instagram. So and that configure. And here BG for background and the quotation marks, and this is the color. The same thing for the Facebook. So choose some, some blue. So we'll take this one copy. And in the Facebook function we will make this face that configure and BG for background and the quotation marks extra. So this is the main, this is the first window and said second. What, what, what do we want? We want to put here, for example, a big title saying, as I grab this, here, we will put a title saying Facebook. And we put some entries and labels. For example, a label here saying username and the entry for us and password at the entry for it. Same thing for the Facebook. So what really we say we will do is here, for example, Madrid labeled here facebook, and we replace it with a comment create. Teacher, for example. Now, put here, creates the window. No, this is here, condition the window and here the making the title. So it puts it in a label. So I will call it, for example, logo, the F for Facebook. So labeled here we'll put it in the face window, which means police in development phase. Then here we make the text equal Facebook. So we changed the font, will put it equal propaganda. I like this guy. I like these phones. I forgot here. Gandalf. Then here I will put the size, for example, 25. And we see how does it look for or Facebook, I forgot to bucket. So we'll put it here, for example, in-degree 0. So logo that grade, he'll was integral 0. Then the column 0, because 0. Then we will make some column, column span. Sorry, column span equal to, we see how does it look after that? We will do some editing on it. Facebook. This is, I will change the background, will, I will put it as blue as this one. And we will do some padding in x. So we will put the background color here. I will copy this. Control C Then here, and Control V. Then you will do some paddings. But x equal 85, I think we see. Now it is two. I will make its 50. And that's it. We have this title in the middle. So this is the title of the Facebook or logo, or you can call it anything we want. Now we will make the same thing for the histogram, so we will just copy this one. And I am too lazy to do this. I will copy just this one. And we have this here. We call it as here. Then we'll put it here, I and I here. And we change the background color. So we take this one control C, control V. We see there is a problem here. Great. Logo. What is the problem? I forgot here, the parentheses. So this will work. So here we have asked for, I forget to change the title text. Here. I will make it straight. Now. That's it. This is for the Facebook and this is for the Instagram. Now we will, I will do some padding on the X here. I will put it 45. This is, and I will put it 45. We see, etcetera. So I will take it for t. Why not? It is good. Now we would add the entries and the labels for the username and password for each. For Facebook and the Azra. So here we will make, for example, this photo. We start by Facebook and adding and trees and labels. So the first label will be for the username Sarah. We'll call it username, user name. Then a equal, a label. Here we put it in the face for Facebook. Then we will give it the text here, username. And the same, we will change the background, will put it like this. Just copy this and paste it. Sorry, this one. Then the same thing for the password. So password equal label. There was in the face windows than texts equal world. The same thing for the font. So this is the background, sorry. So we will see I didn't packet now. So here we have username, that grade. I will put the row for the low. For the username, I will put it in the row one because we have this logo in the low 0. So I will put it into a one, then the column 0. Yes. Then I will make some padding, so y equals 20 and, but x equal 10. The same thing for the password. So we will just copy this one and paste it. Here. We have password. We see how does it look? Sorry, not Instagram, Facebook. This is the password. I forgot to change this one. I will put it here too. So this is the username and this is the Facebook. I will take of this budding because it is, because if we let it this like this, we will have 20 in the budding of door. We have padding y of 20 for the first, L1 and 24 the second. So we will have 40 between these two labor. So we'll take this off. The second doesn't matter. So here we have Facebook, this is the first second. Now we will, I will take off this budding on x. We see. So this one. Now we have to add some engineers here until you for the username and algae for the, for the password. So we will make it just like this. Here. We have box username. For example. Name, Box, user name. Then I will put it for F for Facebook than equal entry. We will put it in the face. Then I will change the font. I will change it after I wish the size or the moment I will make it's none, then I will make it 50. Same thing here. I will change the font. I will take this line, control C, control V. The same thing here. Now we'll make the box for the password. And for Facebook. Now, I will put it in Andrey that I always in the face book. Then I will just make this one. So after that we'll have two gradients. Now here we have books for username, that grade. Here it will put it into row 1. But in the column one, because we want to just next to the label which is, which says username. So username that equal one. The same thing here for the password. So bogs password. But grade. Then here we have row two and column one equal, equal. So we see, here we have Facebook, this is this, this is the first column, and this is the first box to you to enter the username and here to enter the password. So I will make it bigger. Here we have to be handled. I will put it four by five base than not this one. Not this one. I will change it here. Facebook here I will put it for, and here I will put it five. Okay, Facebook. This is for Facebook and this is for the password. We'll do some padding on the y. I will add here we have 20, I will put it 30. Now we will see Facebook. This is not that good. I want it, I want to move it down. I will put this one here, control C. This I will just here, 50 maybe. Okay. I will take it from here, and I will put this in the first controlled eggs and Control V. So this is better. Now, as I told you here, and we will enter the username and he will enter the password. I will change here. I want to, I want that the program shows us just starts here for the security of the password for example. So we'll just here we will put in the password the function show equal Start. We see it Facebook. So there is a problem. The function show password. Sorry, not here in the box x, the books of the password here. Now we will see this is Facebook, and here if we write anything, we see it as a start. For security. The same thing, we will do, the same thing for the Instagram. So the first thing that we have to do is to change here. We pause it for a 110 here, five and we will create, these. Two will create the, we have, we have this labeled, we've created all this, will just copy this from here. Contour c, The Control V. Here we have, we have to change this one. And the same thing here. Stop. And here two. And last one after. So we have here and now we will change this boxes. I will tell you why I am changing, changing this because we need it after. So here we have I and here. So as you can see, this is the window I will change this color after. So we have here the same thing, and here we can see the password. I will change this color because it is blue for the Facebook. So I would just copy it from here, columns of C. Then I will put it higher. And for the password too. So as you can see, this is the username and password. For the moment, we have created these two windows, one for one for the Facebook and one for the Asakura. With what we do now, we will change the will make the program does. If we have, for example here, then the password, the username, admin, and the password. I mean, the same thing for the Facebook and Instagram will print here, for example, high amine, which means high plus the username. Or it will say to us, try again because this username does exist in the problem. So we will let this in the next video because this video is o is very long. So I will let this function for the next video. So I show you the Stay safe, Bye. 26. Following the creation of the app: Hi again. In the previous video, I have shown you how you can create these two beautiful windows. The first one is for Facebook and second one for Instagram. Now, I will show you how we will use. We will add some functions and buzzers. That's if we add a button, for example, here, if we press that button, the program will verify if the username and the password are correct. In this case, it will print, for example, here high then the product, the username als, it will print try again. So to do this, the first thing that we have to do is to create these two buttons. So it is do is you will do is as always. So we will start by Facebook's. So here we have, we will call it, for example, login. So it will be a button, will make it in the phase for Facebook, then text equal. Then here login. And I will make some padding here in the x, x. So I will make it, for example, 40, then y equals 20. And that's it. Now we will make the grade. So for example, here we have login, that grade will put it in the row tree. Then the column, columns, sorry, colon equals 0. Then we will make some column, column span equals two. We see how does it look? We have Facebook, this is the button. We make some padding to put it down. Just a little bit. So close this. And here we have, for example, at bad, why? For example, I will put in churches that it's Facebook. This is the button will let displays to try it. For example, hi, hi plus the username or I'll try again will that displays for this, for the text. So we do the same thing for the other window, which is for the histogram. So here we created a login login button, the same thing here, we'll put it in the past for the Instagram's text, a quarter, sorry, login. Then we'll do some padding. The same thing about x equal 40 than, but y equals 20. And same thing here for the greed will make it here, for example, login, sorry. Login dot grade into row three, then the column. So the two equals two, then we will make column Spain. Spencer is what it is. Column span equals two. We'll look how does it work as trigrams. Sorry, I forgot something. Here. We had two right here, come 0. Now, this is our button will push it down too. So we would add the year pad y equals Churchill as the first one. So here our two windows with the buttons. Now what we have to do is to create two functions, one for this, for this window, at one for this window. So that if we press this button, take that text here for username and the password and verify if this username exists or not. So here we have to write, we have to live these two functions, but actually before that we write it. We have to put it in the, we have to put these functions is in the buttons. So we have the first one for the Facebooky and this is the button Facebook login on Facebook. So here we will make it the command. A course, for example, will make the name login and Facebook. So this function will, with doing this work, we take this the username and the password and put it in a condition and verify if this username or if this person exists or not. But before that, there is two ways to do this. The first way is to push these two boxes or these two variables as a global variable so that we can use it in another function outside this function. Then there is another, another way which is more better than this. We will put the, this, the texts that we have in this entry and the text that we have in this entry as a parameter to this function. Then if we declared this function which is a login, facebook will take these two parameters and do the condition with it. So to do this, that is, we can't just use here, for example, the parameters with this, for example, commands than equal the function and the command. We can't use this. Then we have to add a keyword which is Lambda. Then columns. After this, we can use functions with parameters. So here in the parentheses, we will write the parameters. The first parameter will be the username, and second parameter will be password. So to get the username from the box, we have to write, just hear you, books, username, Facebook, that get not so great, sorry, get this one. And the second parameter will be the password. So Bob's for the password that gets here. Now we have these two parameters. The first one is username and second one is the password. We have to declare or create these functions. So we'll go here and login, and Facebook. Then the parentheses here we will put a comma B. A will take the username or whatever, make it U for username and P4 and password. That the columns here we will do the condition. It is very easy. So if The username that we have in the parameters are that we have in the boxes equal to, I will put it for example, I mean in my name, so amine and the password. The same thing. I will put a quote. I mean, if the username admin and the password equals, I mean, in this case, we will, for example, for the moment to try if the program works or not. We'll just make a painting. For example, print hi plus u for the username, then ends if this is not mean. So in this case we will print here, try again. So what we see if it works or not. So here we have the Facebook realize here, amine and here, same thing. We see login. As you can see here. We have the command here we have high amine because the, we have altered the correct username and password. So if we will try another thing, for example, I will make something like this. As you can see, we will print here try again because this is not the correct person. So, but we don't want to put this text in the command here in the Cloud with data. We want to make it in side this up. So if this person exists, it will write here Hello, I mean, in this place, then if it is not this person right here, try again. Okay? So what we do is we just write, sorry, we have to make a label in this liable we will print that's what we want. So if username equals amine and the password equals AMI, in this case, we will create a label. For example, I will call it text. Then here label. We will put it in the, here. There is another case does I want to tell you about here? If this text, if this username exists. So we want to create a label in the Facebook application or in Facebook window, which is this one. So to do this, we have to put this window in it as a global, global function or global variable, sorry, global variable loss group of function. We have to put this window as global variable. Why? Because if we don't put this as a global variable, so if we let it just like this one, where is it here faced equals top-level, etc. If we want to use this window or this variable in another function, we can't because it is a local variable so that we can use it in another function. We have to put this in global. So, okay, so here we have two global phase. We can use it here, then we can use it in another function which is there. So we will put it here in the face than the text, sorry, Text, sorry, equal. Then we will put it here high. And space plus. The username will put some parentheses here. This one. And this one. Then we will change the font. So I will put it for example, phones equals, for example, llamas. Don't left. Then the size I would put it at 20. And we will packets or make your grade in the, in the application CRD text dot grid. We are, I think that we are in the row for, because here, here we have rotary. So we will put it in the row for n equals four. Then we will make it in the column 10. So we will make a column span. Columns span equal to. And we will do some padding in x. X equal. For example, I will put it 20, not 2000%, just 10. And for the padding of y, I will put it 20. Okay, We'll see how it works. It looks sorry. So here we have, if we write, for example here, amine. And the same thing here because we didn't write the code for the else statement. So here we have, I mean, I mean, in this case we have this texture that we have pushed or mislabeled. We have to change the background. I will put it as the color of the application. So which is this one? So I will take this and in the creation of the label comma and Control V. Okay? Now here we have, if we put here, mean the same thing here. You can see that this is high. I mean, we can make it bigger because there's just more. I will make it charity. Now, we will do the same thing in the other way, which is the end statement C or Control C. And Control V would change just text here. Make it. For example, try again. Okay, now we will see if it works for the try again, if will, if we just, if we don't write anything here, It's the same thing of that is another, there is no user, user here. So here we have always try again. But if we're right, I mean, and the same thing here, I mean, sorry, I think does a message here. We will see there is high. As you can see, we have high, I mean, in as you can see, we have here, the new label is on top of the last label, but we can fix it. You have just to destroy it last label and put the new one. So we will do the same thing for the Facebook and for the Aztec. And I'm sorry, so we will create a function for it. The first thing you have to declare is in the bottom. Here we have this button Login. Now here we will push it. So Command equals Lambda, then columns. So login function with Opposite eye for the Instagram. Now here we will take as a parameter. So the first one is the username. So box username. This one, I will put it after. That gets. And this one is for the books of the username that get that one. Now, we have just to create the function like this one for the Instagram. So here we have to do depth than login, sorry, login. Here, instagram, parentheses scholars. Now here we will write the same thing as this one. So we will just copy this one. Control C, control V. Here. We just need to write U and B. Then we make changes here, for example, and stop. And stop for us the graph, as you can see, there is an error here. Why? Because I think that I didn't put the window Asda as a global variable, as you can see. So in this function, this function doesn't know which, what is this valuable and stop because it is not. And standards as and stop because this function doesn't know it. So we will just write here, we have installed, we'll make it as global variables that are global. Stock. In this case, we have fixed this problem, so you will use it, we'll see if it works. So here we have, for example, Sorry, I forgot something else. I will change the color of the background of this histogram because it is not blue. So I will just take this one, goes from c, Then I will change it here. Yes, here. Control V. And for the IEP, now, I think that it will work. Here we have the Instagram if we just press. So I didn't copy the correct column. Yeah, I have copied just the color of the Facebook, so I will take this one, Control C. And here we have control V. And same thing here, control V. So here we have Facebook. If we just press without any writing anything or when price is just something like this, always, always have, try again. But if we create or off, if we write the correct username and password, We have here, hi, I mean as the Facebook. So that was the video off today creating this application with this too nice windows, one folder, Facebook and 14 for the Instagram. So I see you in the next video, and stay safe. Bye. 27. How to create or connect a database: Hello everyone. Today I will show you how you can work with databases. So in this video I will show you how you can create an all connect a database so that after this we will use it for our app. So the first thing that you have to know that we use the function, the database is with the liability SQLite T3, which is already included in Python 3. So you don't need to style it or download it or something like this. We have just important to our program. So the first thing we have to do so is to import, sorry, import. A skewed like IT. As, for example, will make its name base. With the name based as an object. We have an object base from the liability escalating. So to connect it or to create it, there is one function called connect. This function Connect will either create a funk database or we'll connected if we have already a database. So to use this, we have just to create a variable, for example, we'll call it data base. This variable, we have the role of our database, so we will work with just this horrible. So here we have a database. Here we will analyze the object which is base that we have created from liability. Then that here we write the function connects. This function connects. It will either connect our database to the program or created. In this case, we have, for example, or lights, for example, data base that the beak, the extension, the extension dB means that this file is a database. So if we write database does dB, the program will search if there is fine or if there is something like this in the project folder. If we have already a program file or a database with this name, the program will just connect it to our, our projects and we would work with it. Then if the program will not find it, in this case, it will create a new one for us with this name, which is database does dB. So there is three important things in database. The first thing is to create it or connected. The second thing is to commit all the changes. And the third thing is the closest. What mean this if we have, if we wanted to work with the database. So the first thing we have to take it and open it and take something or put something on it. After that, we'll have to clay close it. So this is how you do these days. Functions for this to correlate it or created there is this function to connect and to commit all the changes. If we have, if we want to do something in the core of this database, we have to put something or take something. This afterwards we have to commit the changes. To commit the changes will have just to write the function which is, for example, we have this variable does obeys that the function commits, dysfunction commits will commit all the changes that we have to do here. That means that we have to call this function. After that, we work with the database. Because if we put commits here, for example, we will commit the changes afterwards. We will do some stuff on the database here, on what we did here. It doesn't work. It doesn't be saved in the database. Why? Because for example, if you are working in Microsoft Word, fine. If you don't save every changes or every thing you add to your own projects, the program, the project doesn't, you will be saved. So the same thing with the database. If we will do something in the database, we have always to commit all these changes after that when we complete or our work, we have to close it. Actually, if we don't use if we don't close it, ourself is will be closed. After that we stop the program. But preferably we have two clauses by ourself. So we have to write database that close. Does, this function will close the database. This function will connect it. We will make a comment here, create or Aconex data. So that's our base. And this function will commit or the changes that we did in the database. And this function, we'll close the data base. So as I told you, there is these three important things. The first thing you have to connected then work on it here, for example, there is a lot of work. Then we have to commit all the changes that we did in this database. And at the end we have to close it. So that was for today and I see you in the next video. Stay safe. Bye. 28. Create a table in the database: Hello everyone. In the last video, I have shown you how you can create or connect your database to your program. Now, I will show you how you can create some tables inside this database. So as you can see, we have this file that are based bus DB, which is a database that we have created. Now in this case, if we will run our program, we want to create another one, but we will just connect this database to our program. Now, as I told you, we want to create some tables inside this database. For example, if we want, if we want that, this database, we want to start on it. Some users, users with the first name, FirstName, LastName, and the age. So in this case we have two head like a table like this one that is three columns. The first formed firstName and seconds for the last name and the third for the H that this was will be the columns of our table. And the rows will be the users, for example, the user one, this one user to the second row, etc. Now, to do this, the first thing that we have to do is to create a cursor. This cursor will circulate inside the database. So we will call it, for example, because we can't circulate with another thing. We have to create a cursor, and this cursor will create, will circulate inside the database to bring something or enter some text in the database or creates a table. So we'll use a cursor. So kill. So we will call it, gave its name cursor. Now we use it. We created using the function cursor, which is this one. In this case, we are in this line we have created, we have created the cursor. We would make a comment here, for example, create a cursor. In this lesson, we have case the cursor. Now. After that we have created it. We will use it to create a table inside, inside our database. So to create it, we have just derived here the cursor dots after, but you have to use the function executes, which is this one. Inside this function will rise all what we want to create a table. So we will write it like a string. So inside the quotation marks, here we have two keywords, which is the first one is create. The second one is table, which may create table. After these two keywords, we will rise the name of the table that we want. So for example, we'll call it users. Our table. We will give it name user. So we will have table like this one. Inside the database. We have these columns and this lines, which is the user, we will add. After that we enter the users will have these lines for the Module 3, just the columns, an empty columns. Okay? So we have to write here the name of the user of the table, which is users. Now we will make these two parentheses. Inside the parentheses we analyze the different columns that we have. So we have to write the name of the column, then the type of the data that we will store in that column. So the first column, we have the firstName, so we make it first, firstname, then we make a space. After that, we realized the type of this data that we will store in this column. In this case, the first name is a string, so we make it text. Then we have the last name here. So the lastName is to a text. So we put the texts, then we have the age, which is an antiviral because the age will make it 1, 2, 3 extra. So this is an anterior cerebral palsy. It's just like this. So if we run our program now, we will create this table inside the, our database. So as you can see, if we will run it, we have nothing here because this table is already know. We have created this table in the database. But if we will create, will run this program another time, we will have problem. Why? Because we have, if we create this table in the, inside the database with this name, we can't create another table with the same name because if we have a folder and we have file, a text file, for example, with the name user. We can't put another, another file with the same type which is taxed at the same name. We can't put two files with the same name and same type inside one folder. So we can't create two tables in the same database with the same name. If you want to create another table, for example, we can create it. We can create, for example, I don't know, for instance, this one for users, another one for workers, etc. But we can't put to two tables in the same database with the same name. If I wanted to show you, what if we run the program another time. You will see here table or table, the table workers already exists, so we can't use weekends create another one. We'd seen that if we want to create another one, we have just two. For example, change the name here and we would execute. In this case, we will create another one. So if we are working in the database, we have to create it. Just, that is just this line which is creation of the table. We will run it just once I am. After that, we will make it in a command or we can take it off, but we have to let it here because if we want to, to go to confirm our columns, so we have to see it here. But there is another way we can put another, another file here, just special for the database. So in this file we will just create the database for example. And we will create it, and we will create the tables. So we create a database and the tables as it does in the fall of our app or, or our projects, we will work with us directly. So that's ones for today. And I will show you, I will see you. So I will see you in the next video. So stay safe. Bye. 29. Insert data into the database: Hello everyone. In the last video, I have shown you how you can create a table inside the database. Now I will show you how you can put the data inside this table, which means inside the database. So the first thing that you have to know, to know that we have, I told you about this line because we are, we have already created the database. So in this line we will just connect it. Then in this slide we have created, in this slide we have created the cursor. And in this line we have created the table, but we put it, we put this line, this line in the comments because we don't want to create another table with the same name users. Now, as I told you, we want to fill this table with data. For example, this is our table. We have these lines, first NIH, a first-name, sorry, last name and age. So we will, for example, these two users and we can use, we can add another ones. So the first thing that you have to know that we will use the same function which is executes. We have just to change this keyword because this keyword is create table is special for creating a table. Now we will answer some, some data into the database. We will use it now. So same thing we call the cursor does execute. And here we would make like a string. So we will create, will rise, as I told you, insert into, insert something into that here we will write the name of the table that we have, which is users. Users. After that we will write value, values, sorry, because we want, that is some values that we want to put it inside the table or inside the database. So here we have the insert into values. We will have to open the parentheses. And inside the parentheses we will write the values that we want to put. So we will give it names here, these names. We have to put it in order to have the first name, then the last name at that age. So we will create three variables that will have the role of the first name and last name and the age in this order, we can reorder these. Okay, so here we will make the FirstName, we will give it the same name. So we have to write cannons than firstName, for example, firstName. Or we can, we can change it, we can make another naval available, but we will, we will keep it to make it more clear. So then comma, then second one is lastName. Then the third one is age colon than h. So if we put a variable or a value in this value, because this, this, this, this line. When we did that, the values of firstName and lastName and age, we would insert it into the table, which is user, which means that we will take this value and put it in the user name, the first name here. Then we'll take the last name here and put it in this column. Then the age, same thing. So what we have to do now, we have just to make the two enter the variables or the values that we want to make in the database. So we may come here. Preferably I would make, I will go to a new line to make it more clear. So to enter the data in these values, we have to open this brackets. Inside the brackets we will give the variables. For example, we have here the first, the first column that we have, which is firstName, first name, then this, this variable we take the value for example, we will give it as we had the first user, which is MCI amine and 24 years old. So we will give it here the first name. First name here, give it as strings. So I would give it like this, sorry. Then the lastName to go, the next line we have to make comma. Then we have, we go to the next line which is last name. Then we will give me columns. Then here the value is amine. Then we will make it come up to go to the next line. Then here we have H, which is the value, for example 24. And we have, this is the last line. So we want add comma here. We have to make comma if we want to go to another line, but if it is last line, we will let it just like this. So if we run our program, we see that there is no errors, which means that this data is always works, which mean that's worse if we want to enter another, another data. If we run this program another time, we will enter this user second, second time. Then if we were on it another time when we have a tree users with the same last name and first name and age, etc. Now, if we want to make to enter another user just, we have just to change this one, the FirstName, LastName, and age. Every time we change this, we will have a new user and we have new line in our table which is in the database. So we have the first one we learned the first time with the first values. We will have here, the first user than the second. If we change it here, for example, then second time we will make it here. I forget, which is Lee John. So we will make it here, Lee and John, which has 22 years old. This one. So if we are on our program now we will have this new user in new line, which is Lee job with 22 years or so. That's was for today. I have shown you how you can enter or insert data into your database. In the next video, I will show you how you can return it or take it out and print it or something with it. So thanks for watching and I'll see you in the next video. And stay safe. Bye. 30. Select data from the database: Hello everyone. In the last video, I have shown you how you can enter or how you can insert data in your database or in your table, which is user here. Now I will show you how you can bring that data and work with it or we use it in your program. So to do this, we have to use just a simple command which is always executes. So cursor dot execute. Here, we will change just this keyword which is here we have inserted because we are inserting the data into the you, the database. Now we will select it. So we will just write here, select, this is the key word. Then we tape star, which means on stuff, all what we have. So we will see next all what we have in this keyword void. I don't know, actually, I don't know what means, really what it means this one. But if we write select star than oid means does select all the rows or odd, we have, we have to say rows because we have here, this is our table. So we, we select all the rows, this row and this row extra. So select on the growth from our table which is users. So we will select all the rows from users. Now, after the, after, when we select it, we have to fetch it. To fetch this. On all what we have in the table we have then is a function called fetch. So cursor dot fetch on fetch all means that you will bring on what we have in the database. So actually if we have, if we will bring on what we have here, it will be like a matrix like this. So we have this lines and rows. So we have, we'll have a table in a table, or we can say an array or a list. Inside this list we have another arise. So we have the first one, the second one, etc. So we will have a main list, and inside this we have Users list, user one, user Joe, etc. So to do this function will bring on this. So to work with this, what we want, there is two ways. For example, if we want to print it, we have just derived, for example, print than this one. I forgot the print. So print cursor database means that we will print all what we have as data in our database or in our, in our table, which is Table users. So here I will use this. We have the first use of a second, etc. You can see that there is a lot of users with the same, The John XXIII because here we have written this and we didn't take it or we didn't really delighted. So in every time we run the program, we will create another one. So, but I didn't want to take it off because it doesn't matter. So in this, as you can see, we have always this index which is 1 and 2, etc. This index is, does he went, What does I told you about? So this is the first item, this is the second item, term, etc. So this is the first user, second user, etc. We can't say items. But in our example we can say the users, user one is extra. So now if we do this, we have, we have selected all what we have and we print it. But if I want to have, if I want to select just one user, for example, just this user or just this one. So what should I do? So the first thing that I have to do is to put all the data that you bring it in a variable. Sorry, I will call it, for example, I don't know. Users equal cursor dot fetch on. So this user know is like a matrix that has all what we have. It has all this table, all the arise on solid, all the rows from this one to the n. Now, what should we have? What should we do? As I told you, I want just, for example, just this one, just this user. So if we have an array and we want to take just the first or we have a list and you want to take just the first item of this list. We have to write, for example, if you have list table, sorry not here. If we have list called table. And this is our list. If I want to select, I want you to show, for example, 2, 3, 4, etc, five. Now if I want to select this item, I have to just realize, for example, table, table. And here we have to write 0 if so, here, table with the index 0, we take the first element item, sorry, and if I will make here Table 1, we will have the second etc. So in the database we would like it works in the same thing. If here we have users. Users is this table with all these users. So if I want to select just this user, means that users, users, sorry, here, 0, if I will put user 0 means does I want the first user on the first row? So if I want to print it, so we have just your eyes present than this one. If we print it, you will see that we have the first user, if we want the second, when I just hear one. And you can see this is the second, etc. Now if I want to select just the firstName, for example, just the FirstName. As you can see, if we have, for example, I will show you if we have, I don't know, table that have this table that has a lot of like a mysteries means that there is at least inside the list. So if we want to select, for example, the first item, we will just like we would, for example, like this. 0 tab 00 means that we will select the first item of our matrix. The same thing if we are here, we had, this is like a matrix. This is table or this is the user's 0 with the index 0. And indeed you in detail in the user's 0, we want to take the first item which is 0. The index 0 means that we have, we have to write like this, for example, for the FirstName, Take table, users 00 means the first row and first column. So if we want to print it, we have to adjust your print. Print, then users 00. So 0. If we write this, we will select this item, this item on this side, as this firstName. So here we have this FirstName if we want to select lastname. So we put here one. As you can see, this is last name if I want to select the age of, of this person. So if this user, we have this user have the first name, last name, and age. If we want to select this, age, means that row 0 and the column 2. So here we have 02, and if we run it, we will see that we have the age. If we want to select second person or second user, which is here, one, and the firstName which is 0. And you can see we have Lee and for the last name John. And for the age, we have here 22. So that's was for the, for the database. If we want two brick laying or select something, it's worse like the rise means that there is a list inside a list. So we would have just like a matrix. So that was for today and I'll see you in the next video. Stay safe. Bye. 31. Insert picture to the database: Hello everyone. Today I will show you how you can insert a picture or pictures in your database. So the first thing that we have to do is to create the database first. So we will give it, for example, we will import the library which is import SQLite, SQLite 3 as DB for example, for like database. So here we have imported the library. Now we will connect the database already created. So as you can see here, we have already a database, so I will just connect it. The, I will give it the name, the base equal db dot connect. And here we will write the name which is name. Then photo. That dB. If you don't have database, you can write just this one, for example, is we create a new one for you. So we will make commits. So database that commit then closes, database that close. Now we will write the first, the first thing that we have to do is to impulse the picture. And thus we will put it or inserted in the database. So before that, we will import the picture first and I will show you how to make the other thing. We create the cursor first, so we'll make it cursor, cursor equal. Then here we have database, database that cursor. Now here we have the cursor, we have created the cursor here. Now we can import the picture after, after that we create the critical mass. I prefer to do this. So to, to, to bring the picture we have two. Use this function which is with open, sorry, with open. Now here we will write the path or the, if we have the picture already in the same project, same folder of our projects, we will just name the type here, the name of the picture. So I will take this one for example, this is the picture. So we will give it here as a name, which is new picture. Does P&G. So this function has two variables. The first two parameters, the first parameter is the bath or the name of the picture. Then the second part, second parameter, which is if we are, in this case we want to read a picture. If we want to bring it into the program and you will convert it. So if we want to put or inserted picture to the database, we can't insert it with any type we want. We have to put this in the binary type. Certainly disagree for that. We are using this function to convert the picture. So here we would like. L be air for rights, be for binary. So it will rise this picture as a binary. So here we'll make it as this is the syntax of this function cell will rise binary as, for example, will make it the name, we give it the name Peak than equal. Here we really get the name of the picture. This variable will take the value of our picture into binary type. So here we have picture equal PQ dot. Now, if we print this picture, sorry, not this one. Print. If we print this picture, you will see this one. You will see that it is in the binary type. As you can see, it is too long. I can show all it, all of it. But you can see that this is the binary type of our picture. Now, after it as we imported, we have just to insert it to the database. Now, we will create a table in the database cursor that execute. Now, there's one. Now we will write create as always, table. Now, if we in the last video, in class video, or in the last, in the last videos talking about the database. I have shown you. I told you that if we have a table with the name, we can't put two tables in the same database with the same name, sorry. So it is the same thing here, but there is, we can solve it with another thing. So before that, because in this case, for example, to create the database, if we have already a database with this name, there is no problem because if we just connected so same thing here. We will write creates a table if, sorry, if not exists, if this table that we will create is not resist created, what if exist? We will just post, we'll just put the cursor on it and work on it. So here we have create table if not exists. Now we will write the name of the table, which is for example, we will give it the name and then B and for name and P4 photos. So this is the parentheses, and here we'll write the parameters as we have. The first parameter is the name with the tape type text. Then the second parameter is the photo with the type blog. This type is for the binary pictures. If we don't have a picture in the binary type, we can't use this one and we can't put it in the, in the database. So in this one we have created the table. You will see that there is no errors. Now to insert, to see that we have really created this table. That is this one database. We should want this one database browser. We will see here file, then we'll open it. We see where is it, Where is it? The teaching, this one. What is this one named photo? And you will see that we have this table. In this table, this is the database. This is the same what NB does we have created. This is the column of images and photos. So as you can see, we have created the table inside this database and we have two columns. The first is for the name and the second one is for the picture. Now, what we have to do is just to ensure this picture in the table as we did with the text and integrals. It is the same thing here. Nothing will change. So we will make cursor dot execute the same function. And here we will write in serve, not insert, insert, then into the name of the table which is n, then p for photo. Then values inserts in the table, into the table and be the values, which is this one. We'll put it here. We have the first, the first value, which is the name. So I will put it like this name. Then the second one is photo. As I told you, we can change these names. It is not necessary to make it in the same, same name. All of this can change this, but in this case I want to make it in the same thing, Okay? Now we have this one and this one we have, and after that we have just to push the data in the database. So we have comma here as we did before. Now we will open the brackets with this one. Now once we have the first thing is the name. So name, then column here we will have, we will make a name for example, I will give it like this. Then come after this, we will pause the picture, which is photo equal. The pictures that we have is this one. So we write it, just take one, just like this, sorry. Here we have the picture. So we have plotted the name and the picture. If we run the program, you will see that there is no errors. And we will go to, okay, here we have this one. As you can see where I, where I can see it. This one, picture and tags. This one. As you can see, we can't see a picture because it is in the binary, as you can see. We can't see it here. But you can't see the picture because independently, but you can see here, you can see the tile, the size of the picture, which is, well, this is too long to read it. So if we want to see if this picture is the same of this one, we will just see the size of the picture that we have here. And you will see that it is the same thing of this one. And name as you can see here, the name that we have put an output, sorry, here we have the name amine and same thing here. So that was for today, how to insert a picture in your database. As you can see, it is easy to do it. In the next video, show you how we can select or how we can return the picture from the database. So that was for today and I see you again. Stay safe. Bye. 32. Select picture form database: Hello everyone. In the last video, I have shown you how you can convert a picture to the binary type, then put it in the database. Now I will show you how you can take it from the database and converts it to JPEG or PNG or whatever you want, then you can save it in your desktop, etc. So now, what do we do? We'll use the function execute as always, execute. Now we will make Select, then select, then we will select everything for everything, which means that all what we have on all the table and all the rows that we have, which is OID, as I told you before, everything from the table, which is an underscore name page, named photo, sorry. So after that we have selected all what we have in our database. Now we will fetch it in a picture, in a variable we'll call it. For example, I don't know, items may cure so that fetch. Now this variable item, now have everything we have into the database. We see it here once we have this photo, okay? Now this is our table. We have this. We have the name, which is the text. Then we have this one. I want to see it like this. Here we have the name which is text. We have the picture. We can't see it here as binary. As you can see, this is the binary of our picture. Or we have here the name, which is a text. This one we have in the database, we have disable these rows, this row 1, 2, 3, etc. So now if we will do here, for example, item, items 0, items that we are talking about, this line, I mean this picture. And if we will put here one, we'll talk about this additional etc. So if we want this picture, for example, so we will take the first line and the first column. So we will have item 0 than, sorry, the first line and second column because the first column is for the name and second card of all the picture. So we have the first, the first row which is 0, then the first, second column, which is one. So this one will have the role of the picture that we have. If we will put this in a variable, we will put it, for example, we give it the name big picture or photo. I prefer photo. I will give it the name photo Ikhwan. This variable now has the picture that we had before, but in the binary type. Now we want to convert it. We will do the same thing that we had that we did before, like this one. We will make just one change. So we'll push it with open, sorry, open. And here we have the first parameter before. When we converted. First time. Here we will put the name or the path of the picture. Now we will write here at the pot or the name if we put just the name. So we save the picture in the same folder of our projects. But if we want to put it in a path that we want, we will put here the path plus the name of the picture. So in this case I want to put it in the same folder. So I will give it the name, for example, I mean, then we will make the type that we want. So we have, for example, can make as PNG JPEG ECO give exit route. So I will take it for example, P&G. Now here, the second parameter before we had here RB, which is read and binary. Now we want to rise to the picture. So we want to convert it from the the binary to the BP and GIF photo. So we make here w for write than B by an array. Now here we have as and the name I will give it, for example, peak. It doesn't matter if this one. So here we have pig. Now. Now we will have to save the picture in a variable. So I will give it, for example, knew, I just knew, I would just make new big churn. So this variable in your picture, resize the load on our picture. Now we will give it here the name, the big. Thus we have here, this one, this item. So we have a pig that right before that we had big dots read because we want, we want it to read the picture. Now we want to write it from the binary to the GP PNG in this case. So what we have here in the parameters functionalized, we have to put in the parameters the picture that we want to write, which is photo. So we will write it here. So we have here, right, the picture photo and put it in new picture. So this new picture which has the photo, which is a PNG. So if we run the program, you will see that the picture will be saved here. As you can see if we open it, this one, the picture, this is our picture, the first picture which was a picture. Then we convert it to binary. Now from the binary type we had return it to PNG. Now if we want to put it in another type, for example, GPG, we can do just like this GPG. Now if we run another time, USE that we have the picture in the same picture but in the type GPG. So that was for today. And I hope that you understand it. And I'll see you in the next video. And stay safe. Bye. 33. Application that convert images from JPG into PNG: Hello everyone. At the end of this course, I want to read an application with you. So we will put all what we learned in our course and we will build an application together. So I will show you how it will look this application, it will look something like this. So with an application, first thing we'll do is to explain to you what kind of application we will breed. So as you can see here in the title, we have image conversion. So we will, with an application that will convert pictures. So if we have a picture in PNG type and we want to convert it to a JPEG, or we have a picture, we GPG type AD, we want to convert it to PNG type. This obligation will help us to do this. So I will explain to you how it works. So for example, we have here, this is a framed as an empty frame. Then we have these three buttons. The first button, we can reverse the picture from the PNG to the GPD. And this button will convert picture from the GPG to the PNG. And this button will clear. What if we have a picture here is we can clear it. And here, if we have something like this, this Watson will create it. So here we have, we have to enter the name of the file that we want to save it. So if we don't, if we forget, for example, to tape, to type the name of our file, of our new picture or our converted picture. Once we, we do, for example, if I click here, we see this window which will ask which pixel with which picture I want to convert. So if you can, if you see I have selected just the PNG pictures because if we want to convert from the PNG, So JEPD, we have to select just the PNG pictures. And the same thing here. If we want to convert from the GPJ to the PNG, we have to select just the GPG pictures. So if I will start, if I will, I will not rise to the name of the file that we want, that we want to be saved. I will just click here. I will select this picture as you can see. Here. We, there is no picture. The first thing that is now picture we couldn't upload it. And the second thing, we couldn't convert it or save it because we didn't enter the name. As you can see, he entered the name of your file, please. So if we will type the name, for example, I will give it name, last name. I would give you just the name of James name PNG, for example. If we want to take a picture from the GPG and converts it to a PNG, we will give it the name, for example, name B and G. Now we will upload the picture. As you can see, these pictures are all PNG types. We can't take the dB and G2 to convert it to GBG. So we will take GPG and convert it to the PNG. So I will take this one, for example. As you can see it upload the picture here and it is converted and saved it as you can see your picture as is. So save it successfully. Now if we go to our, to our directly on our project folder, we will find the new picture. The same thing if I will clear it, for example here, the same thing if I go to, if I want to convert the PNG picture. So I will write here, for example, name. So JEPD because it will be a PNG and we will convert it to the GBG. So here we have the GPG. So I will take here, that is, all these pictures are in the PNG pictures. So I would take, for example, this one. Now, as you can see, this is the picture that this picture is on PNG and it will be saved as this name, name GBG and with the type DPG. And it will write here, your picture is saved successfully. So we will work on this project together and will with this application step-by-step. And that was for the explanation. In the next video, we'll start boiling it. So see you there. Bye. 34. Creating the skeleton of our application: Hello everyone. Now we'll start building our app. So in this video, I will show you how we can create the skeleton of the app, which means that we're creating the buttons, labels, and the frame. So as you can see, this is a picture of our app. So we create these buttons, the entry, this label, and this frame. So the first thing that we have to do is to create the window. So we will import the tick interlibrary loan from Tkinter. Import everything. Now we will create the roots, roots equal dk. Now we're put it in the main loop two, don't forget, it may look like this. Now we will do some changes of the app, will change the geometry, the color, the title, etc. So we'll start by the tighter. We have this one. As you can see, image conversion like this. Now we will make, the icon, will give the icon here. I can. Now we have logo dot o. We have done this before, so I am doing this too fast. Now we will make the geometry so that geometry, I will put it, say 500, 650. So we have like this one, like this. We will see how it looks for the moment. Now this is the window. Now we will change the color circle routes that configure. Here we have BG equals I. Choose the color which one B, one B, 21. I think that this is the color, this one, as you can see, this is the scholar, this background, this background color is this one. So this is the app. The app. Now we will start making stuff on it. We will create the labor of the frame, which is this one. After that will create all these buttons and angry and this label. So to create a frame, I will make a comment here. For example, create a frame like this. Now we will call it frame, frame function. We will put it in the roads like this. Now. We will, we will choose the width and the height of this flame. So for the, for the width will take it just like the width of our app. I will make it a little bit smaller. So we will make it like this with a call. I will make it for a 150 than the high. I will make it 500. Then we will packets in the, in this, like this frame that pack like this. Most pack I will make a great cause we need to grade all the other stuff. So I will make a grade here. I will put it into row 0. Then the column 0. And I will make a column span for three nodes like this, column span equals 3, I will divide the AP injury site three columns because we need the first column for this button. For example, the second column for this button, and third for this wasn't. Okay. Now we will see how it looks. We stop it and here we have our, our frame in the cell. We will make some padding on it. The first thing that we have to do is to make padding on x, which is in this function here. So we make, but x equal 25. We'll see if it is great. I will add a little bit, make it 24, 7. Like this. It is in the middle. This is great. Now we will make the, I will make some padding onto the Why. Not yet I will put this after because I don't want it. I would make somebody on the wired for the moment. But why? For for the function of the padding, that is something that I didn't told you about. We can write, for example 20. So if we write 20, we will have 20 padding in the top and 20 in the button. But if you want to make just bottom, sorry. But if we want to make padding just in the top, for example, we can use this function, but we'll add this parenthesis. So we have here two parameters. The first parameter is how many buddy we want to make in the top. And here we will have many padding we want to make in the bottom button. Sorry. So for this case, I will make For, I will make two in the top, and here I am exhort 0. After that, I will see if it will change it or not. Now, here we have two. Great. Now we're creating the buttons. So we have, as you can see here, we have three buttons. The first button is for the PNG conversion from the PNG to GPG. The second button is clear, and third is from the GBG to the PNG. So we created here, I will make it like this. Creates the buttons like this. Now, the first button that we have is to convert from the PNG to GPG. So we'll give it the name PNG to GBG, which is the name of our button. No. Now here we have button and we'll put this in the roots. Root. Now we give it the text. If we give it the name, which is PNG, JPEG, like this. Now after that, we will change the way we give, change the font and we will make some padding on the x and the y to, to, to control the size of our button. So here we will make the size of, we make the padding on the eggs equal 20. Now the padding on the y equal, I will put it seven. Now for the, for the color and the font. I will give it here, man. But I will change the size of the phosphoryl, put it 20 and bold. Like this. Now, I will packets before that. I own part is after the frame, as you can see. So here we have PNG to GPG equals F1, sorry, GPG does great. But PNG or JPEG dot, it is not working. This S1, sorry, that's great. Like this. Now we will put it in the low one because we have the frame in the low 0 and we want the button will be after the frame, so we will put it in the low one. Let me make some space here. So here we have the row equal one, then we have the column, we put it in the column 0 because it is the first item. So here we have column equal 0. Then we will do some padding. We'll do it after photon, which will let it just like this. So we have in-frame in row one and column 0. We'll see how it looks. This is our button. So I will make some padding in the y for our frame to put this down. So we have, where is it, this one? So we have 0. I will put it, for example, five, and we will see how it looks is great like this. So now what will we do? We have, we have created this button. Now we'll create the second and the third. So second is for two clear. I will put it just like here. Clear, Clear button. Now we will put it in the root. Then we have text equals clear. Same thing. Now, I will take just like this one and this one and this one Control C, Control V. To make it just like the first one, I have to park it to grade it. So we have here clear that, great. Then it is in the same row, but it is the second column. So we have, we have to put it just like this. Rho equal 1. Then column equals one is because it is the second button. Now we will see how it looks. So you can see that there is the first button and the second button. Don't worry about it because as you can see here, we have this button in the middle, but it will be in the middle when we will create the stirred button, okay. So here we have to create the third button, which is from the GPG, DPG to PNG, equal bottom most button. No, now it puts it in the roots than the text equals. Here we have GPG to PNG to be like this, and we'll just copied, we have already copied it. So if you just use it, I will stop this. Now we have two packet. So we have here GPG to PNG dot grade. Then we will just make it in the same row, which is row 1, then the column it is in the third column, which is column 2, like this. So we will see how it looks. Here. As you can see, it is just like the same here. We have this one. This is the first, this is the second, third. Now we have created the buttons. We have just to create this label and this entry. So just too easy for us for the moment. We have the labels. So you're created here. Make it common. For example, crea, create label for the filename like this. Now, I will make space like this. Now. Now we were created. I will give it, for example, the name of file, filename, label. Now we will create it like this label. We will put it in the root. Then we have the text. As you can see here, the text is filename. So we will let it just like this. We have here filename. Now, we will change the font and we will change the size of the text. So we will give the color because if we let it like this, we will have the background of our, our label, Blub white, but we want it is the same thing of this color as the background. So we'll just copy this from here. Control C, control V. Now we'll change the font. The font I will make it equals propaganda. We have used this before. Profile gun, like this, proper Janda, like this then the size 12 and we'll put his want. Now, we will package here. We have it in the second, the third row, which is row 2. So we have here file name that label, that grade. It is in the low equal to than the column. I will put it in the column 0. Now, this is our, this is the remnant column 0. We will see how it looks for the moment. This is our label. We will push it down a little bit. So we'll use the padding in the y. Now, we will do some padding just in the tub. We will use this function, this parentheses in the tub will do, for example 10. But in the button will make that 0. We don't all some padding on the bottom like this, or you put it more down the 20. And we will see, okay, It is great. Here. It is just like this one. Now we have to create the entry. So here we have make a comment, create and 34, the filename like this. Now we're created, for example, like this box or I don't know, Polish, just like this filename without labeled. So here we have an entry and we will put it in the routes like this. And to make the size of this entry as, as much size of our labor. So for this, we have to change the font size of our font size for this one. So we'll just make it like this formed. Which one? I will say just this one or this one. Great control C. Then what is it? This one, Control V. Now we will see a full lecture packets like it just here. We have fine name, not the label that grade, that grade. And he will put it in the same row of labels arrow equal to, then the column equal one, because we want it in the next several. You see how it looks. Here we have this one, we'll put it down. We take this same thing here, but think of Y and we will participate. Now as you can see, this is the, this is what's what we see here in the picture as you can see here. And this is our AP. We have changed the name and I can add, we have created these three buttons and we have this labeled like this one, and we have the entry. Now we will stop here. And in the next video we'll start making the functions for each button of this and we'll create and finish our app. So I see you the Stay safe, Bye. 35. Opening the picture and puting it in the app: Hi again. Now we start creating the functions for each button we have here. So the first function that will create is the function for this button which will convert from the PNG to GBG type. So here we have two different our program which we, which we, which is this one for the layer window. Now it is an empty window, it do nothing for the moment. Now starts creating the functions for foraging. So here the first thing that we have to do is to import libraries for. So here we have from Tkinter import the file dialogue because we have to create the window does we'd ask us what the images for the images we want to create to convert story. Then we have to create two where we will work with the datacenter images. So we have to import from PIL, import image TK, RTK, image TK like this, then the images, image like this as imagery. Now, after we have imported this functions, we will start creating. We have created story, we have imported these liabilities, start creating the function. So the first function, as I told you about this button, which is B and G to G PG. So we'll put it here as the command. So we have sorry, command. What I am doing, command equal, I will call it, for example, P&G to G, PG, GPG. Now this is our function. I will put this in uppercase, like this. Copy control C. Then we put it here. We have here create the function that will convert from PNG to GPG like this. So here we have the and this one the name of the function. Now. Now what we have here, the first thing that you have to is to create a file dialogue that will ask us to choose the picture that we want to convert. So as we did before, we write it just like this. Here we have roots and that filename like this. Here we have File dialog that ask open. Now he had the first, the first thing that we have to do is the title of the window. Title equals I will like this. I will choose a picture. You can put it anything you want. Now the second thing is the file type. File types. I forgot the file types. Here we have equal. Now we will start. We have. Parentheses here than there is another parentheses to select. We will select the PNGs and the second parameter is we will take the all types. If we want to see all your pictures, we will take it here. So the first thing here we have PNG file. Then here. And here we have everything that PNG, because we did this before. The star means everything, which means every name we have, just that PNG. Now, this is the first, the first time than we have here to put the second, which is I would put it all types. Then what we'll have a comma, then we have everything that, everything that ability. Now we have created this one. We'll see if it works. Just like this. Click this button. As you can see, this is our window. Here we have the title, choose a picture, and here we have PNG files and have here all types. Ok? Now, after creating this, we have to, if I want that, if I choose a picture, I will put it in this frame, which is this one. I want to pick to put the picture Susan in this frame. So to do this, before that we do this. We have to See if if the path that we choose if the user selected the picture. Because if we don't select the picture, we don't have a path of any picture, so we can't use it to open the picture and put it in the frame. So the first thing that you have to do is to make a condition. So if this part is different to an empty string, so if roots but filename doesn't equal an empty string, in this case, we will put it in the frame as we don't put anything to don't have an errors after. So if it is different to a fire an empty string, in this case, the user have chosen a picture, so now we will put it in the frame. So I call it, for example, I may make it PNG picture equals. We have here image that open. Now inside this function, open, we have to provide the path of the picture does we want to open. And as you can see, we have here that filename is the part of the fun of the picture that we have chosen after, after creating the window, etc. So we have just to put this one copy, then we will put it here. So if we were to put this part here, this function open, which is in the image objects, will open the picture for us. Now, after that, we will open it. The first thing that we have to do is we have to resize it before because if we have ten, hundreds of pictures, we don't have we don't know if all the pictures has the same size. So to make it very clear and very clean work, we have to resize it in the same site. Any picture we have chosen, we have to resize it in the same size. So here we will change it as we will use the functional resize, which is included in the image object. So we'll make it, for example, air, which is recycled PNG picture. Png picture that resize, resize, and he will put the parameters, the first parameters. The first parameter is the width and height, will put it as the same thing of the frame that we have here, that the fame. And here you can see the frame has the width of 450 and height of 500. So it puts it in the same thing here we have 450 by 500. And the second parameter that we have is the image that and the audience, as I told you to delete all anions that we have. We have. Now. After that we have resize it. Now we will use the function which is included in the object image dk. After that, we will put it in the frame. Now. We call it, for example, picture equals. Here we have, what is it? Tk image. Tk image, this one. But photo image. Now here we will put the picture that we have, resize it. So PNG picture. Now, if you want to put the picture in the frame, we have first to put it in a label. After that, we will put a label in frame. So here we will create a label, which is I will call it labor equal. Here we have the function like this, not lambda label. And he will put it in the notes in the roots, in the frame, sorry, in the frame because we want that the picture will take the place of the frame. So here we have frame then the what will I do? I think that this is all we don't, sorry. We have to make the image. And here we have picture. Okay? Now we have just two. Park this label, so label that back. As you can see. You will see that we can't see the picture for the moment because we have opened and something. I have this. You got it. You can see that there is no picture here. Why? Because I told you that if we have a picture in the function, but we want to put it in the main route. We have to put this picture as a global variable. So we have here just to write global picture. Now it will work as we did before. We have here to select it. Here we have our picture. So if we rina, if we stop it and run it, you can see that if we press here, it will open this window for us. We have here PNG. So if I click this one, it will open for us. So here in this video we have done this little line, this sunlight's to open the picture and resize it and convert it to make it ready for the frame. Not suffering for the, for the tickets are up. So this line we have created labeled as we have noted, the image in this label, then we have book labeled. In the next video, we'll start converting the picture and save it. 36. Function that convert from the png to jpg: Now we have to start the conversion. But before that we started the conversion. I want to give you a remark. So for example, if we have here this UP, which is this one. If I replace this one, I would choose this function, this picture, sorry, we will have this, but if I would want to choose another picture, if we click this one and you choose it, you will see that we have a problem. So to fix this problem, we have to destroy the first picture which was here. After That's reports, that new picture. So to do this, we have to, there is a function for the frames. We will use it here. Like this. The function is, we have, for example, we have items in the frame, so we have to destroy all the items that we have in this project. We have just a picture that will be inflamed, but we have to make a loop that will destroy everything we have. So we have fall, we will actually just like these four items, for example, in, in. Then here we will find items in frame, that frame, we have the frame in that info. Info, where is its info? Window? Sorry, windows info that bush children when in full. Children. So children means that all the items that we have in the flame, so every item we have in the frame, which is every children we have in the frame. We will destroy it. So we will make like this. So item will make it US items, items, every item in the frame. So item.name destroy. We will destroy it from its cell. When we press the button, it will destroy the picture that we have. If we have in the frame, after that, we will put the new one. So we will see if it work here. If we click it, we will choose, we have this picture. Now if I want to choose another one, if I right-click, you will see that there is no picture for the moment. Now, if I will click and choose another one, it will be great. There is no problem for this one. Now we will start the conversion to it. To make the conversion idea is, I told you about the conversion from the PNG or JPEG. So the binary, we use this, well, we want when we were using the desert basis. So wherever we want, when we want to put the pictures to our database, we have to convert it to the binary. After that, we have to put it in the database. So we use this idea and put it in the app. So the first thing that we have to do, for example, if we have BIG picture, will convert it to the binary. After that, we will convert this from the binary to GPG in this case. So to do that, the first thing that we have to do, as I told you, we have here this up. The new the new file or the new picture will be with the name that we will put here. So in case we don't have, we don't put a name here, we will have an error. So we have to verify this from the beginning. So if this, this entry or the name of the picture doesn't equal an empty string. In this case, you start the condition, but if there is no no-name here, we won't. Any, any conversion, and it will be right for us here, a message that say, please enter the name, etc. So to do this, we have just to see if this is, if this file name, which is define a much which is here, not finite, we have here filename. So if we put finite, that gets, we will get the texts that we have in the entry. So if this filename that gets doesn't equal the file, the string, empty string. In this case, we will start the conversion as we will do nothing. So here we have, this is the function. Now we will make this condition. If filename that get like this doesn't equal the start. If it is equal, we start by doing the air. After that, we will do the else. So if the filename that the filename that gets the equal the, the, the empty string. In this case, we will make the error message. So we will put it in, we put in a label. So we will make it like this error. We will call this error equals labeled. Here. We'll put it in the root. Then we will put the message which is text. Text equal. Here we have enter your file name, please. Okay. Now, if we have the, if we have an objective, if we forget to put the name of our file, in this case, it will ask us to enter the name in uppercase. Then we will packets that get much get great. And here we have we put in the rotary because we are in the lottery. So we are individually. I will see rho 12, so low equal tree. Then we will put it in the column 0 because the first column, like this, I will make sure it's just, I will make a span. For example, column span. I will put it into columns in the 2 first columns. So we'll try it here. For example, if I want to write anything, you can see here, this is the text. I will change the color, I will make it read as you know, for don't forget it. So here we have BG for the foreground, I will put it red. And for the background, I apologize in the same color of the AP, which is this one. Copy. And we have here this color. So we will see it how it looks. We have this one. So this is the message until your filename please. So here I will put somebody on x because we will need is after, but x equals 4040. We can't see it for the moment was needed after this, I will tell you where. So here nothing's changed. So here after that we have, we know if this, if we forget to type the name of the new file, here we ask, he will ask us, but in this case, we want that He will destroy the label because if I didn't enter the name of the file in this case, I don't want it to open the file and I don't want it to convert it and save it. So we would here we will label which is the picture label that destroy. So we see it here. If I will choose this one, USE that there is no picture because he didn't upload it. We see that it is uploaded, but he is uploaded that he destroyed. It destroyed because we didn't make the name here. So we will make, we don't want, we don't have any conversion and we can't save it. So here we have if and we will make it as for the moment. And in this case here we will make our conversion. So as I told you, the first thing that we have to do it is to put it in the binary. After that, we will put it from the battery to the JPEG. Now we have the file is in the, in the, sorry B and G. So we will make the function open, which is this one open, that, not that open here we will make the the, the parameters that we have. The first parameter is the file name, which is this one or this one. If I name that gets not the solid headed. Here, we have to put the name of the order, have to put the path of the picture that we want to convert. Here. As we know, we have this name which is root that file. This is the path that we have chosen after, after clicking on the picture of, after choosing the picture that we want. So we'll put this here. As you can see, we have four in the first condition that we have here. If this, if, if, if here we have this one, we want to put all this inside. If we have, if the roost dot filename doesn't equal to the empty. Yes, we have two here. If this the root, if the root, that filename, which is the path, if it is different too, the empty string. In this case we will do the conversion else. We don't have to do the condition because there is no path. So I forgot to push it down. Now, like this, if that frame doesn't equal to the empty string, here, we will do the conversion. So we have here to open it. Now here the second parameter which is read binary because we have to read, the first thing that we have to do is to read the picture and put it in the binary. And you make as big, for example, it doesn't matter. So here we have the new picture which is in binary. So binary PQ equals to. Big dor dot. Read this one. Now, this variable which is binary peak, has the value of the picture in the binary type. Now, after that, we have converted in the binary dour will really make it in another time in a picture, but with the PNA. So here the PNG type will make it a PNG type, but the name, we choose the name which is written here. So the name that which is written here is name file data gets. So here we will make with open dissenting that we have to do. Here, we will make the name here, the first thing here like this, which is fine name that gets plus what we have plus the PNG, That's the GPG, sorry, DPG, because we want the, we want the extension of the disc, this picture PNG. So we will have here the name that we have written in this entry that PNG. So we will put this all in a string and put it as a parameter as the first parameter of this function. Now here we have the second parameter which is writes binary. From the binary, we would write it and pause it and make it as a picture. Here we have same thing as big. I will make it just pick. I think that it doesn't work. I will make it just just a peak. And here we have this one. Here, what we have new, I will put this new peak two doesn't have a problem to not have a problem with the first one. So we have either new peak hand here, we will make this the new pick, which, which will be a JPG picture, equals to new peak. But right. And here we will make the name of the picture that we have in the binary, which is this one, Control C and make it like this. So in this case we will take the picture from the binary type and put it in. We'll take the picture from this file and we will convert it to the binary. After that, we will reconvert it and put it in the PNG JPEG, sorry. So here it was in the PNG and here in binary, and at the end here in the JPEG. After that, we will make a message. For example, your picture is saved. So we will make a label called Save. Here we have labeled when possessed in the roots. Then we have the same thing here. I will just copy this one. See like this controversy that not look like just this one. Yes, this one Control C. And we'll delete this and here we will write the damage. For example, your picture is saved. Six is fully. Now. We will change the color because we don't want it like this. So I will put it, for example, I don't know why this and this, the background and the background. I will let it just like this. So we'll see if it work here. We will have, we will make this name, for example, name or new name, not new name. And we will choose the picture. So we have this picture, for example, we have open it here. And there is no message saying because I didn't bucket, sorry, I will packet if the picture here we have this one. So save that. Great. I always forget to packet. I don't know why. I will just take it from here. This one and C and control V. Now, we'll see if it works. Here we have to type the name as I told you, for instance, variable, name, name, big, not like, just like this. We'll choose this function, this picture, sorry. So as you can see here, your picture is saved successfully. We will see if it work. If we have named picture, we see we have name peak here in GPG. This is the picture that we have converted. As you can see it work for the JPEG. Now we will stop here converting the picture from the PNG or JPEG. And the next time we will do is from the GPG to the PNG. 37. Function that convert form the jpg to png: Hi again. Now what will we do with the function that will convert from the GPD to the P&G. Actually just same thing because it will do the same thing. It will convert it to the binary Dan from the binary, which will convert it to a PNG here. So we'll just copy this function and passed it. After that, you will change just some words to make it unique for GPG. So here we'll make the command here for GPG, here for the PNG. Now, here we have command equals DPG to make it uppercase to PNG. Now, we'll define it. Here. We will just copy this one, this function on this, take it, take it, take it. Just like this. I will just this one too. I am lazy man, because I like copy-paste. So here we'll make it GBD DPG to the P&G, P&G picture. Now here we'll change the name. We have DPG to BMG. Now this is the function does we have written here? It is. Same thing. Now when we start changing things, the first thing that we had to change is the name of the picture because we have here global picture. So we have to change it to not have problems with the other function. So it will possess, for example, picture one. Why not? Here we have picture wherever is it, where is it refined? Whereas picture here will be one. Then here one. Now we have no problem with the name picture, okay. Since the workforce for the lazy river had just changed this one picture. Picture that is no pictures? No. Okay. Now the second thing that we have to do, this is the same thing we haven't. We don't have to change it. Here. We will make the file chain GPG files, and here put a dot GPG disease. The first thing that we have to change. Now here we have GPG picture. So we'll put it like this, DPG. Now, the same thing here, DPG. And here I represent the pH DPG 2. Now here we have resizing GPG picture. Now, which is great here. Now what we see in this part, knots, this one and this one is it's setting. Here. We have to change the picture. We just change the name. Here we have that PNG because we will converge from the GPG to the PNG picture. Here I will make it David, the name PNG. Now, where is it? Png picture. Okay, PNG picture equal this one. Now, what will we do? We have just to change it. Here. We have created the picture, but we didn't say this one. Okay, Now we have changed, we have converted and we have saved it as we did before. Now we see if it work. Here we have the GPG button. If we click a button without giving a name, we will see here enter the filename. Then if we give it a name, for example, gee, I don't know. Green eyed flowers is named this area parties green. Here we have, as you can see, GPG files, as you can see GBG. Now, all the picture here, JPEGs or if I will take this, this one, it will be converted. Your picture is saved successfully. So it was this for the PNG or JPEG. Now I will make just this too easy to make this one. If I want that, if I would press this button, it will clear this one. And the anterior cerebral make a function here. For this button which is clear. This one, this is a great, What is it clear this one I will make command, command equal. I want clear. Clear on iOS, call it clear on for the moment. Now. We will put it here. So we have def, clear, not clear, It is clear, clear. Or now this one here, what we will do, we will clear the frame, so we'll just use this function that will clear, clear all the children's, that's food frame has kit are hydrogens. Now we will make the will clear the entry. So we will just make, which is the anterior which is fine name than that, deletes from 0 to the end, from 0 to the end. So we're clear everything. We'll try it for example, here we have this picture. Now. We did, I'm sorry, we didn't write the name. I'll put just this one. I would take this picture. If I press clear, you see that there is no no-name and now picture. So that was the application that I told you about we have created, as you can see, this is the first one and that's what we do together. I am proud of you and I think that this is the end of this course, and I hope that you understand a lot of things with me. You have questions and you have anything you can let us know in the comments, or you can send me an email for this. And I will be always, they always here for you. So I see you in the next course and stay safe. Bye. 38. How to deploy a deep learning model in an application: Hello guys. And the section I will show you how you can create or how you can deploy your deep learning model on a tick into application. So maybe if you are creating a deep learning model for classification or for detection or something like that. And you want to share it with your boss or with your friends, etc. So I think that it is little bit ugly if you will share it informative on a program with the model on a file, et cetera. So your friends or your boss need, need always to run the program and to install the dependencies like the TensorFlow, et cetera, dependency to the library that you are using and all this stuff. It may take some time. So in this case, I think that is little bit grades if you will share your model or your example of deep learning as formed as a Tkinter application or you can share it as a website or so. There is a lot of times how, a lot of types of how we can deploy your deep learning model. In this case, we will talk about how we can deploy it on a Tkinter application. We will not talk about the training parts for the deep-learning because this is not our subjects. But although if you are interested, I will leave the link of the program for the training for the testing sutra in description. So in this case you can, you can take the Ukrainian go to the model and you can see if, maybe if you are interested by this example so you can train and etc. But in our, in our section, for this section we will talk only about how we can create this one and where we can put the model. Because if you will not put the all, we will not put the line for loading the model in the right place. It will cause a problem, not a problem, but your application will be very, very slow. So if for example, you will put the, the model or the line that will load the model in this button, for example, in ordered on this button means that in each click on this button you will reload the model. So in this case, we now all, we already know that the, when you will load the model, it will take few seconds, may be used. Sometimes it's 30 seconds, etc. So imagine with me on edge click you will, you will wait for 30 seconds. Knots be of great work. So if you will, the mother in place when you eat will be load only one time means that if we will open, because here if I will open this application, the model will be load only one time, then I don't need to load this another sign because it is already loaded. So in this case, you will wait a few seconds at the beginning after class, you will use it without any problem. Then at the end of this section, I will show you how you can create this one because this application is, I didn't run it from this program because this program or this application. But here I didn't run, it's because here I am, I created an executable file, which means an application thus can be shared with your friends, with your boss, with anyone. And they don't need to install any libraries, tensorflow nor below for the images, etc. They will not, they won't need anything. They will need only this file, which is this application. So after clicking on its own, after running it, they will wait for a few seconds to load the mother. After that, they can use it with no problem like this. For example, here, if I right-click, I can choose any type of birds as I, as I told you. Because in this example my model is for image classification, which means for birds, I have 255 types of birds. So I will choose, for example, this one, and you click here on predict and it will give you, I think that we see you. I think that there is a problem with this one, which was another one here. Yes. Sometimes because I think that the model is not as robust, but this is not our, our project. But here, as you can see here, it will give us the name of the bird with the probability. But here if I will choose, for example, another one, like this one maybe. And the same thing, it will give us the name of the bird with probability. And seeing these problems, you will see if this bird is exactly the same or not. For example, if you give us a small probability means that the model is not surely, etc. All of this stuff are for the deep learning. Our project is how we can create this application and how can we deploy the model for this application? So we'll do this project in several videos because it will take time if we were to use all the stuff in one video. So we'll divide them on some videos. How we can create this one at how we can put the modern, or how we can deploy the model, etcetera. So I see you in the next video. Bye-bye. 39. Application that classify 225 kinds of birds: Hi guys. In this video, we'll start creating our application. Here. As you can see, I have two files. This one, the main vial, which means for the application where we will put all the lies of the application, etc. And we have this file is for the benediction means that for deep-learning how, how we load the application, the model, sorry, and all, we have only these two functions will not talk about this stuff because I, as I told you, these are all deeply diction parts of anyone can do that. If you have already did your mother and you tested. So you will use only the lines for the prediction for the test part. Here. I am only here we have two paths. The first path for the model, the second one is for the images so that I can return the labels, which means the names of the birds. Okay, So here this line for loading the model I will go to, I will go back to this after. Then here I have two functions. The first function, which means which will take the path here for the images and it will return only the names of the birds. And this function predicts, which means which will take the path of the new image. Then it will do all the preparation staff, which will convert into energy into gray scaling. And it will do all this stuff, the prediction, and it will return to two resources. The first one is the predicted class, and the second one is the probability of this class. Okay, means that it will make, for example, it is an owl with 99, 99 percent, okay, so that's what only what it will return this function. I will leave all these programs in the description, so maybe we need them after. But although if you are already did your motherland, you have tested. So I think that you have this lines of code. You don't need them. Okay? All what you will need is what you will create now together. So we'll start by creating the face of the application. After that, we will do only all the stuff step-by-step. Okay? So here we have from Tkinter import everything like this. Then here we create the application server. You would have, for example, a coin TJ. Then that may look like this. Okay, So we run it. Here is our application will change the size of this application, which means the width and the height of this application. So I will put them that Yo-Yo Ma HD. Then here I will put them seven is 500 by 700, like this. So we see it here is our application. Now I want to change the background, color background. So we obtain the same thing that I showed you before. So here is the color which is I will put, I will put the color on a variable. So when we will need this on a label or something like that, will use only the name of that variable when we don't need to. Always the same code of the color. So here I would put it at the beginning. Here, have BG for background equals than this one. I don't remember 00 to nine. To my liking this. So here we have application that you're like this, and here we have the background, a background. So here we have pushed this color as a common color. So in each time we needed to read it will only need to type this BG for background. Okay, so we see it here. Here is our application. Maybe we can change the icon Weiner's. So here we have up that icon, the S1, and here I will write the name of Logo. See though, you know that if you want to put a logo on application, you have to convert this into icon like this, okay, there is a lot of online conferences that you can use to do this, okay, and for free, here is our icon. Then I will change the title here. For example, that title. Then here for example, what is your verb? You can put anything you want. This is only one. This is only the example of our projects. So here is the title. Now what we have to do, we will start creating stuff. You will put the word recall is we put the title here, then the frame. We'll put a flame here for the image, then the two buttons. So to do that, we will start by the title, severe. We have title. We'll call it title, then here we have label. Then we'll put it in the text. So for the title we can make, for example, choose your birth or in your image in the world. Then here for the font, I will put it to urgency. For example, the, this is only my choice. You can use any font you want. So I am not a good designer, but I am trying. So here we have bald. Then for the background, I will put the same here as we said before. The background represents background like this. And we see with buckets here that buck. So here is our application. I will change the color of the foreground. I will put this wide so we have foreground a coil, whites like this. So it is listed bit better. I think that this font doesn't work for the moment. Mine, I don't know. Maybe it is not installed. It it doesn't measure for the font. Okay, so I will leave it like this. Now here is labeled what we have to do. We had to create a frame or the image zone. So for this case, we create frame so that it will be very easy to recognize or to define. I ought to define an area here, especially for the image. So we need to do that here by creating a frame. Because when we said when we saw the flames, I've told you that you will need, need them for something like this, so it is time to use them. So here we have, for example, image, zone and frame, and we put it on the application. Then for the width, I want to have a 400 by 400 image so that it will be visible. But, but you can use anything you want and incentive for the height equal four hundred and four hundred and four, the background, I want to change it because here I will leave it. I will show you here if I forget to pockets again. Here we have image zoom on that. So here is the frame that we will use for our application. But I want to change the color. I don't want to put it it's almost like this one and I don't want it to be too wide, so I choose a color which mean between this one and between some white, okay, So it will be visible. The area will be visible, which means that this area for the image. So I choose the color here. Battleground equals, I don't remember it splits, I typed it here. We have 063 b tree be like this. So we see it here. So here is the zone. It's just not as visible as white, but we can see that there is a, an area here for the image. So I will do some padding here, so I will move it here from the title. So here we have y equal than here. I will put 20 by 0 like this. So here is the frame. Now once we have to do, I have to make this size not resizable. Minimise that I when I, when I want it to be fixed. So if I would put anything on it, they will not be changed. Okay, so to do that, I will use the function. Here we have image zone like this. At, when we saw the frames, we use the function called grid propagates like this one. But in this case we cannot use this, what we can use it, but it will not work. Why? Because here we are using the park. So if you are using the parks and we have to use a another function which is back propagate. So if you are using grid, so we'll use Grid propagate. Okay, so here I will use park robot gates, this one. And here the same thing. We will put the parameter 0, which means that it will not be resizable. So here is the application. There is nothing changed, but we will see that after. Now, what do we have to do is create two the other buttons, which means the button that will open and the button that will predict. So here we have the first button on cheese, for example, Open Image. Then here it is a button like this, and we put this at the application. Then for example, we have text and open. And I will change the width. I will put it 15, for example, than four for the font, I want to make it, make it a little bit bigger. So I will put this LAN than 15 bond like this, and we should park the Watson. So here we have a button that pack like this. So the board, is there any problem you think? So here is the Matson that we have here bought and we have opened. Now I want to do some padding here, so that will move it from the frame. So here we have y equal than, I will put it to 200. So here I will do some padding only from the top of the button here. So that's what we have to do with how to create another button. The same for the prediction part. So predicts, predicts, but in like this for example. So here we have Burton then pushes out the text. Print, predicts. Then here we will put the same with equal 15. And I will only copy this and paste it here. And the same thing for this other parts. I will only complete this from here. And we have the same thing, predicts what's in. That was I am do you predict button that pack like this? So here is our two buttons, this one for the opening and this one for the prediction parts. Now what we have to do, we have, we need two other stuff. The first thing is the label or that will put here or the yes label that will control the image. And the second one is a label here that will control the results, which means the name of the, of the, of the bird with the, with the percentage, which means with the probability of this word is true or large. So we'll stop this video here and we'll complete that in the next video. Bye. 40. Third part of the application: Hi guys. So in this video, we will complete our application. Now we are here with this step. We have these two buttons. We have the frame at the title. Now what we have to do, we have to create a label. Then I will post it here in this frame. So that's when we import any image or when we open an image, we will display it on this label. And same thing will create here a label which will take the text of the prediction means does the name of the bird with the probability. So here we will do is here for, for the label for the image were created under the zone. So we're going to call it, for example, brand image. Why not? Then it will be labelled as we said. So here we have labeled. Then we will put his hand in the frame, which is imaged zone like this. Then the for the, for the color will possess the same color of the background of this, of this frame so that it will not be visible. So we have a, B, G full background. I will only copy this and paste it. Now, we have brand image that's back like this, and that's it. Now we will see here there is nothing. We can't see nothing. Why? Because here label is empty. We didn't put any text or anything like that. So for us we can see nothing when using this because we will use some function config, which will help us to put any stuff like image or text on the frame. And in any place we don't have to put them here, or we don't have to create a new label or we don't have to clear a label to put something on it. No, we don't need any stuff, all of that. For example, if I want to put text on this, the same label, but after clicking on the button, for example, this one. So I will show you how we can do it. For example, here we have command. For this one. For example, we call it open, or we'll call it choose image like this, okay? And I will define the function on the here. So we have the truth image like this. Now, I want that if I right-click in the position, I will put a text on dataframe or that label, which means a frame that's labeled is on the frame. So if I were, label will be different. Okay? So here's what you need to do is only to write the name of the label, which is brand image. Then here we call the function config and this one. And now inside these parentheses, we can put any other parameters that we have here. So even when we created the label, we could have this parameter for the background, you have parameter for the foreground, we have for the phones, we have for the text, for the image, any stuff like that. So we can use all these parameters here for this function config. So reliable data, if I will click for example, I will create a text, for example, saying hello. So I will run it again. Now, you can see that there is no text or anything here. If I will click, we see this header. But if I click another assignment will not see all the stuff here because we are not creating new label but only one label, but we are updating. It means that we are changing the values of the US labor or the text of that label means that if we have a text here and I will click automatically, it will clear the Fed labeled and put the new decks, which is always Hello. Okay, So here the same thing for the other button, but this was only an example. I will put this path here because we'll come back to it after. Now we need to create the other label which is here for the results. So for that, I will click, I will put this here, for example, results zone. Why not? Then here it will be labeled. Then we will visit India than for the we don't need anything only for the background. We'll put it at the same thing so it will not be visible. Then that's it's resolved zone that spike like this year. So at the same time we can see nothing for the world because we didn't put any staff on it. If we want to test is if it is okay or not, we can choose here, for example, we call it resolved zone, that's config like this. And here I can pause it decks for example, you hello like this. So if I click here, you can see this. Hello. Quite hear. Mao was I will do, I will only take this off. I will the bus or I will leave it because I wanted to verify something. I want to change the color and the font of that, only the size or the front of this label. So I will pause here, for example, fonts equals. So I will live as none that I repeat too many for example, and bond like this, okay? And for the foreground ion to produce why it's also so your foreground. Because as you can see though, the black one is not that visible with that color of the background. So we should pause it, something like this, lighter. So it now I will run it again. If I will click here, we have this hello, something like that. So not only do some padding here, where is it's for the, for this one here, I will do some bird y equal. Then I will put, for example, 2010. I am writing q. So we have ten, then 0, like it is. Well, yeah. But I am writing here. Sorry, here we have, but like it is. Now if I click here, we can see nothing added, only a budding here of 10. So here is the title. Now what we have to do, we have only to integrate these two functions, which means only this function because this function will use this one. So only what we have to do, we'll call only this function. So we'll use this function with these two returns, the predicts class and predicted class and the probability. And we will use them for the prediction of all our, for our, our world. So what we have to do for this button, first button, this one, for this one for the opening. So in this one we'll use a file dialogue so that it will open the button, then the second button, which is this one. We will use it for the prediction part. So we'll stop this video here and we'll complete in the next video. Bye bye. 41. Foorth path of the application: Hi guys. In this video we will complete our, our application. So here I went. I will write the code for this oblique for this function. So this function will do it will use the File dialog to define a path of the image that we want to predict. Then what we have to do this after clicking on this button, it will open the image and put it here in the frame. So we'll pause it here in the flame. Then after clicking this button, you will see the name of the bird. So what we had to do in this video, we'll do this stuff, which means choosing the image or choosing the path of the image than doing the resizing stuff extra we using below that, after that, we will put it here in this application, in this range. Okay? So I will delete this stuff. Now what we have to do, we have path which is, which will be the parts, but this path variable, we need it in the other function. So it would be global, global variable. So for that, I will, I will put it here, for example, I will put global. But like this, then I will initialize this into land like this. Okay? Now here we should do the same thing here. Global buff, like this. Now we will work with this. So what do we have to do is only Jews, the file dialogue. I didn't import it here, so here we have import from, I think from file. I don't remember it exactly. It is from taking a class, from taking intercept from Tkinter import file dialogue like this. So we'll use it here. We have equal File dialog that US for finding like this. Okay, So what this function will open a window or a widget. So does we choose any image? Then this part of the image or something will be returned on this variable. We see it here. Now if I were to click in open, I will choose, for example, this image was for those we can see nothing. If we want to see it, for example, we can do this here. I can print it. So we have resolved zone does config, then we have tags. But so now if I will click, I will choose this one. For example, it will bring it like this here. So this is the part that we will need. So here is this first part. I will delete this one because we don't need it towards one in example. Now that we have to do with you, we will open the image using below with this. But after That's really resize it. And after the resizing, we'll put it in the frame. So to do that, I need to import the Pillow library. So from the import image and image TK, like this. Now here we have this part. But before doing this, what we have to do, because if you want to have a good application, so imagine with me if the bus, if I click here for example, and I don't choose any path like this. And after doing this, I will try to open an image using that non chosen path, which means it will be always none. So it will cause a problem with this. I think that we had this problem before for the application that we created to convert images from PNG to GPG, etc. So we fixed this one by only using one condition if, so, if path means that if past is true, which means if path is not equal to none. Then afterwards we'll open the image and we'll do the other stuff. So you should only always do this part. So that's your application. When the user does reduce, your application will not have a problem with this kind of stuff. Okay? So here we have if part means if past doesn't equal to none. Now, we will open the MSO here. I will create a viable image. Does I will store on it the image that we will open. So here we have image like this that open than the parts of the image dots we have chosen. Then after opening it, resize it. So if color image, but for the size like this, then the first 10 meters, as always are the new width and new heights. So I will put 400 by 400 and at the same sizes of the frame, which is what is it? Which is this one. So it will fit the frame for the whole size. Okay? Now here the second part of the solution is image that's on this earlier slide, this. Now after resizing it, we should convert it into something that will be shown in the application. So here we have imaged, then, here we have imaged TK, photo image. Then here we have to put the image like this. Now after doing this, we can put the image on the, on the label using the same function which is config. But you will see that we cannot see it for the moment. You will see here we have, I'd expect the so that you receive. And I think that's we had this problem also when we created the application for the conversion of a PNG or JPEG. So I will show you again and I hope that you will remember that we had this problem before and you will see that how we can fix it. So to do this, we have resolved zone that config. And here we have image as we had before. We use text. Now here we have image then equals two image. So this one is the function that's all the parameter of this function. And this one is the image that we will open like this. Now, I will created here, I will create and I will choose image. But you can see that we can see nothing. Why? Because we had this problem before, as I told you, if you are working with this frame is here and we are trying to put something on the frame or on the label, but in another function so that we should pause this image as a global variable so that it will be shown all it will be known in this frame. Because if we don't, we don't do that. We cannot see it here and it will not be projected. Here. What we have to do is always the same thing here I will put here, for example, global image. So this image will not be only local variable, it would be global variable. So we can put these in label, which is here in the external of the function. So now we can see it if I will choose any birth here, there is a problem. Also. We can see, I think does, sorry, sorry, sorry, sorry, sorry. Here the problem is, I chosen the wrong zone, which is here, the brand image. Sorry. So here we'll put it on this one I will try to open. So here is the image as we can see. And the same thing here, if I will take this off, we cannot see is who we see that if I choose any image, we cannot see it. So we can put it as global like this so that it will be known outside the function. So now you can see that we have, we did almost the whole world, which is opening the image, etc. Now all audience to do is to create the function for this button. And here we see that it is very easy when only called. This function predicts, which is this one. Then we'll use it to do this stuff. And we'll leave this to the last video. So I see you in next video. Bye-bye. 42. Final application: Hi guys. So we will complete our application in this video. So this video, which will be the last one for this application. So two dots I will show we were here with this application. We can open the image and something like that. Now we need to configure this predicts button. So to do that, as I told you will use, this function has a parameter, the path of the image that we want to predict. And here you can see that the path of the emulators or predict is this one always. So here, before doing that, we should import that function from this file. So here we have from predicts, parts, imports, predict like this, so that we can use is here. Now, you can also pause this function as copy this functions I put down here at the same same file, but I wanted to make them outside of our file. Okay. But if you want to put them on same file, it is always works, okay? And you should always add these libraries for TensorFlow because he will open the m or we will open the application and application, sorry, when load the model. And here I was that I needed here only for the, for the sparse, which means, which will return the names of the birds. And here for CB2 that I used this year for the data preparation. So precipitator preprocessing of that test image. Then that says here we have now by also for this part. So if you will put this on another parcel, you should put them only on this file. But if you would put all the stuff at the same file, so you have to copy this also and put them here. So we're back to our projects. So here we have deaf, but before that, we need to see what is here is the button. Now, we should create the command of that button. So for example, I will call it predicts image like this. Okay, so now we should define this function which predicts image like this. Then what we have to do, we will use this same path. So I will only copy is huge global path and paste it. Now, what I told you, we'll do the same thing. We should know that if this part is is correct or not. So if this part is Lun, which means we didn't choose any parts. So this may cause a problem. So for that, you should verify that by using an if condition as easily. So here we have if path like this, then we will enter to our work. So before doing that, we have only to call the function predicts. So before that, I will create a variable. I will call it, for example, prediction like this. So this variable prediction will have these two, these two results of redox function. Because here we said, it depends to you and your model. And how did you use this one if you want to do the same thing here. Always the program. But if you have another way, you should see what does your function returns. In my case, it returns two variables or two staff. The first one is the name of the birth, which means the class of that bird. And the second variable, or the second object. Objects will be the probability of that. That's bird. So here this prediction will have two variables, would be something lists with stuff. Okay? So we have prediction than predicts, which is the function than the part like this. Now, this function will return the two stuff on. What we have to do is to put them on the label so we can afford for the first place I will do, I will do, I will try the easiest one which is resolved here. That's config. Then text equal. So here as we said, the first one will be this variable, which is a string, which is the name of the bird. Then this one will be a double or a float. So we'll start by printing or putting on label also, always this one for the first and we see if it works or not. So we said it is the first item from the list which is predictions. And 0, which means the first item. Or if I will put one, which means the second item, which is the probability. Now I will run it. And you can see here it will take swallow. So it will take few seconds to up to open the application. Why? Because here is, when we call this, we call this function from this file. We are loading the model here. But as you can see, the model I put it in here outside the function. I could put this model in this function. But what's this, What's will cause the problem that I told you miss that, I will call this function, it will load the model, but if I will call it another time as the same, the same execution. So it will reload this again. So in each call of this function, we will reload the model a new time. So it will take, That's few seconds that we are waiting for the moment in each time you click the button. And that's we don't need that. We need only to wait only one time as we are waiting now. But after opening the application, we don't need to load the model another time. It will be loaded only one time and you can use it. I am talking about when we will open the application are the first time so we can How many, as many images we want and we'll predict them then when we will close the application. So in this case, when, when openness and other side, we should do the same thing here. We'll wait a few seconds until the model will be open. So I think it was opened. I didn't see it. So here is our model. Now what we have to do with open the image. So I will take here, as you can see, pipe it like this American papers, I don't know it, but I will open a sphere then predicts. We have always the same thing. I think that it is about the model is not. I think that there is some images that he didn't reorganize, but We can see here that it gives the name of this bird. And if I will do this one, for example, I take this one for example, I will open this image and it does, it will change the name with the correct name of this image. Now what we have to do, I will only add this probability of this is the best to you. If you need only to this name, you can leave it here. Or if you need to use that to, how do we call it? If you need to use the US to seek always also the probability. So it is also here. So what is our application? This one here. Now, here you can see that we have prediction 0, which means the name. Now, I will cost of customize a text which means which contains the name of the, of the bird with the probability. So here we have, I will cut this from here. So the test will contains this one. Then I went, I don't want to go to another line, so I will use a slash. And then here, which means the slash n to go to another line. Then here we'll put, for example, with a broad array of which means with the probability of men. We have plus, which means this one. But as I told you, the second parameter here, this one is a float, so we cannot leave it like this. We should convert it into a string using the STR function. Now here we can use and call this texts of this desk customized will have the name of the bird and space, no space in new line. Then with probability of this value. And we see it like this. We should wait always some few seconds so that the model will be loaded. See, and this is our application. Now, I will open a, for example, this one. And you can see that it will give us this probability which is float. But you can see that it is between 0 and 1, which means this one is 100. So if I want to put it four by 100, so I will multiply it by 100. So after multiplying it by 100, we will have a, a value between 0100 because the maximum probability is 100. But we'll see if it will be, for example, ninety-nine point something we don't need that. It's something we need only the anterior value. So I will push all this here. I will convert it into an anti-gay. So here I will put the stuff here. Now, I will rename it, re-run it again. The weights little bit. So the model will be loaded, as you can imagine with me, if you will, this model here, this loading model at dysfunction. So you will wait This seconds or this almost 30 seconds or something. In each time you will click at the model, or each time we'll do the prediction, which is very, it is not very professional and so you should put the mother outside the function, so it will be loaded at the opening of the application that after that you don't need it again. Okay? So here is, I will open, for example, same one that sits here for this one is 100 by 100. And if I will choose another one, for example, in this one. And the same thing, this one. So that is our application. You can see that it is very easy. We can create applications using the old stuff for Dickinson. Then all what you have to know as I repeated a lot of times, which is this one loading the model. You have to put it outside all the functions so that you can, you will not wait all the time. Okay. Then I think that that's it. Not now on what you have to do is to co-create a executable file for this application. So to do that, it is very, very easy. Also, what we have to do is install a library called by installer. So this library by installer will do the stuff for us. So I will show you how you can do it. So we can using pip install. I already have it, but I will show you so we have two points, pip install. So then the library called by installer, install like this. So you can see that I have already this, this library now to create your application, what do we have to do is to create, to put here by installer writer, put this line then the name of the file that you will want to create a application form, which means here we have this, we want to create a application for this one. So you can hear in my case, there is a big problem. Why? Because in this one I am using these functions. So if I will create a, an application for this parts without this one, so this may cause a problem. So you have a really, really good stuff if you, if you are only creating the application and that's it, you don't need executable file. I think this may this way is the better way. But if you want to create an executable file as I shown you at the first video. So you have to put all these two functions here at the same file here, if you will, click create the function for your file, for your file, which is main. Thus by you will have this additional functions at the same path, at the same file. So if we leave them like this and you will create an executable file, you cannot use this functions because they are not as this phi. So you have to think about this. I did this. So does the work will be clean. But when you want to create the executable file, you have to copy all of this stuff and put them here. Okay? So I can do is you can see that it is very easy. I will copy this one. And I will put them here. And for this line resorts needed. Because when we copy this function, this function predicts here, is, don't worry, you will not, you will not have to change anything here because we will copy the same function with the same name which is put in x. So it will be known here at the same file. So I will copy also, this will copy directly all the stuff here from this one. Here. That says now, or what we have to do is if I were to run it, I will delete this stuff here. And I run it. And it is, it does the same thing because we are always having to load the model. Then I will show you how it will work after doing this, after putting all the stuff at the same time. Now we can create the executable file for this application. So here is our application. Now, what we have to do, it works the same thing here. You can see that's only what we have to do. Only what we did is putting these two functions from this file into this file. Now, because all the files are in the same, old functions are in the same file. Now we can create a executable file with using by installer than here, which was the name of the file which is main. That's by. Now you have another parameter which is we want to create only one file for this, for this far, for this file, which means we create only one executable file for this Python file. So here we have, we should put these two dashes then here we have 15. Now if you want to add the icon here, which is this one, for example, you can add it if you don't want to add it's, it's okay, but you want to add it. You can use the same thing here, two dash then i icon than equal than here we have like a string. Then you can, you can pause the name or you can put the path of this icon. So in this case here it is at the same part of my fonder of my project. So here we have logo, that's logos, larger logo. Then as the dots like this. Now if you were run it, it recreates these folders and you have to wait for it. Especially if we are here using TensorFlow and all this stuff, it will take some time to be finished. Then after finishing this loading and it will create your phone a file. You can use it and wait for it. And I will show you how you can use it. Okay. So here is the application. It took me a lot of time because I think that was a problem with my with my because here, when I tried to do this application, before doing this video, I tried to, I created the application before, then I deleted it. So I think that does cause a problem with my, my, my program. So as I should, what I did is I created a new Python file with a new folder than ours I did is only I copy it, the copy the program and I pasted it. New File, New Python file. Then I run the same. Here. I run the same line of code here by, by installer main, which is the name of the Python file than 15, then icon here. Because I think does, if you will create it one time, maybe it will create some standards will cause a problem after. So when you create, if maybe it will not happen for you because it had never happened to me. It's the first time either. I think that this is the program. So if you would create a application, if it will not, because the API, the creation was completed and successfully extra, something like this. But when I tried to open the application, it doesn't it hasn't been opened. It I had a problem. We did it was fatal, something like this. So if you would have the same problem like this, what you should do is to copy the program and go into another directory and creates new, new folder with the new Python file. New Python file. Then you paste your, your code on its annual unless you change nothing on the code and you change nothing in the installation. Or what you have to do is create a new Python file, then run the same code like this. I will delete it. And this is the application on. You can see here, that's really why we go to the folder. You will have some additional folders. You will have this one, this one, and this file here. You don't need any Eden, neither this one or this one. All what you need to do, what you need is this folder which will contain this application, which as you can see it is our icon like this. And when you run it, it retains the same time to load the, the model as we did before. So it will have two windows the same way. There will be some terminal like this. But I don't think that's true. Cause a problem for you. Then you will have this one, which is the application. So it will work the same thing if I will click Add I predicts is really give us with the probability. So now if you want to share the application or the projects with your friends, always you have to do is sharing this one. And they don't need to install neither TensorFlow or below or any of these libraries that we use that because they will be installed with this application. As you can see here, we have the parts or the size of four hundred and four hundred megabytes, which is a huge, huge size. Because of that, the model is, because the model is, has a lot of megabytes. Then for the other stuff for like libraries, hello, So far does the size here is a little bit bigger. But if you want to do that, there is a lot of stuff to optimize your, your projects. Because here I showed you, if, only if you want to share it with your friends or something, was if you want to make this commercial or maybe you want to buy to sell your projects or something. So there is some stuff that you should do before. Maybe you should do complex your model before that. There are a lot of stuff that you can do before the wing this, but in this case I am showing you only to see how to create this application. So I hope that you enjoy it and I see you in the next projects. Buh-bye. 43. Audiobook | The tools that we need: In this video, I will show you how, what are the tools that we will need to do our project. So we go here, as you can see here in our project, we need to use Python with some libraries. Then what I want to say, maybe there is some of you that have already used Python or have heard about it or something like that. But maybe there is some of you that have never used Python or have never installed Python in his PC. So don't worry about it. I will show you all what you need to install to do this project. It is very simple project and easy to do. You will see that we will do it step-by-step and UK. And all of you can do with, even if you have never used Python. So the first thing that you have to do is to install Python. So it will go here in Python, that's the swan, python.org. So here if you will go in Python does only we'd find this page. Then you will go here into our loads and it will don't know that. But if you click here, you will download the latest version of Python. So don't worry about any version. If for example, if you have already a variant or for example, 3.8 or 3.7, don't worry about it because old version does work for this project. Okay? So here you have, but if you don't have Python cell, you need to install it. And preferably you need to install the latest version. Maybe you will need it in other projects in the future. Then after installing Python, you have, you can assign it in like any environment that you have installed before. So don't worry because it is very easy. You have to download it, install it directly. After that, you will need to a text editor. So in this project, I will use Visual Studio Code, but you can use any text editor rewards. For example, there is PyCharm Visual Code, which is this one. There is sublime types text, sorry, there is a lot of text editors that you can use and every text editor will work in this project, so don't worry about it. In my case, I am using Visual Studio bus if you wanted to is another one so you can use it. Go ahead. Then after installing these two, which is the software and the Python environment, you need some libraries to work this project. So there is, actually, there is for important libraries, but one of them is already installed with Python, which is taking this library, taking them will help us to create our application or the face of our application. So we will need it, but for the moment, we don't need to install it because it is already installed with Python, so you don't need to install it. But we will use three other libraries that are not installed with Python, so we need to install it, but it is really easy to do that. To do that, don't worry about it. I am just showing you where you will find it. For example, if you need to use it and you need more functional disease. So you will go here in this page, for example, and you will see. How can you use it? But for the US data we need in our project, I will tell you about, and I will show you how to install it. So don't worry about it. Then here, the first one which is below this library will help us just to put an image on our application or something like that. So this library will help us to create design of our application. So it is the, it hasn't, it has no idea or no relation with the PDF or the book or something like this. It will help us just to make the design of our application. Then we have this library which is by PDF. This library will help us to read the PDF and extract the text from that PDF. So which means that we will take the text which is in the PDF or in any page. For example, we select a page from the PDF and we'll extract the text from that page, then we'll put it in a string or something like that. Because if we want to read it or if we want to put this text as audio, we need to put it in a variable which has text as a string. So after taking the texts from the video on what we need to do is to take it automated audio. So this library, which is byte entity as X3, this library will help us to read texts, which means if we have a variable that has a string, so this library will help us to put this string as a audio. Now, as you can see, we have, we have to install the Python environment that I may have to install the text editor. Then after doing this, I will show you now how you can install these three libraries. So we'll go here, for example, on this rear we have Visual Studio. If you are, you are using Visual Studio Code, so we'd follow my steps. But if you are doing, you are using another text editor. So you have to follow the steps for that, for that individual. But it changes when you will create the project. Because after that, after, if you want to install any library, they are all had the same way. So here I will click here in Open Folder, I have to create a folder, for example, here I would give it a name. For example, all of you book. Then here we have to create this folder, then open it just like this. Now after opening the folder that we want to save our projects in, we have to create just a file, which is Python file. So here, before writing anything, I prefer to do this work, we have to save it. So you had to click on command, command as if you are using MAC, but if you are using Windows or Linux. So we have to click in control as. Then here we had to give it a name, for example, I will give it to you or something like this, but you need to add the extension which is Pi, which means that this file is a Python file. Okay, because if you don't put the dots by its once we recognize that this file is for Python, so you can't use it after. So you have to give it a name. Audio dots by, okay. Don't worry if for example, you forget to put that pi. So we will have to go to the folder one, you would save this file, then you have to change as the name and you put it, for example, audio and you will add that's pi, which is the extension. Okay? Now I will click in here to save it. Now what we have to do, we have just to create our, our program. But before that, I will show you just how you can create, how you can install the libraries which are below and by PDF and this one. So we'll create here, will need to open just 10 minutes. Now, what we have to do is just we have to execute here this program. Now, as you can see when it's viewed, if you run your program, you will see this window. Now here we have the problem. If you have problem, you will see it in this window down here. Here we have the outputs, the bug, but we don't need all these windows for our projects. For the moments, we need just the terminal, terminal we use it for to install our libraries. So as you know, to install any library in Python, I will say 990 hundreds of libraries because there is some evidence that changing, thus you change for us in some cases. But for this project we will use this command. So to install any of these 2D library, these you have to rise just pip install like this stone. But if it won't work for you, install, you have just to add here three, pip3 install, but I think that's pip install work. But in some cases, if you have two versions of your Python in your PC, for example, Python 3 and vital to, so it will give you a problem. So in this case you have to rise PPA, pip3 install, then the name of library. So the first library that we need to install reaches below as I told you. So pillow USE thus it will write that requires already satisfied because I have already installed it. Then you have to do the same thing for this one. Pip install and your eyes, the name which is PDF by video of 32, sorry, Dan, you have to write by PDF, by TTT as extreme. We will do it here too so that you can see. But I have already installed. So you have here, you have to write pip install. Then the name which is by PDF, to like this. Then you have to click Add new, as you can see, already installed. Then the same thing for the other one, which is pip install. That here you have to write piety as a tree. And you can see that's that is already installed but I don't yes. Already installed as you consider require payments, Sorry. Requirements already been satisfied. So as you can see, I don't need to install it because it is here. Sorry, clear this one. Now as you can see here, are all the tools that we need. We need to install Python than a text editor, than all of these libraries. Because I shown you how you can do this. In the next video, we'll start doing our program. So I see you there. Bye. 44. Audiobook | The program that says something: Hello everyone. In this section, I will show you how you can convert any texts to an audio. Which means if you have a variable that has a string, something and you want to put it on audio because the idea of our project is to take any text, which means if you have, for example, a book in a PDF, so you'll have to take that text from the PDF and convert it to an audio. So before doing that, we will start by something easy, which means we take a simple sentence or simple texts and we put it as an audio. That in the next sections we'll do that in PDF. And you will see that it is very easy. We do it in four lines. Okay, so we'll go here to our text editor. As I told you in the previous video, you can use, for example, this initial reaches video code, but if you have another one, it is, okay, okay, don't worry about it. Any editor and it takes initial will work for this project. So then after installing the text initially you have to install the libraries. Does I told you about? Now, let's get started. Once we have to do is first thing, if we want to use a liability, so we need to import it. So if we don't import it, the program will not recognize it with noisy humanize the functions that we'd use. So the first thing that we had to do, we have the imported, which is the function that I told you about, that we'll work with the audio which is by DCT as S3. So it just, we have just reported like this import by the, this one as extreme. Then after importing library, we have just to use it. So we go here, for example, the first thing that we need to do to initialize our speaker, which is the speaker does, we'll talk. So we will give a, or we'll create a variable, we'll call it speaker, that you will have the role of the speaker. So we will give it speaker. So after that, we need to initialize our library or we need to initialize our speaker. So to do that, we have to call a function that does include the, included, sorry, on this library. So what we have to do is just to write the name of the library, which is byte entity as AX3. Then hear that. And we have here dysfunction in it which is initialized. So clicking, if you are using a function, does you have always in Python or any programming language, if you are using any func