1
00:00:01,820 --> 00:00:06,530
I mean, the last video we looked at, grid, forget using a button, so if we type something in click

2
00:00:06,530 --> 00:00:08,370
submit, it's on there, boom.

3
00:00:08,370 --> 00:00:09,830
If we click clear, it disappears.

4
00:00:10,070 --> 00:00:16,820
If we do it again and then pick something else, just anything, boom, it overwrites it.

5
00:00:16,820 --> 00:00:18,520
And the stuff from before is still there.

6
00:00:18,530 --> 00:00:23,330
So in this video, we want to look at how to get rid of the stuff that was there from before.

7
00:00:23,580 --> 00:00:27,800
Any time we click this button without clearing like that.

8
00:00:27,960 --> 00:00:28,300
Right.

9
00:00:28,460 --> 00:00:31,080
And now that we've done it more than once, the clear button itself won't work.

10
00:00:31,100 --> 00:00:32,470
So how do we fix this?

11
00:00:32,480 --> 00:00:37,160
Well, if we look at our code, remember, when we click the clear button, we were running this grid

12
00:00:37,160 --> 00:00:38,360
forget function.

13
00:00:38,600 --> 00:00:41,990
So you might be tempted just to say, well, why don't we just bring that up here?

14
00:00:42,200 --> 00:00:47,030
And for our segment function, whenever we click the button to submit, just have the first thing that

15
00:00:47,030 --> 00:00:49,950
happens is delete that, whatever is there prior.

16
00:00:50,260 --> 00:00:50,570
Right.

17
00:00:50,600 --> 00:00:53,360
So if there's something there, delete it already.

18
00:00:53,660 --> 00:00:56,270
Well, we can try that, but it's not going to work and let's see why.

19
00:00:56,280 --> 00:00:57,410
So let's go ahead and run this.

20
00:00:59,010 --> 00:01:03,450
So we can type something in and then click, oh, now it's not even working at all.

21
00:01:03,720 --> 00:01:07,130
So now if we close out, we see how the label is not defined.

22
00:01:07,530 --> 00:01:10,200
Well, that's sort of the same area we were getting earlier.

23
00:01:10,470 --> 00:01:16,400
What we're defining global label right there, but we haven't actually assigned anything to it yet.

24
00:01:16,800 --> 00:01:17,120
Right.

25
00:01:17,170 --> 00:01:17,670
So.

26
00:01:19,390 --> 00:01:26,560
We could try, just like we did earlier, going, hello, underscore label and start saying that equal

27
00:01:26,560 --> 00:01:30,790
to a label and putting that in root and then just leaving like that.

28
00:01:31,000 --> 00:01:35,430
If we try this, see what happens, it is not going to work.

29
00:01:39,820 --> 00:01:43,310
But it's it's not actually deleting the thing, right?

30
00:01:43,540 --> 00:01:45,460
So what's going on here?

31
00:01:51,770 --> 00:01:52,990
We could try destroying it.

32
00:02:02,400 --> 00:02:07,320
So what we need to do is pull this outside of our function.

33
00:02:09,140 --> 00:02:15,830
So anywhere above our function, we are on that now, we can save this and run it.

34
00:02:19,690 --> 00:02:25,840
Type of any old thing, and we type in something smaller, boom, it works and the clear button still

35
00:02:25,840 --> 00:02:31,720
works, do you do something really long, smaller again?

36
00:02:32,440 --> 00:02:33,280
And that works.

37
00:02:33,290 --> 00:02:35,630
So that's one way you could just sort of do it.

38
00:02:36,010 --> 00:02:42,130
You could also, instead of running our destroy thing here, we could call our clear function.

39
00:02:43,330 --> 00:02:46,540
All right, if we save this and run it.

40
00:02:47,940 --> 00:02:51,270
Um, something smaller firm that works as well.

41
00:02:51,930 --> 00:02:59,040
So probably I would just use this that way we can use this clear function for the button or we could

42
00:02:59,040 --> 00:03:02,130
use the clear function for, you know, just like this.

43
00:03:02,670 --> 00:03:06,240
If we take this off, we comment this out.

44
00:03:06,630 --> 00:03:07,550
Well, there's still work.

45
00:03:07,650 --> 00:03:08,460
Let's find out.

46
00:03:10,300 --> 00:03:12,350
So we can do some big thing.

47
00:03:12,580 --> 00:03:13,510
No, it doesn't.

48
00:03:13,780 --> 00:03:17,230
Everything shuts down because hello label is not defined.

49
00:03:17,650 --> 00:03:23,470
So always a good idea to sort of define your variables if you're going to be changing them during your

50
00:03:23,470 --> 00:03:24,220
program.

51
00:03:24,450 --> 00:03:28,300
You know, like if a user is going to be changing them on the screen, you want to define your things

52
00:03:28,300 --> 00:03:33,400
outside of your functions just right at the beginning of your your code here.

53
00:03:33,970 --> 00:03:35,500
And that will take care of all that.

54
00:03:35,530 --> 00:03:36,610
So pretty simple.

55
00:03:37,420 --> 00:03:43,890
A little tricky and I mentioned we're doing grid forget if this if we were using PAC instead of grid,

56
00:03:44,160 --> 00:03:48,660
we could do PAC forget and that works exactly the same way.

57
00:03:48,660 --> 00:03:51,100
Or you could just use destroy every time to write.

58
00:03:51,120 --> 00:03:52,240
That works as well, too.

59
00:03:52,950 --> 00:03:54,690
It just sort of depends.

60
00:03:55,020 --> 00:03:59,280
There are times when you might want to hide something but not delete it forever and you would use grid

61
00:03:59,280 --> 00:04:00,330
forget or PAC forget.

62
00:04:00,570 --> 00:04:04,890
Other times you may just want to destroy a thing completely, so destroy works as well.

63
00:04:05,160 --> 00:04:07,230
So that's how to overwrite things like labels.

64
00:04:07,380 --> 00:04:09,270
This will work with other widgets as well.

65
00:04:09,780 --> 00:04:17,610
You can grid forget any anything really a button, an image, anything at all you can forget or destroy

66
00:04:17,790 --> 00:04:18,800
and that'll work.

67
00:04:19,080 --> 00:04:21,630
So in the next video we're going to look at the color picker.
