0
1
00:00:04,580 --> 00:00:06,660
<v Volkan>Hello again, in previous lecture what we did</v>
1

2
00:00:06,660 --> 00:00:09,167
we created our main application class, right?
2

3
00:00:09,167 --> 00:00:12,342
And in this lecture, we are going to create our menu class,
3

4
00:00:12,342 --> 00:00:16,057
and also one menu item and we'll create a file menu item.
4

5
00:00:16,057 --> 00:00:18,840
To do that What we need to do here as I said remember,
5

6
00:00:18,840 --> 00:00:22,790
for each item we are going to create a new class, okay?
6

7
00:00:22,790 --> 00:00:24,880
So, that means we are going to create
7

8
00:00:24,880 --> 00:00:27,420
a new class for also our menu.
8

9
00:00:27,420 --> 00:00:30,410
Here I will say I will say class and here
9

10
00:00:30,410 --> 00:00:33,010
for name I will say MainMenu, okay?
10

11
00:00:33,010 --> 00:00:35,893
And now, something else I need to tell you here,
11

12
00:00:36,750 --> 00:00:41,750
I will inherit my main menu from menu, okay?
12

13
00:00:42,090 --> 00:00:42,990
From menu object.
13

14
00:00:42,990 --> 00:00:47,030
Here remember, inherit our MainApplication from Frame,
14

15
00:00:47,030 --> 00:00:50,680
and for the menu inherited from Menu, okay?
15

16
00:00:50,680 --> 00:00:53,010
What I need to do here, I need to say,
16

17
00:00:53,010 --> 00:00:55,910
even we can copy these guys, okay?
17

18
00:00:55,910 --> 00:00:58,673
Let's copy these guys and paste them here.
18

19
00:00:59,950 --> 00:01:01,680
And only what I need to change here,
19

20
00:01:01,680 --> 00:01:04,480
I need to change here Menu, alright?
20

21
00:01:04,480 --> 00:01:06,903
And all other things there are similar.
21

22
00:01:07,750 --> 00:01:09,100
Yes, it's okay now.
22

23
00:01:09,100 --> 00:01:11,773
And now, what I need to do, I created my menu,
23

24
00:01:13,701 --> 00:01:14,840
I need to come here
24

25
00:01:14,840 --> 00:01:18,650
and call this menu,
25

26
00:01:18,650 --> 00:01:19,530
so how can I do that?
26

27
00:01:19,530 --> 00:01:24,530
Here I will say let's comment out and say #Creating widget
27

28
00:01:24,760 --> 00:01:28,907
For menu widget I will say self.main_menu=MainMenu
28

29
00:01:37,070 --> 00:01:37,903
Okay?
29

30
00:01:37,903 --> 00:01:39,920
This is my instance, right?
30

31
00:01:39,920 --> 00:01:42,227
This is my class name, and here what I need to say,
31

32
00:01:42,227 --> 00:01:45,720
I need to pass in self parameter, okay?
32

33
00:01:45,720 --> 00:01:48,130
And also I need to configure my menu.
33

34
00:01:48,130 --> 00:01:49,080
So how can I do that?
34

35
00:01:49,080 --> 00:01:51,510
Here, also let's create another comment line here
35

36
00:01:51,510 --> 00:01:54,653
and I will say #Parent_menu_configuration.
36

37
00:01:59,290 --> 00:02:00,437
And here I need to configure my menu.
37

38
00:02:00,437 --> 00:02:03,920
To do that I will say self.parent.
38

39
00:02:03,920 --> 00:02:07,920
Parent means my main application, main class, okay?
39

40
00:02:07,920 --> 00:02:08,753
Config
40

41
00:02:10,540 --> 00:02:11,708
and here I will say 
41

42
00:02:11,708 --> 00:02:16,708
self.parent.config(menu=self.main_menu) okay?
42

43
00:02:17,920 --> 00:02:21,540
And after what I need to do here, I will create my menu
43

44
00:02:21,540 --> 00:02:26,080
right here, first of all let's create here another
44

45
00:02:26,080 --> 00:02:28,373
comment line and I will say file_menu
45

46
00:02:30,350 --> 00:02:32,850
In this lesson we are going to create only file menu
46

47
00:02:33,890 --> 00:02:35,313
and after that here,
47

48
00:02:36,580 --> 00:02:39,210
this also can be used as
48

49
00:02:39,210 --> 00:02:40,930
a separator right?
49

50
00:02:40,930 --> 00:02:44,090
And here what I need to do first of all
50

51
00:02:44,090 --> 00:02:44,923
I will say
51

52
00:02:44,923 --> 00:02:46,293
self.file=Menu,
52

53
00:02:52,550 --> 00:02:53,850
right?
53

54
00:02:53,850 --> 00:02:54,920
And here I need to use
54

55
00:02:54,920 --> 00:02:59,117
self parameter and the second one will be 'tearoff',
55

56
00:02:59,117 --> 00:03:02,200
and tearoff will be 0, okay?
56

57
00:03:02,200 --> 00:03:05,830
And now lets create submenus for our file menu.
57

58
00:03:05,830 --> 00:03:07,120
To do that I will say
58

59
00:03:07,120 --> 00:03:09,890
self.file.addcommand
59

60
00:03:12,430 --> 00:03:16,350
and here the first parameter will be 'label' right?
60

61
00:03:16,350 --> 00:03:19,540
The label will be my text for my menu, submenu
61

62
00:03:19,540 --> 00:03:24,540
and it will be 'new', and here we can also use here
62

63
00:03:24,856 --> 00:03:28,843
images, okay, and lets also use it, for the image what I
63

64
00:03:28,843 --> 00:03:32,090
need to use icon for my menu item,
64

65
00:03:32,090 --> 00:03:33,270
here I will say
65

66
00:03:34,150 --> 00:03:35,070
self.new_icon
66

67
00:03:41,100 --> 00:03:43,700
is equal to Photo Image library, right?
67

68
00:03:43,700 --> 00:03:46,790
And here I will say file, for the file I'll say
68

69
00:03:48,010 --> 00:03:52,753
file=icons/new.png
69

70
00:03:55,490 --> 00:04:00,490
Its here, we are going to use this image, this .png file,
70

71
00:04:01,040 --> 00:04:03,960
and now what I need to use here, here I need to use
71

72
00:04:03,960 --> 00:04:06,270
image property for my icon,
72

73
00:04:06,270 --> 00:04:09,343
image=self.new_icon,
73

74
00:04:15,050 --> 00:04:16,280
and also compound
74

75
00:04:17,740 --> 00:04:20,310
compound=LEFT
75

76
00:04:21,439 --> 00:04:23,370
If I run my application actually
76

77
00:04:23,370 --> 00:04:25,980
I cannot see it, why is like that?
77

78
00:04:25,980 --> 00:04:29,750
Because also I need to use another function here,
78

79
00:04:29,750 --> 00:04:30,583
I need to say
79

80
00:04:30,583 --> 00:04:33,700
self.add_cascade, okay?
80

81
00:04:33,700 --> 00:04:36,040
And here I will say label
81

82
00:04:39,360 --> 00:04:42,260
label equals file, right?
82

83
00:04:42,260 --> 00:04:45,180
Sorry this we need to use quotes,
83

84
00:04:45,180 --> 00:04:48,799
'file' and after that here what I need to say,
84

85
00:04:48,799 --> 00:04:53,799
menu=self.file
85

86
00:04:54,150 --> 00:04:55,750
Okay now if we run my application
86

87
00:04:55,750 --> 00:04:59,003
I can see this menu item run.
87

88
00:05:03,050 --> 00:05:06,190
As you see now our file menu is here and you can click it
88

89
00:05:06,190 --> 00:05:08,410
you see new is also here.
89

90
00:05:08,410 --> 00:05:10,930
So we have also our icon here
90

91
00:05:10,930 --> 00:05:15,930
but we can also create a shortcut for our menu item right?
91

92
00:05:15,970 --> 00:05:19,310
To create a shortcut what we can use, we can say here
92

93
00:05:21,010 --> 00:05:23,173
we can use accelerator function,
93

94
00:05:24,344 --> 00:05:25,528
And here what I
94

95
00:05:25,528 --> 00:05:27,680
will say come here and say
95

96
00:05:30,960 --> 00:05:31,793
I will say
96

97
00:05:33,740 --> 00:05:34,573
accelerator
97

98
00:05:42,840 --> 00:05:43,740
equals
98

99
00:05:44,640 --> 00:05:47,740
For new what I need to say, I need to say
99

100
00:05:47,740 --> 00:05:50,490
Ctrl, here I need to use quotes.
100

101
00:05:50,490 --> 00:05:51,393
Control,
101

102
00:05:52,960 --> 00:05:55,547
sorry, "Ctrl+N"
102

103
00:05:57,914 --> 00:05:58,747
okay?
103

104
00:05:58,747 --> 00:06:00,547
And if I run it again, let's see it.
104

105
00:06:02,100 --> 00:06:06,250
Now file, as you see Ctrl + N for the new file, okay?
105

106
00:06:06,250 --> 00:06:10,060
And also lets create other menus, submenus for our
106

107
00:06:10,060 --> 00:06:13,893
file menu item, and the second one will be open,
107

108
00:06:16,300 --> 00:06:17,240
here I will say
108

109
00:06:17,240 --> 00:06:18,073
self.
109

110
00:06:20,320 --> 00:06:21,153
open
110

111
00:06:27,040 --> 00:06:29,237
sorry its here what I need to say,
111

112
00:06:29,237 --> 00:06:33,487
self.file.add_command
112

113
00:06:34,380 --> 00:06:35,213
right?
113

114
00:06:35,213 --> 00:06:36,143
And first thing again
114

115
00:06:36,143 --> 00:06:41,143
will be label, label=open, right?
115

116
00:06:41,300 --> 00:06:43,150
And after here
116

117
00:06:43,150 --> 00:06:46,333
what I need to use,  let's use also a shortcut,
117

118
00:06:47,186 --> 00:06:48,353
accelerator...
118

119
00:06:52,248 --> 00:06:53,831
Accelerator equals,
119

120
00:06:57,572 --> 00:07:02,322
Here I will say Ctrl+O, okay?
120

121
00:07:03,544 --> 00:07:07,180
And also lets use an icon for this guy, for icon what
121

122
00:07:07,180 --> 00:07:11,650
I can say, before creating icon we need here, to create a
122

123
00:07:11,650 --> 00:07:13,230
icon for our menu right?
123

124
00:07:13,230 --> 00:07:14,363
Self.open_icon, okay,
124

125
00:07:17,581 --> 00:07:18,914
=PhotoImage
125

126
00:07:20,875 --> 00:07:25,875
and file property equals here for the open I will say
126

127
00:07:26,420 --> 00:07:28,437
icons/open.png
127

128
00:07:35,030 --> 00:07:39,563
its here that one, we are going to use this one okay?
128

129
00:07:40,420 --> 00:07:44,110
And what I need to do now I need to use image property
129

130
00:07:44,110 --> 00:07:46,430
image=self.open_icon,
130

131
00:07:51,910 --> 00:07:52,743
Right?
131

132
00:07:53,820 --> 00:07:56,263
Also, I need to use compound=LEFT
132

133
00:08:01,155 --> 00:08:04,923
Now the second one is also ready let's run our application.
133

134
00:08:06,330 --> 00:08:09,210
Here file as you see, new and open is ready.
134

135
00:08:09,210 --> 00:08:10,440
So what is the next one?
135

136
00:08:10,440 --> 00:08:13,770
The next one will be our save.
136

137
00:08:13,770 --> 00:08:14,603
Okay.
137

138
00:08:14,603 --> 00:08:17,300
For the save what I can say,
138

139
00:08:17,300 --> 00:08:20,860
here we can press
139

140
00:08:20,860 --> 00:08:22,040
Ctrl+D, here okay
140

141
00:08:23,418 --> 00:08:25,747
and here we can change our properties for the open I will
141

142
00:08:25,747 --> 00:08:30,490
say save, and for the save shortcut, it will be Ctrl+S.
142

143
00:08:30,490 --> 00:08:31,323
Right?
143

144
00:08:32,170 --> 00:08:36,010
And image will be here, let's create also Ctrl+D,
144

145
00:08:36,010 --> 00:08:40,218
we can press here Ctrl+D also, and here I will say
145

146
00:08:40,218 --> 00:08:41,635
save_icon, right?
146

147
00:08:42,872 --> 00:08:47,070
Save_icon, and for the save, what I will use
147

148
00:08:47,070 --> 00:08:51,139
save icon, its that one okay,
148

149
00:08:51,139 --> 00:08:55,920
'save_icon.png'
149

150
00:08:55,920 --> 00:09:00,543
And here what I need to use save icon will be the same with this one
150

151
00:09:00,543 --> 00:09:02,310
save_icon, okay?
151

152
00:09:02,310 --> 00:09:05,120
And compound will be LEFT again.
152

153
00:09:05,120 --> 00:09:06,923
And if I run my application now,
153

154
00:09:09,180 --> 00:09:11,080
as you see now, save is also here.
154

155
00:09:11,080 --> 00:09:15,230
What is next also we have two more menu items,
155

156
00:09:15,230 --> 00:09:17,900
the other one will be save as, okay?
156

157
00:09:17,900 --> 00:09:21,673
For the save as, we don't need to create an icon,
157

158
00:09:21,673 --> 00:09:25,744
so here we press Ctrl+D again, and that guy
158

159
00:09:25,744 --> 00:09:28,207
will be 'save as', okay?
159

160
00:09:29,677 --> 00:09:31,185
The other one is by the way,
160

161
00:09:31,185 --> 00:09:34,213
this one will be Ctrl+S, right?
161

162
00:09:34,213 --> 00:09:37,520
For the save as, I can say here
162

163
00:09:37,520 --> 00:09:42,120
Ctrl+Alt+S,
163

164
00:09:42,120 --> 00:09:44,083
for the save as, and here,
164

165
00:09:45,000 --> 00:09:48,050
we are not going to use image property, okay?
165

166
00:09:48,050 --> 00:09:50,160
And let's delete this guy.
166

167
00:09:50,160 --> 00:09:51,420
And for the last one,
167

168
00:09:51,420 --> 00:09:53,782
the last one will be exit menu, okay?
168

169
00:09:53,782 --> 00:09:55,730
Exit submenu.
169

170
00:09:55,730 --> 00:09:59,490
For exit, let's copy this guy, this time, okay?
170

171
00:09:59,490 --> 00:10:03,880
And paste it here, and that one is going to be exit
171

172
00:10:05,010 --> 00:10:08,523
and the other one I will not going to use here,
172

173
00:10:09,460 --> 00:10:12,860
shortcut, okay, for exit, so I will remove this guy.
173

174
00:10:12,860 --> 00:10:15,000
And for the image let's say here
174

175
00:10:17,830 --> 00:10:21,590
Ctrl+D again, and here I will say, exit_icon
175

176
00:10:24,480 --> 00:10:26,813
Here it will be, exit.png
176

177
00:10:27,705 --> 00:10:31,023
Okay it is that one they are going to see this .png file
177

178
00:10:32,530 --> 00:10:35,453
Here I will say, exit.png
178

179
00:10:37,580 --> 00:10:40,116
And for the image, I will say
179

180
00:10:40,116 --> 00:10:40,949
exit_icon
180

181
00:10:43,430 --> 00:10:45,630
and compound will be LEFT,
181

182
00:10:45,630 --> 00:10:50,391
and we are not going to use a shortcut right?
182

183
00:10:50,391 --> 00:10:51,543
I think this is ready.
183

184
00:10:51,543 --> 00:10:55,143
If I run my application We will see all our menu items.
184

185
00:10:59,948 --> 00:11:03,260
Let me run it again, something is wrong, here or...
185

186
00:11:03,260 --> 00:11:06,923
Yes something is wrong here, so we need to say here
186

187
00:11:06,923 --> 00:11:08,540
exit_icon, right?
187

188
00:11:08,540 --> 00:11:10,193
And if I run it again now,
188

189
00:11:12,700 --> 00:11:16,940
here file, and as you see new, open, save and save as here
189

190
00:11:16,940 --> 00:11:19,480
and also exit is also here, we didn't create
190

191
00:11:19,480 --> 00:11:22,400
a shortcut for exit, and for now that's all.
191

192
00:11:22,400 --> 00:11:24,150
In the next lesson we are going to create other
192

193
00:11:24,150 --> 00:11:26,910
file menu items.
193

194
00:11:26,910 --> 00:11:28,423
See you in the next.
