1
00:00:00,690 --> 00:00:08,100
Hello and welcome to part two where we will continue with the creation of the weight conversion tool

2
00:00:09,150 --> 00:00:09,960
to carry on.

3
00:00:09,960 --> 00:00:17,290
I'm going to add some lines of code that I have already pre staged.

4
00:00:17,580 --> 00:00:20,950
I have had it some more lines of code here.

5
00:00:21,000 --> 00:00:24,280
So this is the line of code I've added.

6
00:00:24,330 --> 00:00:26,570
So here we've got a variable here.

7
00:00:26,640 --> 00:00:35,280
I've set it to a string var method that means this who accept string values.

8
00:00:35,400 --> 00:00:38,100
Here again the meter's variable.

9
00:00:38,160 --> 00:00:45,370
Set it to a string file which means it again it will accept string variables.

10
00:00:45,450 --> 00:00:52,110
I've also created three main widgets for our program.

11
00:00:52,110 --> 00:01:00,560
We've got the entry where we'll type the number of feet which is this here.

12
00:01:00,780 --> 00:01:03,240
This is where we'll type the number of feet.

13
00:01:03,840 --> 00:01:04,510
OK.

14
00:01:04,620 --> 00:01:12,960
And then a label where we will put the resulting numbers of feet.

15
00:01:12,960 --> 00:01:14,070
OK.

16
00:01:14,190 --> 00:01:25,320
This label here is where we will put the result to number and got a calculate button that will we will

17
00:01:25,320 --> 00:01:34,050
press to perform the calculation which is this line of code here for each of the three widgets that

18
00:01:34,230 --> 00:01:43,830
we have created we need to do two things we need to create the widget itself and then we need to place

19
00:01:43,830 --> 00:01:55,110
it on the screen all the three widgets which are children of our main content window are created as

20
00:01:55,290 --> 00:02:06,600
instances of one of the T keys themed widget classes the same time we create them we also need to give

21
00:02:06,600 --> 00:02:17,040
them certain options such as how wide the entry should be the text the position of the text inside the

22
00:02:17,040 --> 00:02:28,420
button the entry and the label we need to assign each of them text variables so you can see the text

23
00:02:28,420 --> 00:02:38,300
variables here have attached when you create widgets they don't automatically show up on the screen.

24
00:02:38,440 --> 00:02:52,260
This is because T.K. doesn't know how you want them to be placed in relative to other widgets OK.

25
00:02:52,390 --> 00:02:57,180
So this is where the great method comes in.

26
00:02:57,190 --> 00:03:04,130
Remember when you we did in here when we were doing the frame we did a bit of greed.

27
00:03:04,180 --> 00:03:06,220
There was some greed involved in there.

28
00:03:06,520 --> 00:03:14,350
So we place each widget in the appropriate column so it could be column one two or three and also in

29
00:03:14,350 --> 00:03:15,250
the appropriate role.

30
00:03:15,250 --> 00:03:19,180
So for example row one two or three.

31
00:03:19,240 --> 00:03:21,150
We've also used this tiki option.

32
00:03:21,190 --> 00:03:31,540
You can see the sticky the sticky option says or it's used as Perspex specify how the widget will line

33
00:03:31,540 --> 00:03:33,700
up within the grid cell.

34
00:03:34,840 --> 00:03:39,480
So it does that using the direction of the compass.

35
00:03:39,550 --> 00:03:51,010
So W stands for West which means Uncle the widget to the left side of the cell W E stands for w e which

36
00:03:51,010 --> 00:03:59,740
means Uncle it to both the left and the right side and so on.

37
00:03:59,800 --> 00:04:10,480
Next we're going to add some lines of code that will create three static text label that we will use

38
00:04:10,480 --> 00:04:12,970
for the user interface.

39
00:04:13,030 --> 00:04:15,970
So I've now added the lines of code.

40
00:04:16,000 --> 00:04:22,260
These are the labels that we'll be using for the user interface.

41
00:04:23,230 --> 00:04:31,330
All the three lines of code here they do exactly the same thing for the three static text labels that

42
00:04:31,330 --> 00:04:33,640
we're adding to the user interface.

43
00:04:34,090 --> 00:04:40,990
So each one he's created and placed in the appropriate cell in the grid.

44
00:04:41,350 --> 00:04:46,930
So we've added some more line of code to finish up the user interface.

45
00:04:46,960 --> 00:04:51,640
So these are the lines of code I I've just added on.

46
00:04:52,720 --> 00:04:54,640
So let me just walk you through that.

47
00:04:54,850 --> 00:04:57,760
The first line here.

48
00:04:58,550 --> 00:05:01,870
So I'm using a for loop here.

49
00:05:01,990 --> 00:05:13,870
So that first line there basically you walk through or all the widgets that are children of our content

50
00:05:13,870 --> 00:05:21,060
frame and it will then add a little bit of padding around each.

51
00:05:21,790 --> 00:05:26,920
So the errant so so that they are not all squashed up together.

52
00:05:26,920 --> 00:05:28,930
That's what that does.

53
00:05:29,980 --> 00:05:40,420
We could have added these options to each of the Creed when we first put a test on the screen but this

54
00:05:40,420 --> 00:05:44,710
doing it this way is a more it's a nice on a shorter way.

55
00:05:44,710 --> 00:05:46,810
That way we don't write too many code.

56
00:05:47,230 --> 00:06:02,140
This line of code here that line basically tells T.K. to put the focus on our entry widget.

57
00:06:02,140 --> 00:06:08,410
So any way you see me talking about T.K. I'm making a reference to the T.K. function which is part of

58
00:06:08,410 --> 00:06:12,460
the T Kintore module.

59
00:06:12,460 --> 00:06:21,640
So this line here like I said is basically used to tell T.K. to put the focus on our entry widget that

60
00:06:21,640 --> 00:06:26,920
way the cursor will start in that field.

61
00:06:26,930 --> 00:06:29,260
It does its best to do it that way.

62
00:06:29,260 --> 00:06:34,890
So the user doesn't have to click it before starting to type.

63
00:06:35,020 --> 00:06:38,560
Let's move on to the third line which is this one here.

64
00:06:38,560 --> 00:06:51,670
The third line basically tells T.K. that if the user presses the return key enter on a window anywhere

65
00:06:51,880 --> 00:06:58,570
within the root window that should call our calculate routine.

66
00:06:58,570 --> 00:06:58,980
All right.

67
00:06:59,010 --> 00:07:05,560
So if the user should press the return key or enter a return and enter the same thing.

68
00:07:05,950 --> 00:07:11,040
So if they're pressed if you're on a window it will be enter on a Mac probably will be returned.

69
00:07:11,410 --> 00:07:23,860
So if the user should press that T.K. basically will respond by calling they calculate routine.

70
00:07:24,160 --> 00:07:24,910
OK.

71
00:07:25,000 --> 00:07:34,910
The same will happen if the user presses a calculate button and then we've got the main loop here.

72
00:07:34,910 --> 00:07:36,460
This event loop.

73
00:07:36,470 --> 00:07:44,360
This is what keeps the application running until the application is close.

74
00:07:44,510 --> 00:07:50,870
So the application we keep running on looping until it is close and it is controlled by this route.

75
00:07:50,960 --> 00:07:58,190
The main it is what controls the events that occur within the application.

76
00:07:58,190 --> 00:08:02,380
So that's set for this part in the final part in Part 3.

77
00:08:02,450 --> 00:08:09,610
We are going to create a function that will actually perform the calculation.

78
00:08:09,650 --> 00:08:12,370
Thank you for watching and see you in part 3.
