1
00:00:01,680 --> 00:00:07,440
OK, so in this video, I want to show you how to hide things and then reshow them, so I've created

2
00:00:07,440 --> 00:00:10,440
a new file called Hide PIEDs, the same file we've been working on.

3
00:00:10,440 --> 00:00:13,280
I just took out the image thing that we looked at in the last video.

4
00:00:13,650 --> 00:00:16,560
And so if you don't remember, let's run this real quick.

5
00:00:16,830 --> 00:00:20,190
We just have our little app we can enter in a name.

6
00:00:21,310 --> 00:00:26,320
We can add it, click me, and it pops up here, so what if we want to then get rid of this Hello John

7
00:00:26,530 --> 00:00:31,540
and remove it or and then after we've removed it, what if we want to put it back again?

8
00:00:31,700 --> 00:00:36,630
That's we're going to look at in this video so we can do this a couple of different ways.

9
00:00:37,150 --> 00:00:40,660
So let's come down to our button and let's create another button.

10
00:00:40,660 --> 00:00:41,950
And I'm just going to copy this.

11
00:00:43,900 --> 00:00:49,360
And then here I'm going to type and show.

12
00:00:50,890 --> 00:00:58,180
Well, let's start with hide, hide, and let's do it again and let's take this one and call it a show

13
00:00:58,810 --> 00:01:00,040
and we need to change these.

14
00:01:00,040 --> 00:01:03,870
So let's call this, um, what do you think?

15
00:01:04,180 --> 00:01:05,290
Hide button, maybe.

16
00:01:08,280 --> 00:01:10,620
And we'll call this one show button.

17
00:01:13,640 --> 00:01:21,320
And OK, so when this one gets clicked, we want to run a function called hide, and when this one gets

18
00:01:21,320 --> 00:01:23,740
clicked, we want to run a function called show.

19
00:01:24,300 --> 00:01:25,790
So now we need to create those functions.

20
00:01:25,820 --> 00:01:28,970
Let's come up to the top here and below this guy.

21
00:01:28,970 --> 00:01:30,680
Let's go hide function.

22
00:01:32,640 --> 00:01:34,620
And so we can define hide.

23
00:01:35,930 --> 00:01:40,640
And then for now, just go past and then let's go show function.

24
00:01:42,940 --> 00:01:47,110
And so we can define, show and then pass.

25
00:01:47,740 --> 00:01:49,090
OK, so what do we want to do?

26
00:01:49,120 --> 00:01:56,050
Well, we want to hide or show that text that gets put on the screen, which is the way we click the

27
00:01:56,050 --> 00:01:58,090
clicked button and this thing.

28
00:01:58,090 --> 00:02:02,670
So it's my label, too, is what we want to either hide or show.

29
00:02:02,680 --> 00:02:02,910
Right.

30
00:02:02,960 --> 00:02:05,350
So if we want to hide it, there's two ways to go about it.

31
00:02:05,350 --> 00:02:11,470
And the first one I'll show you is Haak underscore forget.

32
00:02:12,660 --> 00:02:17,490
And all this does is it just kind of forgets, it removes it, but it still exists.

33
00:02:17,700 --> 00:02:23,460
You can also do we'll look at it in a second destroy and that just destroys it.

34
00:02:23,460 --> 00:02:24,440
That deletes it forever.

35
00:02:24,450 --> 00:02:25,770
We don't want to do that just yet.

36
00:02:25,950 --> 00:02:29,040
What we want to do is pack, underscore, forget.

37
00:02:29,190 --> 00:02:33,390
And you can also if you're using the grid system, you can do grid forget.

38
00:02:33,540 --> 00:02:35,160
Same thing acts the same way.

39
00:02:35,520 --> 00:02:36,900
But what we're doing pack right now.

40
00:02:36,900 --> 00:02:43,230
So we just want to go pack, forget, and if we want to show it, we would just go, we could just pack

41
00:02:43,230 --> 00:02:43,980
it back in again.

42
00:02:43,980 --> 00:02:44,250
Right.

43
00:02:44,640 --> 00:02:46,230
OK, so let's save this and run it.

44
00:02:46,470 --> 00:02:47,670
See what we got here.

45
00:02:48,090 --> 00:02:50,130
So we've got to maybe take out this padding.

46
00:02:51,120 --> 00:02:52,940
So John, click me.

47
00:02:53,090 --> 00:02:53,850
It shows up.

48
00:02:54,120 --> 00:02:55,200
We can click hide.

49
00:02:55,560 --> 00:02:56,760
Oh, it's still there.

50
00:02:57,330 --> 00:02:58,860
So something has gone wrong.

51
00:02:59,430 --> 00:03:01,650
My label too is not defined.

52
00:03:01,860 --> 00:03:03,110
So check this out.

53
00:03:03,120 --> 00:03:04,560
There's something we need to talk about.

54
00:03:05,070 --> 00:03:10,860
Any time you're writing any kind of code, you need to understand the scope of your variable.

55
00:03:10,870 --> 00:03:18,510
So local variables versus global variables, a local variable only works inside of a function.

56
00:03:18,750 --> 00:03:21,540
If it's a global variable, it works anywhere.

57
00:03:21,540 --> 00:03:26,880
So we can come up to our click function and we can call my underscore label, too.

58
00:03:27,240 --> 00:03:28,710
And then we could just.

59
00:03:30,610 --> 00:03:37,330
And we could just call this a global, so now it should work outside of the function that it was created

60
00:03:37,330 --> 00:03:39,570
in so we can come back here and run this again.

61
00:03:39,970 --> 00:03:41,470
And when we do, we can type in.

62
00:03:41,470 --> 00:03:44,650
John, you can type click me when it shows up.

63
00:03:44,650 --> 00:03:48,880
If we click hide when it disappears, if we click, show when it shows up again.

64
00:03:49,120 --> 00:03:51,130
So that's interesting.

65
00:03:51,340 --> 00:03:55,810
Now let's take a look at Destroy so we can hide this and show it as many times as we want.

66
00:03:56,140 --> 00:03:56,960
And that's cool.

67
00:03:57,850 --> 00:04:02,110
So let's come back here and let's clear the screen because that is getting out of hand.

68
00:04:04,090 --> 00:04:08,430
So, OK, we can come to our high level and instead of PAC forget, let's try and destroy.

69
00:04:09,130 --> 00:04:13,810
So if we save this, come back here and run it again so we can type in.

70
00:04:13,810 --> 00:04:15,720
John, click me.

71
00:04:15,970 --> 00:04:17,680
Now, if we hide, we're not hiding it.

72
00:04:17,680 --> 00:04:18,460
We're destroying it.

73
00:04:18,460 --> 00:04:21,880
Now, if we click show, nothing happens because there's nothing to show anymore.

74
00:04:21,890 --> 00:04:22,570
We've destroyed.

75
00:04:22,570 --> 00:04:23,980
It does not exist anymore.

76
00:04:24,160 --> 00:04:27,730
We can come up here and run this again and then it shows up.

77
00:04:27,730 --> 00:04:28,090
Right.

78
00:04:28,600 --> 00:04:30,430
And we can destroy it again.

79
00:04:31,300 --> 00:04:37,090
But destroy kills it completely unless you recreate it again by, you know, doing whatever you did

80
00:04:37,090 --> 00:04:38,160
to create it in the first place.

81
00:04:38,170 --> 00:04:39,970
In this case, clicking the click me button.

82
00:04:40,300 --> 00:04:40,640
Right.

83
00:04:40,930 --> 00:04:43,540
So that's how to hide and show things pretty simple.

84
00:04:43,540 --> 00:04:47,740
Just remember PAC forget Ingrid forget and you should be good to go.

85
00:04:47,950 --> 00:04:50,530
In fact I'm just going to change this right back right now.

86
00:04:50,680 --> 00:04:56,800
Hack, underscore, forget and let's copy this and let's put a.

87
00:04:58,190 --> 00:05:06,230
Thing there, and let's go destroy, just so you remember, if you ever come back and check the code

88
00:05:06,230 --> 00:05:10,220
from this course, you'll have that listed there at the end of the course, I'm going to push on my

89
00:05:10,220 --> 00:05:11,150
code up to GitHub.

90
00:05:11,330 --> 00:05:14,420
My hope account is GitHub, dot com forward slash flat planet.

91
00:05:14,600 --> 00:05:19,460
You can search the repository there if you want to find the printer course here and look at this code.

92
00:05:19,730 --> 00:05:20,030
All right.

93
00:05:20,030 --> 00:05:22,580
In the next video, we're going to look at menus.

94
00:05:22,580 --> 00:05:24,770
That's like these things up here, right?

95
00:05:24,770 --> 00:05:26,630
These things that drop down and let you do things.

96
00:05:26,630 --> 00:05:27,600
How do we do that encounter?

97
00:05:27,890 --> 00:05:29,480
We'll start to look at that in the next video.
