Hello and welcome to this video.
This video is going to be the part one of a series of videos on creatine a calculator with Python.
The first thing you need to do is open up a python shell so the way you access it is fine.
The python folder so if you go into your program file as a python folder and just click on the Idol
and that will launch the shell.
So once you've got the shell open we need to open up a new file so click on File.
New file and this file here is where we will write the code that will build the calculator the first
and I recommend you do a save this file save as a python file so you do safe has and then keep it whatever
name you want.
He's already got the python file format here so you don't need to worry about that.
Just give it a name.
I'm going to call mine calculator
calculator and I just press save and that will save it.
I wanted to save on my desktop so I click save.
So this file now is now a python file.
The first thing I want to do is import a library.
The library I want to import is called T counter is a library used to generate or create graphical user
interface.
So to do that we need to import it.
So you type in from then you specify the name of the module.
So this is a module is called teak into space and type in the word import space Asterix and that will
import the library into the application for me to you.
The next thing I want to do is create a class a class basically is a template for creating objects.
So our typing class followed by the name I want to give the class I'll call it application.
And when you create a class you can also passing arguments all parameters into it and I'm going to pass
him a frame has an argument into that class.
And when you create a class you also have to put a call on there.
So this would be the main class for the calculator.
Not as a passing frame that a frame basically is used to group and organize other widgets.
So it's kind of like a container object for all the widgets the application is going to use.
So inside this class I'm going to create a function or a method so to define a function you type in
the what the f followed by the name.
So I'm going to use the in it c to underscore in it on the score and then in parentheses is who are
passing the any arguments I want inside that function.
This on the score you need on the score function is a special function that is called when an instance
of a class is created.
So you use that to initialize that instance.
So inside the parentheses I'm going to pass same two arguments.
I'm going to passing herself variable and master the self is a reference to the current instance of
the class.
OK.
And that's what that self is.
And then the master represents the parent widget.
So now let's initialize the frame so to initialize the frame we're going to use a special built in function
and the built in function is called Super.
So inside the parentheses are passing some of the super function is a built in function which returns
a proxy object to delegates.
Method calls.
So he uses that to delegate method calls to a class which can either be a parent or a sibling in nature.
So inside a super function I pass Tim the application class here and also a reference to the cell variable.
And here I'm using the underscore in it again initialize the master widget.
This master also is known as the parent widget so we initialize in it.
Here to save time I've added a few lines of code here.
I've added these lines of code so this self again is a is a variable.
It's a reference to an instance of a class or an object that is created.
So here I am set in these two blank and then here I'm using the self again the user input.
This was going to be a user input variable and I've set that to equals to this string.
Var basically this string var is going to hold a string and the default value is blank.
But I've set this to make sure it holds a string value.
Then here we've got the create method.
The grid metal basically is used to register a widget with the great geometry manager.
So if you don't do this the widget will exist internally but it will not be visible on the screen so
the greed is used to register widgets with the jewel military manager.
The geometric manager is used to manage the placement and the layout of the elements of the go to create
on the score widget function which will use to create widgets.
So that's it for this part.
Thanks for watching.
Bye for now.