1
00:00:00,450 --> 00:00:04,260
After having looked at an introductory app with Pi.

2
00:00:04,260 --> 00:00:12,570
q26 We're ready to go ahead and code our main app, which is the Student Management System app.

3
00:00:12,750 --> 00:00:17,670
Specifically in this video, we will construct this window.

4
00:00:18,150 --> 00:00:20,250
So that's the main window.

5
00:00:20,250 --> 00:00:25,230
And then in the next lecture, so we're going to construct the other windows as well.

6
00:00:25,770 --> 00:00:29,100
So each of them one by one.

7
00:00:29,100 --> 00:00:31,580
Let's start with the main window.

8
00:00:31,590 --> 00:00:34,830
So I'll work on the same page on projects.

9
00:00:34,830 --> 00:00:39,000
This time I'm going to create a main that P file.

10
00:00:39,330 --> 00:00:47,100
The import statements are basically the same as in the example file, so I'm going to copy that and

11
00:00:47,100 --> 00:00:48,390
paste it in here.

12
00:00:48,690 --> 00:00:51,270
We also need the system library.

13
00:00:53,660 --> 00:01:03,070
And create a class called it Main Window, which inherits from well, does it inherit from queue widget?

14
00:01:03,660 --> 00:01:04,340
No.

15
00:01:05,810 --> 00:01:14,390
This time we want to inherit from queue main window another type of class.

16
00:01:15,200 --> 00:01:20,480
Why do we inherit from queue main window instead of queue widgets?

17
00:01:20,480 --> 00:01:21,530
You'd ask.

18
00:01:22,480 --> 00:01:32,830
Well, we do that because CU main window allows us to add a menu bar here and a toolbar and a status

19
00:01:32,830 --> 00:01:34,630
bar here at the end.

20
00:01:35,230 --> 00:01:45,370
And queue main window is the class that allows us to do this division between among the different sections

21
00:01:45,370 --> 00:01:52,660
of an app queue widget, on the other hand, doesn't have that capability, so you want to use queue

22
00:01:52,690 --> 00:01:56,380
main window when you have a larger app.

23
00:01:56,680 --> 00:02:00,700
And larger apps usually also have multiple windows.

24
00:02:00,700 --> 00:02:07,180
So you'll see that later on we'll have we'll have all the classes here, but this will be our main window.

25
00:02:07,180 --> 00:02:14,470
The other classes will inherit from yet another class, the queue dialog class.

26
00:02:14,470 --> 00:02:15,850
But that's for later.

27
00:02:15,850 --> 00:02:19,270
For now, we want to work on queue main window.

28
00:02:20,400 --> 00:02:22,590
The philosophy here is the same.

29
00:02:22,590 --> 00:02:32,820
You want to create an init method first and you want to instantiate the parent in its method as well.

30
00:02:32,910 --> 00:02:36,300
So these two are the very first things you want to do.

31
00:02:36,570 --> 00:02:39,510
And then again, you can set the title.

32
00:02:43,620 --> 00:02:49,920
For your window, such as student management system.

33
00:02:51,560 --> 00:02:56,510
And so then we can add all these routine calls.

34
00:02:57,680 --> 00:02:59,000
Outside the class.

35
00:03:00,790 --> 00:03:01,270
Right.

36
00:03:01,270 --> 00:03:03,400
So that would be main window.

37
00:03:03,850 --> 00:03:06,250
That's the main window class.

38
00:03:06,670 --> 00:03:08,080
So if I run this.

39
00:03:10,020 --> 00:03:10,370
Yeah.

40
00:03:10,380 --> 00:03:14,550
Basically we get this kind of window which can be expanded.

41
00:03:15,810 --> 00:03:22,650
So, so far it looks the same, but we can add a menu bar, a toolbar and a status bar and also the

42
00:03:22,650 --> 00:03:24,260
main central area.

43
00:03:24,270 --> 00:03:25,470
So let's do that.

44
00:03:26,280 --> 00:03:28,710
Let's start from the top.

45
00:03:28,710 --> 00:03:32,370
So let's add a file menu item and a help menu item.

46
00:03:34,410 --> 00:03:41,830
File menu item which should be self dot menu bar.

47
00:03:41,850 --> 00:03:45,450
So self refers to the main window class.

48
00:03:45,450 --> 00:03:50,250
So menu bar comes from queue main window the parent of main window.

49
00:03:51,450 --> 00:03:58,650
So you call that method and then you call that at menu the other method.

50
00:03:58,830 --> 00:04:02,550
And in here you specify what's the first item.

51
00:04:02,550 --> 00:04:03,810
So that's file.

52
00:04:04,320 --> 00:04:09,300
The convention here is that you should add this symbol in front and then file.

53
00:04:09,570 --> 00:04:11,670
Sorry, this is add menu.

54
00:04:12,030 --> 00:04:13,140
Duplicate that.

55
00:04:13,140 --> 00:04:15,780
So that would be the about menu item.

56
00:04:15,780 --> 00:04:18,209
The other sorry, the health menu item.

57
00:04:21,440 --> 00:04:23,120
So file menu item help.

58
00:04:23,120 --> 00:04:24,080
Menu item.

59
00:04:24,410 --> 00:04:26,090
And that would be help.

60
00:04:28,530 --> 00:04:33,870
And before we run the code and see what has happened in the guy, we want to do something else here.

61
00:04:33,870 --> 00:04:38,310
We want to add the sub items of these items.

62
00:04:38,320 --> 00:04:45,660
So for example, in Power Charm, we have the menu items, but but each of these items have their own

63
00:04:45,660 --> 00:04:47,520
sub items, right?

64
00:04:47,640 --> 00:04:53,550
So we want to add at least one sub item for each menu item.

65
00:04:53,700 --> 00:04:55,830
Let's start with the file menu item.

66
00:04:55,830 --> 00:05:05,400
Let's add an add student menu items so the user can go to file add student to add a new student to the

67
00:05:05,400 --> 00:05:05,910
table.

68
00:05:05,910 --> 00:05:14,880
The table is something we're going to create later, so this sub items are actually known as actions.

69
00:05:14,880 --> 00:05:20,070
So let's create an add student action variable, which is equal to Q action.

70
00:05:20,460 --> 00:05:34,770
So queue action is a class which you need to import from p y q26 That's cute gooey import queue action.

71
00:05:35,040 --> 00:05:43,290
So with queue action you can create, for example, an add student action or sub menu item.

72
00:05:44,750 --> 00:05:55,310
And then you refer to file menu item, which we created in here and don't add action.

73
00:05:55,640 --> 00:06:00,440
So that's a method of this menu item, right?

74
00:06:00,590 --> 00:06:08,680
And this method gets as input an action a queue action object instance such as add student action.

75
00:06:08,690 --> 00:06:10,160
This one goes here.

76
00:06:11,150 --> 00:06:15,490
Right now we want to do the same thing with the help menu item.

77
00:06:15,500 --> 00:06:17,990
Let's add a sub item for that.

78
00:06:19,350 --> 00:06:23,720
About action, for example, that's equal to Q action.

79
00:06:25,600 --> 00:06:37,030
Let's call this a boat and then we refer to that variable help menu item dot add action.

80
00:06:38,440 --> 00:06:42,480
And then this variable goes in here, right?

81
00:06:42,490 --> 00:06:52,180
We're just about to run our code, but we also need to add self as the second argument inside queue

82
00:06:52,180 --> 00:06:56,590
action and do the same in here self.

83
00:06:56,590 --> 00:07:01,870
So this will connect this queue action to the actual class.

84
00:07:02,590 --> 00:07:02,950
Right.

85
00:07:02,950 --> 00:07:03,850
Let's run.

86
00:07:08,270 --> 00:07:09,380
So there we go.

87
00:07:09,380 --> 00:07:16,760
Now, depending on the operating system, you may see those menu items either in here or you may see

88
00:07:17,060 --> 00:07:18,200
them on top here.

89
00:07:18,200 --> 00:07:24,530
So file ad Student That's my file menu item and that's my sub item for that item.

90
00:07:24,800 --> 00:07:28,700
Now the other help item is not displayed.

91
00:07:29,780 --> 00:07:36,950
That is because at least on Mac computers, that is not displayed because you need to add something

92
00:07:36,950 --> 00:07:37,790
else here.

93
00:07:38,300 --> 00:07:40,370
So you only need to add this line.

94
00:07:40,370 --> 00:07:43,400
Now if the help item didn't show for you.

95
00:07:43,400 --> 00:07:45,650
Otherwise don't type in this line.

96
00:07:45,650 --> 00:07:49,300
And that line is about action.

97
00:07:49,310 --> 00:07:53,510
That set menu row.

98
00:07:54,760 --> 00:08:00,820
Cue action dot menu row, dot no row.

99
00:08:01,360 --> 00:08:02,980
So if I run this node.

100
00:08:04,650 --> 00:08:08,000
Help is going to show there and about as well.

101
00:08:08,010 --> 00:08:12,710
There's also a search default sub item here.

102
00:08:12,720 --> 00:08:16,950
So that is added by default for help menu items.

103
00:08:17,700 --> 00:08:22,020
But the about page is there, which is something that we added in here.

104
00:08:22,970 --> 00:08:27,380
And that is how to create a main window with a menu bar.

105
00:08:28,070 --> 00:08:31,750
So we completed this step here in the next video.

106
00:08:31,770 --> 00:08:38,690
So we need to add a toolbar, then this table here and then the status bar.

107
00:08:38,720 --> 00:08:39,730
So let's do that.

108
00:08:39,740 --> 00:08:40,789
See you in the next ones.

