0
1
00:00:04,248 --> 00:00:05,610
<v Volkan>In this lecture we are going to create</v>
1

2
00:00:05,610 --> 00:00:07,850
other buttons for our application.
2

3
00:00:07,850 --> 00:00:10,840
And let me run our application first.
3

4
00:00:10,840 --> 00:00:11,910
As you see now here,
4

5
00:00:11,910 --> 00:00:14,420
by the way I did not show you, but for this code
5

6
00:00:14,420 --> 00:00:16,705
you remember not equals zero.
6

7
00:00:16,705 --> 00:00:20,720
Because if I press here plus symbol
7

8
00:00:20,720 --> 00:00:23,430
as you see it doesn't affect because
8

9
00:00:23,430 --> 00:00:28,210
we said if not equals zero then insert operator.
9

10
00:00:28,210 --> 00:00:32,920
Okay, that's why now user cannot start with operator.
10

11
00:00:32,920 --> 00:00:34,590
This is not something normal
11

12
00:00:34,590 --> 00:00:38,840
for a calculator application, by the way, of course.
12

13
00:00:38,840 --> 00:00:41,810
So everything is correct, everything works fine.
13

14
00:00:41,810 --> 00:00:44,450
So what we need to do now, here I will created a button
14

15
00:00:44,450 --> 00:00:46,870
zero button okay it can be larger.
15

16
00:00:46,870 --> 00:00:49,010
It's like it's here
16

17
00:00:49,010 --> 00:00:52,770
will be big zero button okay
17

18
00:00:52,770 --> 00:00:55,410
and after that under zero button,
18

19
00:00:55,410 --> 00:00:59,430
I will create a button equal dot clear button dot button
19

20
00:00:59,430 --> 00:01:00,990
and also equals button.
20

21
00:01:00,990 --> 00:01:02,570
So that's what we need to do.
21

22
00:01:02,570 --> 00:01:04,897
Okay let's get started here
22

23
00:01:04,897 --> 00:01:07,090
I need to come  here let's say
23

24
00:01:08,070 --> 00:01:11,830
here other buttons let's say other buttons
24

25
00:01:14,810 --> 00:01:16,523
and first one is zero, btn_zero.
25

26
00:01:17,780 --> 00:01:19,780
So I will say btn_zero
26

27
00:01:22,130 --> 00:01:24,800
equals button constructor method
27

28
00:01:25,800 --> 00:01:28,823
and here I will say width will be,
28

29
00:01:28,823 --> 00:01:31,490
for this time it will be 19 okay
29

30
00:01:33,135 --> 00:01:34,770
because it will be big one.
30

31
00:01:34,770 --> 00:01:38,613
So and other one is our text property will be.
31

32
00:01:40,210 --> 00:01:43,640
Simply it will be zero right
32

33
00:01:43,640 --> 00:01:46,910
and the for font I will say font is equal to
33

34
00:01:48,950 --> 00:01:52,570
times 16 for size and again bold
34

35
00:01:54,140 --> 00:01:59,140
and let's use here border again five.
35

36
00:01:59,280 --> 00:02:02,020
And then now what I want to do also,
36

37
00:02:02,020 --> 00:02:07,020
I want to use a, here's command, of course for our button.
37

38
00:02:07,790 --> 00:02:09,280
And here I will say again,
38

39
00:02:09,280 --> 00:02:13,250
I will use lambda and I will say command
39

40
00:02:14,660 --> 00:02:19,590
equals lambda x this time equals zero.
40

41
00:02:19,590 --> 00:02:22,380
We know that okay, and we don't need to use
41

42
00:02:22,380 --> 00:02:25,210
something like I because we know it is zero.
42

43
00:02:25,210 --> 00:02:29,590
And here I will say Enter again, number x, okay?
43

44
00:02:29,590 --> 00:02:34,590
And here this time, we know x is already equals zero, okay?
44

45
00:02:35,000 --> 00:02:36,692
And so what I need to do
45

46
00:02:36,692 --> 00:02:40,193
and here I need to use geometry managers, btn_zero.
46

47
00:02:43,044 --> 00:02:45,370
btn_zero that place
47

48
00:02:46,830 --> 00:02:50,860
and here I will say x 25,
48

49
00:02:50,860 --> 00:02:54,987
y is equal 280.
49

50
00:02:58,020 --> 00:03:00,860
Now, if I run my application
50

51
00:03:02,080 --> 00:03:05,780
as you see a number zero its  here
51

52
00:03:05,780 --> 00:03:09,110
and if I press zero as you see now zero is here.
52

53
00:03:09,110 --> 00:03:12,000
Something like that also and here
53

54
00:03:13,610 --> 00:03:16,220
zero buttons also works
54

55
00:03:16,220 --> 00:03:20,197
and so what is next also let's create our Clear button.
55

56
00:03:20,197 --> 00:03:22,920
For clear button I will come  here and say
56

57
00:03:23,944 --> 00:03:28,944
btn_clear equals button constructor method
57

58
00:03:29,900 --> 00:03:33,040
and here everything will be very similar.
58

59
00:03:33,040 --> 00:03:37,573
So let's copy these guys, okay,
59

60
00:03:38,610 --> 00:03:41,100
and paste it here.
60

61
00:03:41,100 --> 00:03:45,740
For the width what I will say I will use four okay,
61

62
00:03:45,740 --> 00:03:50,240
and for text it will be C right
62

63
00:03:50,240 --> 00:03:54,150
and the border same lambda will be here function clear.
63

64
00:03:54,150 --> 00:03:59,150
I will create a new function so I will say funcClear, okay.
64

65
00:03:59,310 --> 00:04:02,340
For my button and here after it what I will say,
65

66
00:04:02,340 --> 00:04:04,843
I will say btn_clear.place.
66

67
00:04:08,940 --> 00:04:13,860
For place I will say x is 25
67

68
00:04:13,860 --> 00:04:17,993
and y is 340.
68

69
00:04:20,290 --> 00:04:22,620
Okay and what is next now,
69

70
00:04:22,620 --> 00:04:26,800
I need to create this function,
70

71
00:04:26,800 --> 00:04:31,800
by the way again here x must be what x cannot be zero,
71

72
00:04:31,950 --> 00:04:35,760
here we need to say here instead of x
72

73
00:04:35,760 --> 00:04:38,343
actually we cannot use x here this also.
73

74
00:04:39,673 --> 00:04:44,170
Remove this one because we will clear everything from my
74

75
00:04:47,040 --> 00:04:47,990
entry box okay.
75

76
00:04:47,990 --> 00:04:49,990
So we don't need to use parameter here,
76

77
00:04:49,990 --> 00:04:54,990
parameter something that comes for our function right?
77

78
00:04:56,350 --> 00:05:00,660
So simply we'll clear everything from our entry box.
78

79
00:05:00,660 --> 00:05:04,360
So that's why we don't need to use here, we use parameter.
79

80
00:05:04,360 --> 00:05:07,970
Even we cannot use here parameter sorry for that again.
80

81
00:05:07,970 --> 00:05:11,787
So it must be like that okay and here what I need to do,
81

82
00:05:11,787 --> 00:05:16,660
I need to copy this name of my function
82

83
00:05:16,660 --> 00:05:18,840
and after it here for the function I will say,
83

84
00:05:18,840 --> 00:05:23,840
def clear funcClear and here what I will say,
84

85
00:05:24,168 --> 00:05:29,168
I need to clear my entry box, right.
85

86
00:05:29,350 --> 00:05:32,090
So to do that what I will do, here I will say
86

87
00:05:32,980 --> 00:05:37,957
simply entry box.delete okay
87

88
00:05:38,920 --> 00:05:43,630
and first is zero and until end.
88

89
00:05:43,630 --> 00:05:45,723
By the way you can use end like that.
89

90
00:05:46,695 --> 00:05:48,495
I want to show you the other one end
90

91
00:05:50,098 --> 00:05:51,840
capital okay, without quotes
91

92
00:05:53,130 --> 00:05:56,730
and again let me actually run it first
92

93
00:05:56,730 --> 00:05:58,600
and I want to show you something.
93

94
00:05:58,600 --> 00:06:02,220
Now if I run it, see if I type something like that.
94

95
00:06:02,220 --> 00:06:06,090
If I press clear button as you see now it's fine it's gone
95

96
00:06:06,090 --> 00:06:08,590
but our default values also it's not here.
96

97
00:06:08,590 --> 00:06:11,500
So what I need to do here and I need to say here
97

98
00:06:11,500 --> 00:06:16,500
entry_box.insert again zero and "O".
98

99
00:06:19,505 --> 00:06:24,230
That one is capital "O" okay and if I run it again now
99

100
00:06:25,780 --> 00:06:30,780
and clear button as you see now our default value is there.
100

101
00:06:31,030 --> 00:06:35,000
Okay, so what is next our next button will be dot.
101

102
00:06:35,000 --> 00:06:39,450
Right btn_zero.place,
102

103
00:06:39,450 --> 00:06:40,970
and after it here I will say
103

104
00:06:42,530 --> 00:06:47,010
btn_dot is equal to
104

105
00:06:48,220 --> 00:06:53,220
here very similar actually and here what I can copy
105

106
00:06:53,560 --> 00:06:58,240
or anyway let's write it will be better.
106

107
00:06:58,240 --> 00:07:02,240
And here I will say, button
107

108
00:07:02,240 --> 00:07:07,240
again width equals four,
108

109
00:07:07,780 --> 00:07:12,240
text will be of course it will be
109

110
00:07:12,240 --> 00:07:16,423
dot only like that right and the for the font,
110

111
00:07:19,420 --> 00:07:24,420
times 15 and bold okay,
111

112
00:07:24,670 --> 00:07:27,780
and borders again five
112

113
00:07:27,780 --> 00:07:32,420
and for command for functions I will say command
113

114
00:07:32,420 --> 00:07:34,563
and again, I will use lambda.
114

115
00:07:34,563 --> 00:07:36,940
Lambda I will say here,
115

116
00:07:36,940 --> 00:07:41,670
this time x I already know it equals my dot,
116

117
00:07:41,670 --> 00:07:44,800
here write dot okay,
117

118
00:07:44,800 --> 00:07:49,113
and now I will use again enterNumber function, okay,
118

119
00:07:51,660 --> 00:07:54,150
and here I will paste x, okay,
119

120
00:07:54,150 --> 00:07:56,630
because x is already dot by the way
120

121
00:07:56,630 --> 00:08:00,600
and if I use place geometry managers
121

122
00:08:00,600 --> 00:08:04,887
btn_dot is here, dot place
122

123
00:08:09,330 --> 00:08:10,700
x equals 110
123

124
00:08:14,260 --> 00:08:17,837
and y equals here 340, okay.
124

125
00:08:22,980 --> 00:08:24,663
If I run my application now,
125

126
00:08:26,360 --> 00:08:31,360
as you see now our button is here, 0.8 and plus 9.5.
126

127
00:08:35,040 --> 00:08:37,240
Perfect, it's working also.
127

128
00:08:37,240 --> 00:08:38,270
What's our next button?
128

129
00:08:38,270 --> 00:08:41,280
Our next button will be equal button, Btn_equal
129

130
00:08:45,900 --> 00:08:48,810
equals here what I will say,
130

131
00:08:48,810 --> 00:08:52,970
so it will be very similar like C, btn_clear.
131

132
00:08:54,110 --> 00:08:59,050
So I will copy this one, okay, and paste it here.
132

133
00:08:59,050 --> 00:09:02,980
I will say here for equal for the text,
133

134
00:09:02,980 --> 00:09:05,333
I will use instead of C I will use,
134

135
00:09:06,960 --> 00:09:11,960
equals okay and command will be for command function,
135

136
00:09:12,230 --> 00:09:14,633
here I will say operator okay.
136

137
00:09:16,139 --> 00:09:18,440
FuncCalculator or you can say something like that.
137

138
00:09:18,440 --> 00:09:20,493
Operator is fine,
138

139
00:09:22,120 --> 00:09:25,510
and here operator and now what I need to do,
139

140
00:09:25,510 --> 00:09:27,750
I need to use place geometry manager,
140

141
00:09:27,750 --> 00:09:31,700
btn_equals is here
141

142
00:09:31,700 --> 00:09:35,250
and after it here I will say place
142

143
00:09:36,360 --> 00:09:39,870
and for the place I will say x is equal to 200
143

144
00:09:39,870 --> 00:09:44,370
and y is equal to 340.
144

145
00:09:44,370 --> 00:09:46,450
But this time I will not create this function.
145

146
00:09:46,450 --> 00:09:51,193
This is long one okay and so here I will only say simply,
146

147
00:09:53,320 --> 00:09:56,870
def my function and here,
147

148
00:09:56,870 --> 00:09:59,990
I will simply say pass for now okay.
148

149
00:09:59,990 --> 00:10:03,542
And here if I run my application,
149

150
00:10:03,542 --> 00:10:05,960
as you see now it's okay it's here.
150

151
00:10:05,960 --> 00:10:09,140
Let's also create delete button okay,
151

152
00:10:09,140 --> 00:10:11,100
and here and also after delete,
152

153
00:10:11,100 --> 00:10:13,840
create our status bar okay
153

154
00:10:13,840 --> 00:10:16,450
but in this lecture we are not going to create our status bar,
154

155
00:10:16,450 --> 00:10:19,230
only we are going to create our delete button,
155

156
00:10:19,230 --> 00:10:21,920
and next lesson we are going to create our status bar
156

157
00:10:21,920 --> 00:10:24,640
also our function and after it we are going to
157

158
00:10:24,640 --> 00:10:27,890
finish this application.
158

159
00:10:27,890 --> 00:10:32,750
Here for delete button by the way I want to use,
159

160
00:10:32,750 --> 00:10:34,373
let's show the original one.
160

161
00:10:36,030 --> 00:10:39,440
You see now here I had an icon here for my bottom right.
161

162
00:10:39,440 --> 00:10:42,106
I will use icon for this button
162

163
00:10:42,106 --> 00:10:46,040
and here I will say icon is equal to
163

164
00:10:46,040 --> 00:10:49,407
photo image library right
164

165
00:10:49,407 --> 00:10:54,407
and file is equal to icons/arrows.png.
165

166
00:11:00,450 --> 00:11:04,260
So it's here, my folder name is icons
166

167
00:11:04,260 --> 00:11:07,680
and my image name is here okay.
167

168
00:11:07,680 --> 00:11:10,367
And after it here, what I will say btn_delete
168

169
00:11:13,860 --> 00:11:16,573
equals button constructor method again.
169

170
00:11:17,820 --> 00:11:22,820
And here let's use actually so similar,
170

171
00:11:23,550 --> 00:11:26,550
so I will say here function operator,
171

172
00:11:26,550 --> 00:11:28,640
so that one is very similar.
172

173
00:11:28,640 --> 00:11:33,460
I will copy this guys, paste it here okay.
173

174
00:11:33,460 --> 00:11:37,800
And the text is, there is no text for this guy
174

175
00:11:37,800 --> 00:11:42,780
because we are going to use icon right,
175

176
00:11:42,780 --> 00:11:46,750
and here function operator not it will be function delete.
176

177
00:11:46,750 --> 00:11:50,820
So I will say here function delete okay
177

178
00:11:50,820 --> 00:11:52,900
and after the last property will be
178

179
00:11:52,900 --> 00:11:56,410
image is equal to icon, okay.
179

180
00:11:56,410 --> 00:11:59,440
And now what I need to do, I need to copy this one
180

181
00:11:59,440 --> 00:12:03,414
and I need to create this function.
181

182
00:12:03,414 --> 00:12:06,497
def function delete and after that here
182

183
00:12:07,856 --> 00:12:10,106
I will say pass, okay fine.
183

184
00:12:11,617 --> 00:12:15,239
So what is next actually all fine,
184

185
00:12:15,239 --> 00:12:18,380
I need to to run my application right to see everything
185

186
00:12:18,380 --> 00:12:22,120
and I didn't use place geometry manager
186

187
00:12:22,120 --> 00:12:25,540
to place my layout, my button.
187

188
00:12:25,540 --> 00:12:27,763
To that I will say btn_delete.place,
188

189
00:12:33,130 --> 00:12:38,130
and x value will be 290 and Y value will be 340, okay.
189

190
00:12:43,660 --> 00:12:45,373
Now if I run it again,
190

191
00:12:46,950 --> 00:12:49,373
its, yep it's here.
191

192
00:12:49,373 --> 00:12:53,100
There's something wrong about my image,
192

193
00:12:53,100 --> 00:12:56,490
I think I used a big image for this one.
193

194
00:12:56,490 --> 00:13:01,330
So what is what I will do, actually I  need to use,
194

195
00:13:01,330 --> 00:13:05,560
I will use another image for this file
195

196
00:13:05,560 --> 00:13:07,450
and paste it here okay.
196

197
00:13:07,450 --> 00:13:09,880
This one is arrows.png.
197

198
00:13:09,880 --> 00:13:12,740
I will provide this file don't worry about it.
198

199
00:13:12,740 --> 00:13:16,895
So here arrows dot run if I run it,
199

200
00:13:16,895 --> 00:13:19,800
something's wrong not that one.
200

201
00:13:19,800 --> 00:13:24,450
So what's wrong here, let me check it.
201

202
00:13:24,450 --> 00:13:28,810
It must be fine so calculator,
202

203
00:13:28,810 --> 00:13:31,383
we used to which one let me check it,
203

204
00:13:32,930 --> 00:13:35,740
icons/arrow.png this okay.
204

205
00:13:35,740 --> 00:13:39,190
So font is fine.
205

206
00:13:41,780 --> 00:13:44,800
Width delete what is in width.
206

207
00:13:44,800 --> 00:13:46,780
So we need to use different width
207

208
00:13:46,780 --> 00:13:48,800
and height property for here
208

209
00:13:48,800 --> 00:13:53,800
because we are using an icon, okay.
209

210
00:13:54,632 --> 00:13:59,632
This file here I will say width is 50, height 35, okay.
210

211
00:13:59,920 --> 00:14:03,850
Because we are using an image as you see now it's perfect.
211

212
00:14:03,850 --> 00:14:08,120
It's here and it's working no, it's not working
212

213
00:14:08,120 --> 00:14:11,100
because we didn't create our function right.
213

214
00:14:11,100 --> 00:14:13,920
So, for the function what I will do,
214

215
00:14:13,920 --> 00:14:15,120
I will come to here and I will say
215

216
00:14:15,120 --> 00:14:19,010
btn_delete, by the way function delete sorry,
216

217
00:14:19,010 --> 00:14:21,940
function name is function delete and here I will say
217

218
00:14:23,040 --> 00:14:28,040
again length equals len of entry_box.get.
218

219
00:14:33,680 --> 00:14:37,690
Okay and by the way we will delete one by one okay,
219

220
00:14:37,690 --> 00:14:38,970
this is important.
220

221
00:14:38,970 --> 00:14:42,977
And after that here I will say entry_box.delete((length)),
221

222
00:14:47,300 --> 00:14:50,200
but this one I will say length minus one.
222

223
00:14:50,200 --> 00:14:51,033
Why is that?
223

224
00:14:51,033 --> 00:14:54,713
Because length value start from one okay,
224

225
00:14:54,713 --> 00:14:57,360
but indices start from zero.
225

226
00:14:57,360 --> 00:15:00,290
That's why we need to say length minus one,
226

227
00:15:00,290 --> 00:15:02,990
okay, and until end I will say.
227

228
00:15:02,990 --> 00:15:05,420
But something else I need to do here
228

229
00:15:05,420 --> 00:15:07,000
and let me run it actually first
229

230
00:15:07,000 --> 00:15:09,080
and after that you can really understand.
230

231
00:15:09,080 --> 00:15:11,940
Here four five, right?
231

232
00:15:11,940 --> 00:15:13,380
Delete, delete, delete.
232

233
00:15:13,380 --> 00:15:18,380
So for something's wrong here, entry index at one,
233

234
00:15:18,520 --> 00:15:20,893
and so what's wrong here?
234

235
00:15:22,210 --> 00:15:24,790
Because entry index is one.
235

236
00:15:24,790 --> 00:15:27,780
That's why I need to solve, to solve this problem,
236

237
00:15:27,780 --> 00:15:29,510
I' need to say if length.
237

238
00:15:29,510 --> 00:15:34,193
So you said you see we got an error equals equals one,
238

239
00:15:34,193 --> 00:15:35,830
okay, this is important.
239

240
00:15:35,830 --> 00:15:39,580
Entry box that insert again zero
240

241
00:15:39,580 --> 00:15:43,145
and our default value capital O, okay.
241

242
00:15:43,145 --> 00:15:46,133
And now if I run my application, again.
242

243
00:15:47,740 --> 00:15:51,550
45 delete, something wrong.
243

244
00:15:51,550 --> 00:15:55,990
So delete first, last okay, so what's wrong here.
244

245
00:15:58,720 --> 00:16:01,200
Let me check it and entry box
245

246
00:16:01,200 --> 00:16:05,030
that length of entry box that get okay.
246

247
00:16:05,030 --> 00:16:09,110
Entry box that delete length minus one.
247

248
00:16:09,110 --> 00:16:12,790
So we have two parentheses here, first of all,
248

249
00:16:12,790 --> 00:16:16,510
So I need  to remove this one, okay,
249

250
00:16:16,510 --> 00:16:20,290
and if after that I need to run this one again.
250

251
00:16:20,290 --> 00:16:23,600
78 you see now it's working, okay,
251

252
00:16:23,600 --> 00:16:27,000
so I want to remove this guy okay first of all,
252

253
00:16:27,000 --> 00:16:28,740
and after that I will paste again.
253

254
00:16:28,740 --> 00:16:33,740
Now, if I try to delete something.
254

255
00:16:34,130 --> 00:16:36,790
Look, we have three numbers here right.
255

256
00:16:36,790 --> 00:16:38,080
The first one is 9,
256

257
00:16:38,080 --> 00:16:41,125
by the way we are deleting from the last one okay,
257

258
00:16:41,125 --> 00:16:45,880
2 that's why we are using here length minus one, okay.
258

259
00:16:45,880 --> 00:16:49,400
This is index of which number we want to delete.
259

260
00:16:49,400 --> 00:16:51,870
Okay, so the last one is here
260

261
00:16:51,870 --> 00:16:54,000
and I will press delete button again.
261

262
00:16:54,000 --> 00:16:56,440
As you see now our default value is not here.
262

263
00:16:56,440 --> 00:16:59,520
That's why we need to say here if
263

264
00:17:01,590 --> 00:17:04,730
length equals equals one, okay,
264

265
00:17:04,730 --> 00:17:07,340
that after deleting it entry works
265

266
00:17:07,340 --> 00:17:11,060
at insert our default value, okay
266

267
00:17:11,060 --> 00:17:12,850
and that's all for now.
267

268
00:17:12,850 --> 00:17:16,910
In the next lesson we are going to finish our application.
268

269
00:17:16,910 --> 00:17:18,810
For now that's all see you in the next.
