1
00:00:01,830 --> 00:00:08,520
OK, moving right along or is working pretty good, but now when we pull up a certain function like

2
00:00:08,520 --> 00:00:14,760
the addition thing here and then move to another one, that seems to work, but then if we go back again

3
00:00:14,760 --> 00:00:18,420
to the first one, what was originally printed is still there.

4
00:00:18,570 --> 00:00:20,430
And then it prints out another set.

5
00:00:20,430 --> 00:00:25,800
And you can see it's kind of, you know, doing a thing here and this is no good.

6
00:00:25,830 --> 00:00:26,730
So how do we fix this?

7
00:00:26,760 --> 00:00:28,200
Well, it's actually pretty easy.

8
00:00:28,450 --> 00:00:34,350
And I've showed you a couple of different ways to change things, you know, like overwrite labels or

9
00:00:34,350 --> 00:00:39,050
use the config feature to change what's in a label or a thing.

10
00:00:39,480 --> 00:00:41,490
What we can also do is just sort of.

11
00:00:42,730 --> 00:00:45,770
Destroy all of the things in a frame.

12
00:00:46,000 --> 00:00:52,140
So let's look at this again real quick, because I want you to understand what's going on here.

13
00:00:52,150 --> 00:00:58,570
So we've got our app, and so we've got basically three or four things here.

14
00:00:58,580 --> 00:01:00,100
We've got this label here.

15
00:01:00,360 --> 00:01:03,510
We've got this entry box, we've got a button, and then we've got this label here.

16
00:01:03,520 --> 00:01:04,600
So one, two, three.

17
00:01:04,600 --> 00:01:05,740
We've got four things.

18
00:01:06,070 --> 00:01:10,570
And each of these things is a child of the parent frame.

19
00:01:10,840 --> 00:01:12,070
So the frame is the parent.

20
00:01:12,070 --> 00:01:15,910
The things in the frame are the children, the children, widgets.

21
00:01:16,090 --> 00:01:21,310
So all we have to do is loop through and destroy all of those children widgets.

22
00:01:21,460 --> 00:01:26,950
Now we can look up the names for each ones, but that would be a hassle and, you know, changes from

23
00:01:26,950 --> 00:01:27,810
program to program.

24
00:01:28,390 --> 00:01:33,850
Instead, we can just sort of loop through all of the children in a particular frame.

25
00:01:34,120 --> 00:01:35,830
And that's what we're going to do in this video.

26
00:01:35,840 --> 00:01:43,930
So there's a function called dot w info underscore children and it just looks like this.

27
00:01:43,940 --> 00:01:46,090
Let me just copy and paste it.

28
00:01:46,420 --> 00:01:50,680
And what we want to do is go down to our hyd menu frames.

29
00:01:51,070 --> 00:01:57,010
Remember, this function gets fired any time one of our other functions gets fired.

30
00:01:57,020 --> 00:02:01,930
So when we call divide it, it calls that hyd menu frames function, remember from, I don't know,

31
00:02:01,930 --> 00:02:03,250
10 videos ago or so.

32
00:02:03,520 --> 00:02:08,810
And what that does is it hides all of the other frames that had already been up.

33
00:02:09,040 --> 00:02:11,860
Well, this is a great place to do this, what we need to do.

34
00:02:12,070 --> 00:02:14,470
So like I said, this is this function.

35
00:02:14,470 --> 00:02:16,840
It's the W info underscore children.

36
00:02:17,170 --> 00:02:23,440
And what we can do is just loop through each frame and then we destroy each thing.

37
00:02:23,440 --> 00:02:25,810
So let's do that so we can go for widget.

38
00:02:26,650 --> 00:02:27,820
Now, this is just a variable.

39
00:02:27,820 --> 00:02:29,590
This is a for loop with Python.

40
00:02:29,770 --> 00:02:32,530
It's not Kintyre things, just a loop thing, a python thing.

41
00:02:32,770 --> 00:02:33,960
So we create a variable.

42
00:02:33,970 --> 00:02:36,220
I'm just going to call it widget because that's what we're dealing with.

43
00:02:36,220 --> 00:02:36,790
Widgets.

44
00:02:37,520 --> 00:02:38,800
Again, it's not a counter thing.

45
00:02:38,800 --> 00:02:40,960
I'm just picking a random variable name.

46
00:02:40,960 --> 00:02:43,030
We could call it W we can call it X.

47
00:02:43,030 --> 00:02:46,470
It doesn't really matter, but it's a widget that we're going to be dealing with.

48
00:02:46,480 --> 00:02:47,410
So I'm going to call it widget.

49
00:02:47,650 --> 00:02:54,710
So for widget in and now we call our frame and let's start with the add underscore frame and then we

50
00:02:54,710 --> 00:02:57,550
can just dot w info children.

51
00:02:58,120 --> 00:02:59,560
So then we're going to loop.

52
00:02:59,800 --> 00:03:04,990
And so inside of here we can just go widget, dot, destroy.

53
00:03:07,010 --> 00:03:07,210
Right.

54
00:03:07,590 --> 00:03:08,040
So that's it.

55
00:03:08,070 --> 00:03:14,130
So this little for loop will loop through all of the widgets, the children widgets in our frame.

56
00:03:14,850 --> 00:03:21,540
So what this does is say, hey, go to the ad frame and then find all of the children in there and then

57
00:03:21,540 --> 00:03:24,610
loop through each one and then destroy each one.

58
00:03:25,020 --> 00:03:26,460
So that's all there is to it.

59
00:03:26,490 --> 00:03:33,350
So now we could just copy this and be sure that your tabbing here and not spacing.

60
00:03:33,360 --> 00:03:36,020
Remember, Python is tab sensitive.

61
00:03:36,300 --> 00:03:39,720
So one, two, three, four.

62
00:03:39,730 --> 00:03:41,790
And let's make a comment here.

63
00:03:41,790 --> 00:03:51,370
So say destroy the children widgets in each frame.

64
00:03:52,830 --> 00:03:54,980
And then down here, let's make a comment.

65
00:03:57,520 --> 00:04:02,560
Hide all frames, OK, so OK, for each of these, we need to fiddle with it.

66
00:04:02,570 --> 00:04:09,600
So this is the this will be the subtract frame and I'm just taking these names right here.

67
00:04:09,610 --> 00:04:17,560
So the next one will be multiply the frame and then finally divide frame.

68
00:04:20,060 --> 00:04:22,290
OK, so if we save this, this should work now.

69
00:04:23,030 --> 00:04:24,050
Let's go ahead and run this.

70
00:04:25,000 --> 00:04:32,920
And so we've got add and we go subtract and we go back to add and oh, it worked and it's not putting

71
00:04:32,920 --> 00:04:34,120
it again down here.

72
00:04:34,510 --> 00:04:39,220
So we could try for all of these, go back to add, back to subtract.

73
00:04:39,220 --> 00:04:39,820
Go back.

74
00:04:39,970 --> 00:04:40,880
Try and multiply.

75
00:04:40,900 --> 00:04:42,130
Go back to divide.

76
00:04:42,520 --> 00:04:45,280
And it seems to work for all of them.

77
00:04:45,290 --> 00:04:48,340
So pretty simple and a very handy little function to know.

78
00:04:48,910 --> 00:04:51,220
And that's all there is to it.

79
00:04:51,230 --> 00:04:57,100
So that's all with this video in the next video, I think will play around with the main screen of our

80
00:04:57,100 --> 00:04:57,540
app.

81
00:04:57,760 --> 00:05:00,280
So like right now it's just sort of blank here.

82
00:05:00,280 --> 00:05:03,070
So let's put a little something in there and make it look a little nicer.

83
00:05:03,250 --> 00:05:04,920
And I think we'll do that in the next video.
