1
00:00:01,700 --> 00:00:07,520
OK, in this video, we're going to start to talk about menus and you might call them menu bars.

2
00:00:07,700 --> 00:00:10,580
And what I'm talking about is take a look at Sublime over the top.

3
00:00:10,590 --> 00:00:12,530
We have this sort of menu thing.

4
00:00:12,530 --> 00:00:15,640
And if you click on something, it drops down and there's things you can click on.

5
00:00:15,860 --> 00:00:17,060
How do we do this with Kenta?

6
00:00:17,300 --> 00:00:19,210
Well, it's actually not that hard at all.

7
00:00:19,520 --> 00:00:21,290
So it takes a couple of different steps.

8
00:00:21,590 --> 00:00:26,100
First, we need to sort of define our menu so we can call it anything we want.

9
00:00:26,420 --> 00:00:28,700
I'm just going to name this my underscore menu.

10
00:00:29,030 --> 00:00:36,700
And we set this equal to a menu widget and we want this to be in root, our root icon or our root window.

11
00:00:36,710 --> 00:00:37,030
Right.

12
00:00:37,520 --> 00:00:40,850
So then we need to do some configuration to our root window.

13
00:00:41,030 --> 00:00:43,400
So we go a root dot config.

14
00:00:44,900 --> 00:00:47,010
And then we need to tell it what menu to use.

15
00:00:47,030 --> 00:00:50,120
Well, we only have one menu, but we still have to define it.

16
00:00:50,120 --> 00:00:53,950
So menu equals and let's go my underscore menu.

17
00:00:54,050 --> 00:00:55,730
So, OK, now we're defined.

18
00:00:55,730 --> 00:00:58,310
We've we've told it to use that menu.

19
00:00:58,490 --> 00:01:00,320
And Clinton knows what a menu is.

20
00:01:00,320 --> 00:01:01,880
It knows it goes up at the top.

21
00:01:01,880 --> 00:01:04,070
We don't have to, like, pack it up there or anything.

22
00:01:04,280 --> 00:01:06,150
It will put it up there on its own.

23
00:01:06,410 --> 00:01:11,540
So now we need to create menu items.

24
00:01:12,530 --> 00:01:17,320
So let's just kind of make some fake stuff here, we've got file, edit and selection, maybe we'll

25
00:01:17,360 --> 00:01:17,960
we'll do that.

26
00:01:17,960 --> 00:01:23,240
So let's do let's do one called file so we create a variable and I'm going to call it file menu and

27
00:01:23,240 --> 00:01:27,410
think of each of these things like file edit selection.

28
00:01:27,410 --> 00:01:29,480
Think of them as submenus.

29
00:01:29,480 --> 00:01:29,800
Right.

30
00:01:29,810 --> 00:01:34,790
So we've got our main menu, but now we need to create little submenus for each thing you want at the

31
00:01:34,790 --> 00:01:35,320
top there.

32
00:01:35,330 --> 00:01:39,470
So the first one we're going to call file menu and set that equal to a menu.

33
00:01:39,470 --> 00:01:40,350
And what menu?

34
00:01:40,350 --> 00:01:42,580
Well, we want to use my menu.

35
00:01:43,460 --> 00:01:46,100
So we're saying, hey, put this submenu in the main menu.

36
00:01:46,250 --> 00:01:46,590
Right.

37
00:01:47,140 --> 00:01:50,220
And then we need to say what it's going to look like.

38
00:01:50,240 --> 00:01:51,110
So let's go.

39
00:01:52,130 --> 00:02:00,620
My menu does not add underscore Kaskade now when we put other things on the screen, we pack or grid

40
00:02:00,620 --> 00:02:02,900
them with menus, you cascade them.

41
00:02:02,900 --> 00:02:03,290
Why?

42
00:02:03,290 --> 00:02:06,190
Because when you click on it, it's like cascading open.

43
00:02:06,410 --> 00:02:08,240
I guess that's how I think of it at least.

44
00:02:08,720 --> 00:02:12,380
So we add Cascade and now we can put a label on here.

45
00:02:13,070 --> 00:02:16,850
Now notice again, this is not a capital L. It's a lowercase L.

46
00:02:16,850 --> 00:02:18,290
I don't know why Sublime does that.

47
00:02:18,590 --> 00:02:23,390
It makes it sort of cursive looking and it looks like an uppercase L. But it's not as lowercase.

48
00:02:23,750 --> 00:02:30,020
So let's say we want this to read file and then what menu?

49
00:02:30,170 --> 00:02:31,940
Again, I have to define this.

50
00:02:32,570 --> 00:02:36,410
Well, it's not my menu now.

51
00:02:36,410 --> 00:02:37,910
It's file menu.

52
00:02:39,780 --> 00:02:41,970
Because this is the submenu we're creating, right?

53
00:02:42,480 --> 00:02:46,950
OK, so that's that now we need to define what's going to be inside of here.

54
00:02:46,960 --> 00:02:49,270
So when we click file, what do we want to pop up?

55
00:02:49,290 --> 00:02:54,090
So let's have one for new and let's have one for, I don't know, just do a couple here.

56
00:02:54,090 --> 00:02:55,590
We'll do open an exit.

57
00:02:55,590 --> 00:02:57,750
Maybe we'll go file underscore menu.

58
00:02:59,770 --> 00:03:05,530
That ad underscore command, because think of these like when you click a button, remember or command

59
00:03:05,670 --> 00:03:06,620
running a command.

60
00:03:06,910 --> 00:03:07,540
Same thing here.

61
00:03:07,570 --> 00:03:10,690
We're clicking a button and we want it to add a command.

62
00:03:10,780 --> 00:03:12,120
So sort of think of it like that.

63
00:03:12,310 --> 00:03:14,220
And same deal we got a label equals.

64
00:03:14,230 --> 00:03:15,280
And so let's go new.

65
00:03:16,750 --> 00:03:23,310
And now command equals let's just go take command, right?

66
00:03:23,380 --> 00:03:28,690
So in this when we click this, we just want to run the function, fake command and let's come up here

67
00:03:28,690 --> 00:03:32,130
and define our fake command.

68
00:03:32,830 --> 00:03:36,060
So let's just go define fake command.

69
00:03:36,430 --> 00:03:37,840
And for now, I'm just going to type past.

70
00:03:37,840 --> 00:03:41,710
It's not going to do anything more will play with it later and make it do something.

71
00:03:42,140 --> 00:03:43,480
OK, so that's that.

72
00:03:44,980 --> 00:03:52,240
So we can copy this and let's create another one that's just say exit, and we can actually close a

73
00:03:52,240 --> 00:03:55,920
program by calling Route Dot quit.

74
00:03:56,320 --> 00:03:58,390
So this will just close the program.

75
00:03:58,770 --> 00:04:03,750
OK, so if we save this and run it and again, I call this menu that pie.

76
00:04:04,570 --> 00:04:06,640
Now we have this file file bar.

77
00:04:06,640 --> 00:04:09,220
If we click on it new, nothing happens.

78
00:04:09,220 --> 00:04:12,120
We also click exit and the program closes.

79
00:04:12,340 --> 00:04:13,010
So pretty cool.

80
00:04:13,300 --> 00:04:18,940
One more quick thing I'll show you is we can actually add a little bar between things in our menu.

81
00:04:18,940 --> 00:04:23,110
So like right here between these two things, there's this separator bar.

82
00:04:23,530 --> 00:04:24,820
We could do that really easily.

83
00:04:24,830 --> 00:04:32,680
We just come in here and just call file, underscore menu, dot add, underscore separator.

84
00:04:36,690 --> 00:04:41,910
And it's just a function and we don't have to pass anything into the function just on its own will work,

85
00:04:41,910 --> 00:04:43,080
so let's save this and run it.

86
00:04:43,770 --> 00:04:47,710
And now you see we have this bar between these two things, and that's pretty cool.

87
00:04:48,030 --> 00:04:50,060
And again, if we click this, nothing happens quickly.

88
00:04:50,100 --> 00:04:51,230
Exit it exits.

89
00:04:51,480 --> 00:04:52,190
So very cool.

90
00:04:52,200 --> 00:04:53,480
And that's how you create menus.

91
00:04:53,490 --> 00:04:56,040
So we went through that pretty quick in the next video.

92
00:04:56,040 --> 00:04:59,430
We'll go over the summer and we'll add more submenus.

93
00:04:59,730 --> 00:05:02,030
And so you'll see how to do more than one.

94
00:05:02,040 --> 00:05:04,950
Once you learn how to do two, you can do as many as you want.

95
00:05:04,980 --> 00:05:05,160
Right.

96
00:05:05,230 --> 00:05:07,710
So we'll look at adding a second one in the next video.
