Hello and welcome to part two where we will continue with the creation of the weight conversion tool
to carry on.
I'm going to add some lines of code that I have already pre staged.
I have had it some more lines of code here.
So this is the line of code I've added.
So here we've got a variable here.
I've set it to a string var method that means this who accept string values.
Here again the meter's variable.
Set it to a string file which means it again it will accept string variables.
I've also created three main widgets for our program.
We've got the entry where we'll type the number of feet which is this here.
This is where we'll type the number of feet.
OK.
And then a label where we will put the resulting numbers of feet.
OK.
This label here is where we will put the result to number and got a calculate button that will we will
press to perform the calculation which is this line of code here for each of the three widgets that
we have created we need to do two things we need to create the widget itself and then we need to place
it on the screen all the three widgets which are children of our main content window are created as
instances of one of the T keys themed widget classes the same time we create them we also need to give
them certain options such as how wide the entry should be the text the position of the text inside the
button the entry and the label we need to assign each of them text variables so you can see the text
variables here have attached when you create widgets they don't automatically show up on the screen.
This is because T.K. doesn't know how you want them to be placed in relative to other widgets OK.
So this is where the great method comes in.
Remember when you we did in here when we were doing the frame we did a bit of greed.
There was some greed involved in there.
So we place each widget in the appropriate column so it could be column one two or three and also in
the appropriate role.
So for example row one two or three.
We've also used this tiki option.
You can see the sticky the sticky option says or it's used as Perspex specify how the widget will line
up within the grid cell.
So it does that using the direction of the compass.
So W stands for West which means Uncle the widget to the left side of the cell W E stands for w e which
means Uncle it to both the left and the right side and so on.
Next we're going to add some lines of code that will create three static text label that we will use
for the user interface.
So I've now added the lines of code.
These are the labels that we'll be using for the user interface.
All the three lines of code here they do exactly the same thing for the three static text labels that
we're adding to the user interface.
So each one he's created and placed in the appropriate cell in the grid.
So we've added some more line of code to finish up the user interface.
So these are the lines of code I I've just added on.
So let me just walk you through that.
The first line here.
So I'm using a for loop here.
So that first line there basically you walk through or all the widgets that are children of our content
frame and it will then add a little bit of padding around each.
So the errant so so that they are not all squashed up together.
That's what that does.
We could have added these options to each of the Creed when we first put a test on the screen but this
doing it this way is a more it's a nice on a shorter way.
That way we don't write too many code.
This line of code here that line basically tells T.K. to put the focus on our entry widget.
So any way you see me talking about T.K. I'm making a reference to the T.K. function which is part of
the T Kintore module.
So this line here like I said is basically used to tell T.K. to put the focus on our entry widget that
way the cursor will start in that field.
It does its best to do it that way.
So the user doesn't have to click it before starting to type.
Let's move on to the third line which is this one here.
The third line basically tells T.K. that if the user presses the return key enter on a window anywhere
within the root window that should call our calculate routine.
All right.
So if the user should press the return key or enter a return and enter the same thing.
So if they're pressed if you're on a window it will be enter on a Mac probably will be returned.
So if the user should press that T.K. basically will respond by calling they calculate routine.
OK.
The same will happen if the user presses a calculate button and then we've got the main loop here.
This event loop.
This is what keeps the application running until the application is close.
So the application we keep running on looping until it is close and it is controlled by this route.
The main it is what controls the events that occur within the application.
So that's set for this part in the final part in Part 3.
We are going to create a function that will actually perform the calculation.
Thank you for watching and see you in part 3.