Skip to playerSkip to main contentSkip to footer
  • 2 months ago
Transcript
00:00:00Hello and welcome to our channel. This is Aumit. Today is my first video in this channel.
00:00:07So today we are going to talk about Tickinter mainly.
00:00:13So we will create one application, one weather application.
00:00:18So through this we will learn Tickinter, database connection and API call.
00:00:28So we will learn three things. But first we will learn Tickinter.
00:00:35So Tickinter is a module in Python for creating GUI application.
00:00:45So without any further delay let's start with Tickinter.
00:00:50So first I am going to show you what kind of application we are going to make.
00:00:59So this is the application.
00:01:02So if I log in.
00:01:09One window will come asking for the city name.
00:01:19If I provide one city name.
00:01:34Suppose Kolkata.
00:01:39We will get the weather details of Kolkata.
00:01:45So we will get today's temperature, current temperature, maximum minimum temperature, pressure, humidity.
00:01:54So all these details.
00:01:56So I am getting this details data from one open weather web service.
00:02:04So today we are going to talk about how to call this.
00:02:11So first go to Tickinter.
00:02:15So as I said Tickinter is a GUI model.
00:02:19So first thing we need to do is to import the library.
00:02:24So import Tickinter.
00:02:29So if Tickinter is not installed in your Python.
00:02:36Then you will get some error that this model is not present.
00:02:42So you need to install it first through the pip command.
00:02:48pip install Tickinter.
00:02:51So after installing that, you start programming.
00:02:57So import Tickinter.
00:02:59And first thing is to create a window, GUI window.
00:03:05For that Tickinter has one class called Tick.
00:03:11So the Tickinter class will return an object of window.
00:03:18So I am naming it as some name, suppose window.
00:03:27So after that, you can set a different parameter in the window.
00:03:35Suppose title, title, open weather.
00:03:52then set the size of the window I'm setting as 280 cross 300
00:04:12and 280 is the width and 300 is the height of the window and we can set also the color background
00:04:31color for that window dot so config black so before changing the color I'm willing to show by default
00:04:57it comes with gray to load the window you have to call the main loop method okay so that's it so if I
00:05:14run this program you will get this window so it's not looking good it's kind of old kind window so
00:05:25if I change this then okay okay sorry
00:05:55so now if I run it will come like this okay so let's enter some
00:06:24levels and text fields like login user ID password and two bottom login and register so to do so
00:06:36tinder has one class column level so in this level we have to send the reference
00:07:05next window reference here then text suppose weapon
00:07:17okay now you want to fit it means you have to place this level to some position in the window for that I am using grid method
00:07:45so you can use grid or back so grid is basically separate the window in rows and columns so so so it is basically like a
00:08:15like a excess sheet so I am placing it in the row 0 and column 0 in the first place
00:08:22and let's check how it is coming now okay so see the level is coming but the thing is it is coming in
00:08:43gray background so we have to change this gray background so we have to change this gray background and we have to change the text color also so let's make the change for that
00:08:50so let's make the change for that
00:08:57so let's make the change for that
00:09:02bg equals black
00:09:07bg is background and foreground
00:09:12background and foreground
00:09:27and foreground
00:09:29bg equals yellow
00:09:30bg so on now see
00:09:31bg is changing
00:09:33bg 0
00:09:34bg
00:09:35bg
00:09:36bg
00:09:37bg
00:09:38fg
00:09:39c
00:09:39I am writing the login.
00:10:09Now, I am placing it below this line, below this line, so low will be 1, and column
00:10:39will be 0.
00:10:51Now I am going to enter one text field, so for that it can turn as a class called entry.
00:11:01So, in the same way we have to pass the window and that's all.
00:11:15Now, I am changing the column to one, so it will be placed beside this user edge.
00:11:26Now, I am changing the column to one, so it will be placed beside this user edge.
00:11:37So, let's see.
00:11:44So, now, yeah.
00:11:49So, it is looking good.
00:11:52Now, let's enter the password in the same way.
00:12:00Now, I am entering row 2, column 0, and it's row 2, column 1.
00:12:22Okay.
00:12:23Now, one thing we need to do here.
00:12:28Yeah.
00:12:29We don't want to show the password.
00:12:31So, we have to write, so, star.
00:12:38So, it will become as a star.
00:12:43Now, so, if I write anything here, it is coming as a normal text, but here it is coming as star.
00:12:59Now, we have to enter the button.
00:13:04For that, tick enter has button class.
00:13:17Wave, we have to pass window.
00:13:24And we also want to change the background and foreground color.
00:13:31Let's give the text.
00:13:33Now, I am changing the background color as yellow.
00:14:02So, that it will, it will look good.
00:14:07So, black.
00:14:09And we have to place this grid.
00:14:15Now, row will be 4.
00:14:28I am giving 4.
00:14:30The reason, I will tell you later.
00:14:31The reason, I will tell you later.
00:14:37So, let's see.
00:14:38So, let's see.
00:14:39So, now it is coming like this.
00:14:40So, let's see.
00:14:41So, now it is coming like this.
00:14:42But, the thing is, this text box and this button.
00:14:43are.
00:14:44So, now it is coming like this.
00:14:45So, let's see.
00:14:46So, now it is coming like this.
00:14:52So, let's see.
00:14:53So, now it is coming like this.
00:14:54So, let's see.
00:14:59So, now it is coming like this.
00:15:08But, the thing is, this text box and this button are.
00:15:15So, we have to place one dummy label in between this entry and the button.
00:15:44And, that's why I am using 4.
00:15:47So, level 3 will enter here.
00:15:50So, let's go.
00:15:54There will be no text.
00:16:00Blank.
00:16:01And, the row will be 3.
00:16:05So, now see.
00:16:09Now, it is coming.
00:16:12Good.
00:16:13So, after that, now if I click this button, nothing is working because we have not written
00:16:22any code there.
00:16:23So, we have to write the code.
00:16:25For that, we have to first capture the user id and the password given in the text field.
00:16:37So, that we can pass in the login.
00:16:42So, for that, we have to write one thing.
00:16:47That is.
00:16:48Text.
00:16:49Variable.
00:16:50Some variable name.
00:16:51Suppose.
00:16:52User id.
00:16:53Oh.
00:16:54It should come here.
00:16:56So, in the entry we should write their names.
00:17:03So, what if.
00:17:04Now, it is one error is coming here because the variable is not declared.
00:17:20So, in order to declare the variable, we have to write tickinter dot string bar.
00:17:37So, now this is resolved.
00:17:58In the same way, we have to write it in the password.
00:18:27So, password is also not declared.
00:18:30We have to declare this.
00:18:34Okay.
00:18:35So, now one more thing.
00:18:37Whenever this button is clicked, we have to trigger some function.
00:18:41For that, we have to write command.
00:18:42equals to function name.
00:18:43Login.
00:18:44Login.
00:18:45Okay.
00:18:46Okay.
00:18:47So, now one more thing.
00:18:51Whenever this button is clicked, we have to trigger some function.
00:18:59So, now we have to declare this function.
00:19:00So, we have to write command.
00:19:01For that, we have to write command.
00:19:02Because to function name.
00:19:06Login.
00:19:07Now, command.
00:19:08equal to register.
00:19:09Okay.
00:19:10Now, we have to declare this function.
00:19:11So, we have to declare this function above these two lines.
00:19:15So, we have to declare it here above.
00:19:16If we declare below, the python will not find that method and error will come.
00:19:20So, let's declare the function franchise.
00:19:21Okay.
00:19:22Okay.
00:19:23Now we have to declare this function.
00:19:23Now we have to declare this function.
00:19:25So, we have to declare this function above these two lines.
00:19:30So, we have to declare it here above.
00:19:33So, we have to declare it here above.
00:19:37If we declare below, the python will not find that method and error will come.
00:19:45let's declare the function first. So def to declare function def in
00:20:10some painting something
00:20:15And that is the name of the
00:20:18float in the ground.
00:20:21Let's take care of the
00:20:23one in the alone.
00:20:25Of course not.
00:20:27What's the one in the alone.
00:20:28Oh, I know that.
00:20:30And this is a sign for you.
00:20:33Your mind is a sign for the
00:20:35secret.
00:20:36And that's a sign for you.
00:20:38Before you start, I cannot
00:20:42Let's check and one more thing I'd like to do here so I want to pass this user
00:21:00ID and password through this function code so function will be like this
00:21:06for that I have to write a comment like this
00:21:36lambda hello and the function user ID and password
00:21:51okay good now here it won't come as a string to so to get the string value from this user
00:22:02ID and password right
00:22:16dot get so it will come as a string value now let's show this user ID
00:22:32let's write something
00:23:02that's it for tickinter we can customize many things in tickinter but this is the basic thing
00:23:14so in next part we will discuss about the database connection and the api call so for this part
00:23:23and welcome to our channel so today is the second part of the open weather app
00:23:32today we are going to show the database connection and api call but before starting with database
00:23:42connection I'd like to mention something in previous part I forgot to mention this so in tickinter you can also create checkbox or radio button
00:23:55and so the process of creating checkbox is similar to creating label or entry or button here the parameter few parameters are different
00:24:08like in checkbox like in checkbox you provide window text as usual and variable instead of text variable you provide variable so in variable you declare the variable name
00:24:23and you have to declare the variable here
00:24:28so after that on value means when this checkbox is checked what will be the value of this variable
00:24:44of this variable you mention and of value what will be the value of this variable so suppose if the this checkbox is checked then value will be yes if not checked then value will be no
00:25:02remember value will be no so this is for the check button and radio button
00:25:12radio button is similar but here you have mentioned the variable name
00:25:22but here you have mentioned the value
00:25:25and the value
00:25:27and the value if
00:25:31this radio button is selected
00:25:34the language value will be english if this radio button is selected
00:25:40then language value will be in d so let's see how it looks so
00:25:47yeah so mainly it looks like this
00:25:51so you can change the color background color
00:25:56so
00:25:58that's it for this
00:26:02then moving to the database connection so first register
00:26:10user have to register first
00:26:13so in register
00:26:15you have to
00:26:16enter this function you will create a one window
00:26:23that takes the first name last name email id whatever you want
00:26:29to save in database you can put there so to save some time i'm just
00:26:35copying and paste this
00:26:38function
00:26:39function so as you see this register function is called from here
00:26:48from this button
00:26:52okay so
00:26:58just
00:27:01copy this portion
00:27:09tell about this
00:27:22you can easily create this
00:27:23so here uh we just declaring this first name last name email
00:27:37uh this variable whatever we are going to
00:27:41use here to store in database
00:27:44so uh here you provide uh the level of first name
00:27:53then you provide the entry of first name
00:27:58and storing the value
00:28:00text variable value in first name
00:28:04so this is the same thing
00:28:06and after that after collecting all the data
00:28:12you are
00:28:15implementing two button one is register and one is cancel
00:28:20so whenever register button is clicked you are calling one function
00:28:26so this function pass that values
00:28:30whatever uh we can we get from this window
00:28:39so we are passing this value
00:28:43and just background color
00:28:46so that's all and uh if you user create uh cancel then this window will be destroyed so
00:28:55the destroy uh uh property is called here
00:29:02so this our window register window will be destroyed
00:29:09so now we have not recleared this function that's why this error is coming now
00:29:15so let's declare the function
00:29:18so we have to declare it over over this function so i'm declaring it here
00:29:29what is the name db connect register just copying this
00:29:50in the whole thing
00:29:51so here we are also passing this our window register window here
00:30:16so now what do we need to do so first of all we have to get the string value from this variable
00:30:28so for that left name goes to
00:30:36first name dot get so that's in that way we have to declare so i'm just copying
00:30:58first name dot get so
00:31:08so after that uh here we declare one function
00:31:16that is encrypt password so encrypt pass what uh it is doing we should not store the
00:31:24the text password in our database it should be hashed so what it is doing it is returning the hashed
00:31:40password value so in this function we are importing the crypt context
00:31:47in crypt context class you will define the schemas means what algorithm this class can support so we are
00:32:02initial instantiating this crypt context class while instantiating we are providing the schemas what this script context can support
00:32:17then we are declaring the default value
00:32:21among this algorithm so we this script context can support saa 256
00:32:33md5 or tes
00:32:36so we are setting this default value
00:32:40and we are providing the default rounds so after that we are
00:32:50hashing our password we are passing this password here
00:32:56and we are hashing and here we don't mention uh the default schema so by default it takes the
00:33:05the sharp 256
00:33:10after that we are returning this and we as we will store this value in our database so uh we are going to
00:33:21make the database connection so in database connection we can get some error so we want to handle the error
00:33:30error for that we will write the code and the track as below
00:33:40so in uh as i mentioned uh for uh database connection uh python has different connector
00:33:56for different database so for mysql it has mysql connector so
00:34:02in this project uh we will use mysql database so
00:34:10let's start
00:34:13first we have to create the connector
00:34:17for that mysql dot connector dot
00:34:37connect method
00:34:38so this is a uh function in this package so first it will take the in this you have to
00:34:57specify the host what is the host name so in this case it is local
00:35:03host host then you have to specify the
00:35:15uh username so
00:35:21this variety is
00:35:27root
00:35:28so you have to specify the user and the password so i'm not going
00:35:57to type the password here so i have written the password in the file
00:36:13so in the pwd file i have written the password so i'm reading from the file for that
00:36:20uh python has open method so in open method you don't need to import any library so just mention the
00:36:35file name pwd dot txt and the mode or you can skip it also so it will
00:36:47that you have to read the file
00:36:52file so
00:37:02after that uh you have to read the file
00:37:09that is the
00:37:09that is the file name pwd file so it will read the line one by one from the password so currently password
00:37:38you have only the password so it will store this value here in this string so here i am going to mention the pass
00:37:54okay so now we got the connector so i'm mentioning it
00:38:05so now we have to get the cursor it is quite similar to jd
00:38:16this connection for java so for after getting connector you have to
00:38:25get the car
00:38:28cursor
00:38:35okay
00:38:44you
00:39:05now using this cursor execute method you have to execute the comment so before
00:39:15executing the comment you have to write the comment first so I'm just copying
00:39:21the comments so here first comment is
00:39:35so the first we are using the database use open weather store I have created one database
00:40:04in my database mysql database so after that you are creating the table if not exist the
00:40:16user table you are defining all the columns and their size data type after that you insert
00:40:31one row in the database so in user table you are inserting one row so after that you are
00:40:48mentioning the argument so here you mention the values this value is referred
00:40:59in the argument so you have to pass this argument
00:41:09in argument you are capturing the first first name last name email like this so it will be if name
00:41:21after that you are using the execute method of cursor in execute method you are providing the query
00:41:40simply passing that query string value after that you are commenting then what actually
00:41:54it should work now so i'm just testing one thing
00:42:07let's run this code and click the register button
00:42:14and some error
00:42:15it is not indent
00:42:32okay so
00:42:33one important thing so here you open the cursor and connector so in finally
00:42:51finally block you have to close this cursor
00:43:08first cursor
00:43:09then connector dot close
00:43:21then connector
00:43:29dot close
00:43:35dot close
00:43:51So let's register say
00:44:21Okay
00:44:49Now see
00:44:51We're in database
00:45:54See, the entry has been created in the database.
00:46:13So, the password is hashed here.
00:46:18So, I think it's okay.
00:46:28So, after that, if someone registered, they should get one window that you are registered
00:46:38or something.
00:46:39So, for that, we have to create one more window.
00:46:44So, in this case also, I am just copying.
00:46:47And also, we have to declare this exception.
00:46:56If some exception occur, then we have to mention this.
00:47:00So, after commit, we have to destroy the register window.
00:47:17So, now we see that after register also, this window is appearing.
00:47:24It should not be the case.
00:47:26So, we have to destroy this window.
00:47:28And we have to create one new window, printing the success message.
00:47:36So, let's copy this.
00:47:45Because if I am going to write this, it will take more time.
00:47:49So, in the success window, we are just mentioning that you have successfully registered in OpenWeather.
00:48:05After that, you are providing one OK button.
00:48:13That button will destroy the newly created window.
00:48:20So, let's see once.
00:48:23Then we will move on to login.
00:48:28So, let's put something.
00:48:35So, like this, it will come.
00:49:00And as you see, the register window is just right.
00:49:04And if you click on OK, then this window will also be destroyed.
00:49:15After that, we should concentrate on login.
00:49:20So, in login, what will happen?
00:49:23In login, we will search in the database with the provided email ID.
00:49:29And we will check whether there is any entry for this email ID.
00:49:37And we will also bring the password of that entry.
00:49:42If the password is matched with the provided password, in this case, the password will be hashed.
00:49:54So, we will get the hashed value of the password.
00:50:00So, we have to first make another function to verify the password.
00:50:13So, I am just to verify the password, we are defining one checkpassword method.
00:50:24So, in the checkpassword, we are doing the same thing, the checkpassword, we are instantiating this object.
00:50:37So, we are using verify, instead of using hash, we are using verify.
00:50:45And in verify, we are passing the password provided in the login screen and the database password.
00:50:57So, in, we are calling this from the login method, providing the password we get from database.
00:51:07So, again, we have to connect to the database in same way.
00:51:12So, again, I am copying because the code is not small.
00:51:21It will take time.
00:51:22So, again, I am copying.
00:51:52So, now, I am explaining this login user ID.
00:52:01So, I have to change the name here.
00:52:09So, we are getting the username and password, the string value here.
00:52:15And same way, we are getting the connector.
00:52:22Then, in the cursor, after getting the cursor, we are selecting the query.
00:52:43So, we are selecting with the email ID.
00:52:48We are doing the query in the database where email ID is the provided email ID.
00:52:56So, in argument, we are providing the email ID.
00:53:00So, then, the same way cursor.execute to select the database and then cursor.execute to execute this select query.
00:53:15And we are fetching the data and we are checking whether this is column equals one.
00:53:30So, email ID is unique in the database and we should get only one email ID or we should not get any email ID at all.
00:53:44So, after that, we are just looping the record.
00:54:00So, ideally, there should be only one record.
00:54:04So, in that, we are getting the first column.
00:54:13So, here in select query, we get a list of columns.
00:54:20Here, there is only one column which is password and we are getting it by using the zero index.
00:54:31Then, we are checking whether this password is matching with the password provided or not.
00:54:45So, here we are checking and if this method written true, if the verify method written true,
00:54:57then we are allowing for login.
00:55:01Then, if we, after login, we are calling one function.
00:55:13So, in that function, again, we will call one window.
00:55:18So, we will create one window inside this function asking the city name.
00:55:27Or else, we are sending some failure message here.
00:55:35And if the, we are, same thing is doing in this else also.
00:55:42So, in that case, password is not matching.
00:55:45In that case, we don't find any username with this email ID.
00:55:52So, two different messages are printed here.
00:55:55So, let's create the open weather page function.
00:56:08So, let's try to get a couple of questions like this.
00:56:24If we are going to request a copy that we must take a copy that we will be using.
00:56:25Okay.
00:56:26So, let's write down the pages.
00:56:27So, let's try to do a copy that we have to go through this in this case.
00:56:30now here what we are doing we are just creating one window asking for city name so again i am
00:56:48copying just copying this is the same thing you know how to create the window so
00:57:00you
00:57:30so nothing special here we are just creating one window asking for the enter the city name
00:57:42so when the after providing city name user need to click on check so in the check button we are
00:57:55calling one more function get weather so this is the important function but we are calling the API so
00:58:06let's define the gate whether so first thing we have to do is to import
00:58:35one package called request so this package can pass the data from basically it can create one HTTP
00:58:49request and through this package we can get the response also
00:58:56so there is one method in request dot get here we have to provide the URL from where we will get the response
00:59:25so so before proceeding here I just like to give the open the open weather website and give how to
00:59:41get the API so let's type open weather API
00:59:47sorry
00:59:51you
00:59:53you
00:59:55you
00:59:56you
00:59:58you
01:00:00you
01:00:02you
01:00:04so first of all you have to create one account in open weather I have already created my account so after signing in you will get one API key so for that you have to go here your account page and you have to go to the API key tab
01:00:33so here you have to go to the API key so here you have to go to the API all the thing is not free this is free current weather data is free so you can go to price tag and check what is free and how much money you have to pay if you want to use if you want to use
01:01:01uh if you want to use some other feature
01:01:08so in API doc
01:01:13inside API
01:01:16you will get the detailed document how you can get the data by JSON format or XML format or HTML format so for this suppose this
01:01:30suppose this so if you type this
01:01:35uh
01:01:36url
01:01:37so
01:01:38you will get the JSON data
01:01:41of
01:01:42London
01:01:43so here Q is equal to
01:01:45London
01:01:46and
01:01:48you can also search with city ID
01:01:51you can also search with latitude longitude
01:01:55you can also search with zip code and
01:02:04here are you can also search with
01:02:08rectangular zone
01:02:09so you can read this and
01:02:12whatever if
01:02:14if you want to call you can call
01:02:18log
01:02:19so after that
01:02:20so
01:02:21after that
01:02:24so
01:02:25one thing
01:02:26like you can get
01:02:33this
01:02:34kind of format in JSON
01:02:38and
01:02:39you can also get
01:02:41in XML
01:02:48and
01:02:51here
01:02:52you can format
01:02:54which format
01:02:55you
01:02:56can
01:02:57you want to get
01:02:58suppose
01:02:59temperature
01:03:00you want to get
01:03:01in Celsius
01:03:02or Fahrenheit
01:03:03so for that
01:03:04what you have to do
01:03:06or
01:03:07you
01:03:08want to get
01:03:09the XML format
01:03:10or JSON format
01:03:11for that
01:03:12you have to write
01:03:13mode
01:03:14mode
01:03:15is equal to XML
01:03:16or
01:03:17mode
01:03:18is equal to HTML
01:03:19by default
01:03:20mode
01:03:21is
01:03:22JSON
01:03:23so
01:03:24you don't have to
01:03:25mention that
01:03:26and
01:03:27metric
01:03:28so
01:03:29in metric
01:03:30if
01:03:31you
01:03:32want
01:03:33centigrade
01:03:34temperature
01:03:35use
01:03:36unit
01:03:37equals
01:03:38metrics
01:03:39like
01:03:40provide
01:03:41one
01:03:42length
01:03:43here
01:03:44and
01:03:46unit
01:03:47equals
01:03:48metrics
01:03:49and
01:03:50if
01:03:51you
01:03:52want
01:03:53to
01:03:54for
01:03:55one
01:03:56Fahrenheit
01:03:57then
01:03:58unit
01:03:59equals
01:04:00to
01:04:01imperial
01:04:02so
01:04:03you
01:04:04can
01:04:05read
01:04:06this
01:04:07API
01:04:08and
01:04:09you
01:04:10can
01:04:11do
01:04:12whatever
01:04:13you
01:04:14want
01:04:15so
01:04:16currently
01:04:17I
01:04:18am
01:04:19calling
01:04:20this
01:04:21API
01:04:22so
01:04:23that
01:04:32is
01:04:34this
01:04:35API
01:04:36API
01:04:37URL
01:04:38so
01:04:39let me
01:04:52explain
01:04:53this
01:04:54API
01:04:55URL
01:04:56here
01:05:01here
01:05:02q
01:05:03here
01:05:04we
01:05:05are
01:05:06providing
01:05:07the
01:05:08second
01:05:09bracket
01:05:10because
01:05:11we want
01:05:12to
01:05:13replace
01:05:14it
01:05:15with city
01:05:16the
01:05:17selected city
01:05:18here
01:05:19and
01:05:20then
01:05:21matrix
01:05:22will
01:05:23get
01:05:24centigrade
01:05:25temperature
01:05:26and
01:05:27app
01:05:28id
01:05:29here
01:05:30you
01:05:31have
01:05:32to
01:05:33mention
01:05:34your
01:05:35API
01:05:36key
01:05:37so
01:05:38first
01:05:39we
01:05:40have
01:05:41to
01:05:42get
01:05:43the
01:05:44city
01:05:45so
01:05:46how
01:05:47can
01:05:48we
01:05:49get
01:05:50the
01:05:51city
01:05:52here
01:06:02you
01:06:03have
01:06:04mentioned
01:06:05the
01:06:06selected
01:06:07city
01:06:08here
01:06:09so
01:06:10let me
01:06:11pass
01:06:12this
01:06:13first
01:06:14we have
01:06:26to
01:06:27get
01:06:28the
01:06:29stream
01:06:30you
01:06:31have to
01:06:44pass
01:06:45this
01:06:46in
01:06:47format
01:06:48then
01:06:50we have to
01:06:51pass this
01:06:52in
01:06:53current
01:06:54now
01:06:55pass this
01:06:56URL
01:06:57in
01:06:58gate
01:06:59and
01:07:00you
01:07:01will get
01:07:02the
01:07:16data
01:07:17as
01:07:18i
01:07:19have not
01:07:20mentioned
01:07:21anymore
01:07:22so it
01:07:23will be
01:07:24print
01:07:25so
01:07:26let's
01:07:27print
01:07:28the
01:07:29data
01:07:30it
01:07:31the
01:07:32you
01:07:33have to
01:07:34do
01:07:36you
01:07:38you
01:07:40you
01:07:41you
01:07:44you
01:07:45you
01:08:47So, it is not printing properly.
01:09:09So, one thing I think I have forgot.
01:09:16You have to call that data equals to JSON.
01:09:46so here you get the json format data
01:10:14now let's
01:10:22let's format this so
01:10:34because it is not looking good we cannot understand from this because it is single lined
01:10:45if i process this
01:10:49so something is wrong
01:11:14so as you see
01:11:25this format is like the first the whole thing in the second bracket
01:11:36then inside this second bracket there is some entry like dictionary
01:11:47so inside that dictionary there is another dictionary
01:11:52so it's basically python dictionary so you can get this
01:11:59so if you want the coordinate so what you have to write data
01:12:05under third bracket quart so let's try
01:12:22we have latitude
01:12:30data
01:12:33Third bracket.
01:12:48So inside that we have latitude and latitude.
01:12:54So how can we get latitude?
01:12:57Again we have to provide third bracket then left.
01:13:09In the same way we can get the longitude.
01:13:23So let's try to run again.
01:13:53So let's try to run again.
01:14:00So let's try to run again.
01:14:08So let's try to run again.
01:14:23So let's try to run again.
01:14:30So let's try to run again.
01:14:45So let's try to run again.
01:14:52So let's try to run again.
01:15:00So let's try to run again.
01:15:25So you see you get the latitude and longitude value.
01:15:32In the same way you can get the description, main description and temperature, current temperature.
01:15:51What is the highest temperature?
01:15:55What is the minimum temperature?
01:15:58What is the humidity?
01:16:03So to get the temperature, what do you have to do?
01:16:08You have to go to main.
01:16:10So in the first, in the third bracket, first provide the main, then under, in the second third bracket,
01:16:26you provide the max temperature, mean temperature, humidity.
01:16:32So like this, you can get the wind, wind here.
01:16:46So one thing is that in main, this temperature, pressure are directly mentioned.
01:16:56But inside the weather, there is another second bracket, means there is one another element.
01:17:04So if you want to get the main, then you have to go to weather first.
01:17:16Then mention zero, because this is the zeroth element here.
01:17:23Then inside this, mention the main.
01:17:26So like this, like this.
01:17:49So basically, so here, you have to first check whether the response is 200 or not.
01:18:00It's a successful response or 404 or something error code will be written if it is not successful response.
01:18:14So first check this and then just print this, make any window and show this weather in that window.
01:18:25And else you mentioned the city not found.
01:18:30So let's just copy this, because this is the same thing.
01:18:44Let's run some error.
01:19:10Let's run some error.
01:19:14Okay.
01:19:15Okay.
01:19:16I have changed the variable name.
01:19:20So it should be.
01:19:27Yes city.
01:19:34Good.
01:19:35Now.
01:19:44So this error is basically, it cannot, some data it cannot encode.
01:20:01So that's why this error is coming.
01:20:18It may be written through.
01:20:19So it's not all.
01:20:20No, I can't.
01:20:22No, no.
01:20:23No, no.
01:20:24It's not what it is.
01:20:25I think it's going to be that error.
01:20:26No, no.
01:20:27No, no.
01:20:28No, no.
01:20:29It's not bad.
01:20:30It's not bad.
01:20:31No.
01:20:32No, no.
01:20:33No, no.
01:20:34No, no.
01:20:35No.
01:20:36No.
01:20:37No, no.
01:20:38No, no.
01:20:39No, no.
01:20:40No.
01:20:41No.
01:20:42No, no.
01:20:43No.
01:21:14So, it was not taking the degree value, so that's why this error was coming, I don't know why, here I have mentioned that degree centigrade, so it's not taking this, I don't know why, so let's run this.
01:21:44So, let's run this.
01:22:14So, you get all the details here, so for today, our session is done.
01:22:28So, have a nice day, bye.
Be the first to comment
Add your comment

Recommended