0
1
00:00:04,340 --> 00:00:05,340
<v Speaker>After learning tkinter</v>
1

2
00:00:05,340 --> 00:00:06,810
widgets now we are ready to create
2

3
00:00:06,810 --> 00:00:08,200
our GUI applications.
3

4
00:00:08,200 --> 00:00:09,350
And in this lecture we are going
4

5
00:00:09,350 --> 00:00:11,000
to create a calculator app.
5

6
00:00:11,000 --> 00:00:12,107
What is our application?
6

7
00:00:12,107 --> 00:00:14,930
Let me show it, as you see now
7

8
00:00:14,930 --> 00:00:17,060
this is a classic calculator app.
8

9
00:00:17,060 --> 00:00:18,650
But actually its not very classic.
9

10
00:00:18,650 --> 00:00:22,534
What I mean, because here we have more features.
10

11
00:00:22,534 --> 00:00:25,100
For example we will use here a status bar,
11

12
00:00:25,100 --> 00:00:27,240
and will show our operations here.
12

13
00:00:27,240 --> 00:00:29,100
Our history here, okay?
13

14
00:00:29,100 --> 00:00:31,530
And after here, what is next?
14

15
00:00:31,530 --> 00:00:32,860
Also we have a delete button,
15

16
00:00:32,860 --> 00:00:35,070
clear button for our application
16

17
00:00:35,070 --> 00:00:37,750
and also we can, this is the most important part
17

18
00:00:37,750 --> 00:00:40,090
we can make multiple operations
18

19
00:00:40,090 --> 00:00:40,970
with this application.
19

20
00:00:40,970 --> 00:00:42,200
What I mean, for example
20

21
00:00:42,200 --> 00:00:44,870
here I can say seven plus
21

22
00:00:44,870 --> 00:00:45,720
three
22

23
00:00:45,720 --> 00:00:47,600
times six
23

24
00:00:47,600 --> 00:00:49,010
divided by nine
24

25
00:00:49,010 --> 00:00:50,439
minus six
25

26
00:00:50,439 --> 00:00:52,100
and after that,
26

27
00:00:52,100 --> 00:00:52,933
equals.
27

28
00:00:52,933 --> 00:00:53,973
As you see now it says,
28

29
00:00:57,449 --> 00:00:58,600
our output is three point zero.
29

30
00:00:58,600 --> 00:00:59,890
Its a float number by the way.
30

31
00:00:59,890 --> 00:01:01,750
And our history is here,
31

32
00:01:01,750 --> 00:01:03,610
let me make another one.
32

33
00:01:03,610 --> 00:01:06,360
Also let me show you delete button.
33

34
00:01:06,360 --> 00:01:08,663
This is delete button and as you see now,
34

35
00:01:08,663 --> 00:01:11,750
I delete my characters, also of course
35

36
00:01:11,750 --> 00:01:15,810
I can erase all of them, to press clear button
36

37
00:01:15,810 --> 00:01:18,440
and let me make another operations here.
37

38
00:01:18,440 --> 00:01:20,570
45 times
38

39
00:01:20,570 --> 00:01:22,390
three minus six
39

40
00:01:22,390 --> 00:01:25,240
okay that means 135,
40

41
00:01:25,240 --> 00:01:26,073
129
41

42
00:01:27,011 --> 00:01:29,780
and it should be 129
42

43
00:01:29,780 --> 00:01:32,880
if I press equals, as you see now
43

44
00:01:32,880 --> 00:01:36,230
129 is here and also we show it here.
44

45
00:01:36,230 --> 00:01:38,760
At our status bar,
45

46
00:01:38,760 --> 00:01:41,690
by the way our last operation is that one.
46

47
00:01:41,690 --> 00:01:43,010
This is our first operation,
47

48
00:01:43,010 --> 00:01:45,670
that means we are displaying our operations
48

49
00:01:45,670 --> 00:01:48,450
from last to first, okay?
49

50
00:01:48,450 --> 00:01:51,070
And other one I also want to show you what we can do,
50

51
00:01:51,070 --> 00:01:53,570
also we can find power of numbers
51

52
00:01:53,570 --> 00:01:55,150
to use our application.
52

53
00:01:55,150 --> 00:01:57,023
For example, four,
53

54
00:01:58,590 --> 00:01:59,490
what we need to do
54

55
00:02:00,459 --> 00:02:03,570
is press multiplication button two times okay?
55

56
00:02:03,570 --> 00:02:06,550
And the power of two,
56

57
00:02:06,550 --> 00:02:07,383
for four
57

58
00:02:07,383 --> 00:02:08,550
as you see now is 16.
58

59
00:02:08,550 --> 00:02:12,370
Of course we can find any power of numbers.
59

60
00:02:12,370 --> 00:02:17,370
For example for six, lets find the power of three.
60

61
00:02:17,490 --> 00:02:20,143
As you see now it says 216.
61

62
00:02:21,182 --> 00:02:23,880
Or lets try for something else,
62

63
00:02:23,880 --> 00:02:28,180
for example this one and power of five.
63

64
00:02:28,180 --> 00:02:30,310
As you see now, its a huge number.
64

65
00:02:30,310 --> 00:02:33,050
Anyway, so it's really a very useful application.
65

66
00:02:33,050 --> 00:02:35,920
And we will learn a lot with this application.
66

67
00:02:35,920 --> 00:02:37,930
And also we will use here an icon
67

68
00:02:37,930 --> 00:02:41,190
for our button, but it's here it's our folder
68

69
00:02:41,190 --> 00:02:43,790
I already created, Icons, the folder name
69

70
00:02:43,790 --> 00:02:47,040
and also our PNG file is here.
70

71
00:02:47,040 --> 00:02:49,570
Lets get started, what we need to do
71

72
00:02:49,570 --> 00:02:53,010
here firstly I will create another Python file.
72

73
00:02:53,010 --> 00:02:55,743
And I'll say, here, New,
73

74
00:02:57,982 --> 00:02:58,815
Python file.
74

75
00:02:58,815 --> 00:03:02,450
And here I'll say, Calculator for Python file.
75

76
00:03:02,450 --> 00:03:03,283
Okay?
76

77
00:03:03,283 --> 00:03:04,790
And here what I need to do first of all,
77

78
00:03:04,790 --> 00:03:08,920
I need to say, from tkinter import asterisk
78

79
00:03:10,100 --> 00:03:14,060
that means from tkinter import everything.
79

80
00:03:14,060 --> 00:03:17,110
And after that here, of course root is
80

81
00:03:18,240 --> 00:03:20,030
equals Tk
81

82
00:03:20,030 --> 00:03:22,010
and here lets create
82

83
00:03:22,010 --> 00:03:24,203
a title for our application.
83

84
00:03:26,953 --> 00:03:29,160
Root.title
84

85
00:03:29,160 --> 00:03:31,550
and lets say
85

86
00:03:31,550 --> 00:03:34,270
Calculator App,
86

87
00:03:34,270 --> 00:03:38,590
enough and after that we need to define geometry
87

88
00:03:38,590 --> 00:03:39,540
for our application.
88

89
00:03:39,540 --> 00:03:40,970
For geometry I will say
89

90
00:03:42,340 --> 00:03:43,400
380x
90

91
00:03:44,910 --> 00:03:46,020
550.
91

92
00:03:46,020 --> 00:03:48,243
Okay and also location of our window.
92

93
00:03:49,553 --> 00:03:53,020
For 850 plus 200 okay?
93

94
00:03:53,020 --> 00:03:53,853
And after that what I need to do,
94

95
00:03:53,853 --> 00:03:58,460
I need to say here root.mainloop right?
95

96
00:03:58,460 --> 00:04:00,240
And now if I run my application.
96

97
00:04:00,240 --> 00:04:03,050
My window is ready, as you see now
97

98
00:04:03,050 --> 00:04:04,750
our window is here, but of course
98

99
00:04:04,750 --> 00:04:06,080
its totally empty.
99

100
00:04:06,080 --> 00:04:08,060
So what we need to to first of all,
100

101
00:04:08,060 --> 00:04:10,110
we will create our buttons.
101

102
00:04:10,110 --> 00:04:12,003
And how we can create our buttons,
102

103
00:04:13,033 --> 00:04:15,720
actually before buttons we need to create our entry right?
103

104
00:04:15,720 --> 00:04:18,510
Lets create our entry here, entry box
104

105
00:04:19,376 --> 00:04:22,610
and I will come here and say here comment line
105

106
00:04:23,600 --> 00:04:26,613
and let's say Entry Box.
106

107
00:04:28,180 --> 00:04:30,410
And after that here I say
107

108
00:04:31,810 --> 00:04:32,930
entry box
108

109
00:04:35,980 --> 00:04:37,230
is equal to
109

110
00:04:38,490 --> 00:04:41,487
what I need use, first of all by the way
110

111
00:04:41,487 --> 00:04:43,957
I will only use tkinter widgets okay?
111

112
00:04:43,957 --> 00:04:46,470
That's why I didn't import ttk.
112

113
00:04:46,470 --> 00:04:48,640
And here we will say Entry and after
113

114
00:04:48,640 --> 00:04:50,930
our first property will be font
114

115
00:04:50,930 --> 00:04:53,478
and something else I want to tell you.
115

116
00:04:53,478 --> 00:04:56,760
Now here I can say root for master
116

117
00:04:56,760 --> 00:04:58,829
but I will not use root because
117

118
00:04:58,829 --> 00:05:01,665
we will not use another frame
118

119
00:05:01,665 --> 00:05:03,712
and we will have only this main window.
119

120
00:05:03,712 --> 00:05:04,970
That's why I don't use root here.
120

121
00:05:04,970 --> 00:05:09,410
And I say here font is equal to my first property.
121

122
00:05:09,410 --> 00:05:12,770
And Verdana for font family name.
122

123
00:05:12,770 --> 00:05:15,750
14 and it will be bold okay?
123

124
00:05:15,750 --> 00:05:18,500
And for the width, I'll say width
124

125
00:05:18,500 --> 00:05:20,180
is equal to 22
125

126
00:05:21,500 --> 00:05:24,660
and other one is, lets use border.
126

127
00:05:24,660 --> 00:05:26,840
For border I will say 10.
127

128
00:05:26,840 --> 00:05:28,260
Now what I need to do,
128

129
00:05:28,260 --> 00:05:30,720
I need to use a geometry manager right?
129

130
00:05:30,720 --> 00:05:33,760
I will use place geometry for my entry box.
130

131
00:05:33,760 --> 00:05:36,840
And here I will say entry box.place
131

132
00:05:38,760 --> 00:05:42,580
for place I will say x is 20
132

133
00:05:42,580 --> 00:05:45,550
and for y i'll say 10.
133

134
00:05:45,550 --> 00:05:47,810
Now, our entry box is ready.
134

135
00:05:47,810 --> 00:05:49,660
Lets run it, our application.
135

136
00:05:49,660 --> 00:05:51,610
As you see now our entry box is here,
136

137
00:05:51,610 --> 00:05:54,300
and the border looks nice right?
137

138
00:05:54,300 --> 00:05:56,980
But let me type it,
138

139
00:05:56,980 --> 00:05:57,813
you see?
139

140
00:05:57,813 --> 00:05:59,220
Also we can type it here.
140

141
00:05:59,220 --> 00:06:02,640
But the problem is here, we need to justify here
141

142
00:06:02,640 --> 00:06:05,160
because calculator apps as you know
142

143
00:06:05,160 --> 00:06:06,770
it starts from right to left
143

144
00:06:06,770 --> 00:06:08,920
and you can write from right to left.
144

145
00:06:08,920 --> 00:06:10,640
But this one is from left to right
145

146
00:06:10,640 --> 00:06:13,970
so here what I will say, I will say here...
146

147
00:06:13,970 --> 00:06:14,830
justify
147

148
00:06:16,780 --> 00:06:18,020
is equal to
148

149
00:06:19,550 --> 00:06:20,710
right, okay?
149

150
00:06:20,710 --> 00:06:24,770
And also lets use background for our entry.
150

151
00:06:24,770 --> 00:06:26,553
For background I will say here,
151

152
00:06:27,955 --> 00:06:30,150
I will use something like blue.
152

153
00:06:30,150 --> 00:06:31,660
E six
153

154
00:06:31,660 --> 00:06:32,800
e six
154

155
00:06:32,800 --> 00:06:34,620
f a okay?
155

156
00:06:34,620 --> 00:06:38,440
And after that here if I run my application.
156

157
00:06:38,440 --> 00:06:40,370
First lets run it, as you see now
157

158
00:06:40,370 --> 00:06:44,390
it's better and it justifies from right to left
158

159
00:06:44,390 --> 00:06:45,453
it's also fine.
159

160
00:06:46,850 --> 00:06:49,620
What is next, let me delete this one.
160

161
00:06:49,620 --> 00:06:53,507
Now I want to also use a default value
161

162
00:06:53,507 --> 00:06:57,950
here for my entry box, like something like that okay?
162

163
00:06:57,950 --> 00:06:58,860
So how can I do that?
163

164
00:06:58,860 --> 00:07:01,110
To do that, here I need to say
164

165
00:07:02,578 --> 00:07:05,830
entry box.insert
165

166
00:07:05,830 --> 00:07:07,380
and for the index
166

167
00:07:07,380 --> 00:07:08,760
I need to say zero
167

168
00:07:08,760 --> 00:07:10,140
and my
168

169
00:07:11,360 --> 00:07:14,350
text string will be O.
169

170
00:07:14,350 --> 00:07:16,350
I will not use zero here, why is like that?
170

171
00:07:16,350 --> 00:07:19,310
Because if I want to make, like from here
171

172
00:07:23,280 --> 00:07:25,480
if I want to use zero point five,
172

173
00:07:25,480 --> 00:07:27,790
zero point nine or these kind of numbers.
173

174
00:07:27,790 --> 00:07:32,290
I cannot use zero, so the default value will be O.
174

175
00:07:32,290 --> 00:07:34,304
It looks like a zero by the way,
175

176
00:07:34,304 --> 00:07:35,766
capital O, okay?
176

177
00:07:35,766 --> 00:07:39,247
If I run my application now, you see now its here
177

178
00:07:39,247 --> 00:07:41,414
and it looks like a zero.
178

179
00:07:41,414 --> 00:07:44,283
And what is next, now we need to create our buttons.
179

180
00:07:44,283 --> 00:07:47,550
Right here, by the way I want to tell you something.
180

181
00:07:47,550 --> 00:07:50,550
Now of course we can create our buttons manually,
181

182
00:07:50,550 --> 00:07:53,330
like we can create a button and after that copy
182

183
00:07:53,330 --> 00:07:55,010
its code and create the others.
183

184
00:07:55,010 --> 00:07:56,760
But it's not a good way.
184

185
00:07:56,760 --> 00:07:58,260
We need to use a Pythonic way.
185

186
00:07:58,260 --> 00:07:59,760
Okay to create our buttons.
186

187
00:07:59,760 --> 00:08:01,513
So what I will do,
187

188
00:08:03,432 --> 00:08:05,750
here let me say here.
188

189
00:08:05,750 --> 00:08:07,719
Number Buttons
189

190
00:08:07,719 --> 00:08:08,930
(typing)
190

191
00:08:08,930 --> 00:08:11,920
okay, this is our comment line.
191

192
00:08:11,920 --> 00:08:13,603
And after that here I will say,
192

193
00:08:15,500 --> 00:08:19,000
I can use more by the way here, okay.
193

194
00:08:19,000 --> 00:08:23,750
So for number buttons what I will say I will use here
194

195
00:08:23,750 --> 00:08:25,760
a list, okay an empty list.
195

196
00:08:25,760 --> 00:08:28,030
btn numbers
196

197
00:08:28,030 --> 00:08:30,960
and this is an empty list.
197

198
00:08:30,960 --> 00:08:32,470
And after that here I will use for loop
198

199
00:08:32,470 --> 00:08:33,400
to create my buttons.
199

200
00:08:33,400 --> 00:08:35,520
I will say for i in
200

201
00:08:35,520 --> 00:08:38,040
range 10 okay?
201

202
00:08:38,040 --> 00:08:41,690
From zero to nine that means, okay?
202

203
00:08:41,690 --> 00:08:46,060
And after that here I will say btn numbers dot append
203

204
00:08:47,190 --> 00:08:49,400
and here I need to create button right?
204

205
00:08:49,400 --> 00:08:52,790
Button constructor method and after that here
205

206
00:08:52,790 --> 00:08:55,700
my properties the first one will be width
206

207
00:08:55,700 --> 00:08:57,240
is equal to four
207

208
00:09:00,910 --> 00:09:02,110
and text must be string.
208

209
00:09:03,915 --> 00:09:06,510
But this i value is already integer.
209

210
00:09:06,510 --> 00:09:09,850
So, what I need to do I need to say str i.
210

211
00:09:09,850 --> 00:09:13,100
This is important, if you don't say str
211

212
00:09:13,100 --> 00:09:15,010
you will get an error and after that here
212

213
00:09:15,010 --> 00:09:19,370
also lets use font, font is equal to times
213

214
00:09:19,370 --> 00:09:22,810
font family name 15 and bold.
214

215
00:09:22,810 --> 00:09:25,610
Okay and also I want to use border.
215

216
00:09:25,610 --> 00:09:30,270
Border for my buttons, five and that's all.
216

217
00:09:30,270 --> 00:09:35,070
So what I need to do, here now I will create a command.
217

218
00:09:35,070 --> 00:09:36,423
Later, not now okay?
218

219
00:09:37,286 --> 00:09:40,202
And now I need to place my buttons right?
219

220
00:09:40,202 --> 00:09:44,503
What I need to do, I need to create here a variable button,
220

221
00:09:46,727 --> 00:09:49,580
actually it's an integer value
221

222
00:09:49,580 --> 00:09:52,980
btn text number will be one.
222

223
00:09:52,980 --> 00:09:55,080
Okay so why it's like that.
223

224
00:09:55,080 --> 00:09:56,260
Now you will understand why I am using
224

225
00:09:56,260 --> 00:09:59,601
btn text is equal to one, after I will use
225

226
00:09:59,601 --> 00:10:01,270
enter for loop and increase this one.
226

227
00:10:01,270 --> 00:10:03,340
It will be one two three four five
227

228
00:10:03,340 --> 00:10:06,620
because our first btn is btn zero also we have.
228

229
00:10:06,620 --> 00:10:08,880
If I want to for example,
229

230
00:10:08,880 --> 00:10:10,970
if I want to display a button here I can
230

231
00:10:10,970 --> 00:10:13,570
say btn underscore number
231

232
00:10:13,570 --> 00:10:16,370
and square brackets one two three.
232

233
00:10:16,370 --> 00:10:17,830
This is my buttons right?
233

234
00:10:17,830 --> 00:10:20,440
Here I want to start from one,
234

235
00:10:20,440 --> 00:10:23,350
that's why I said btn text is equal to one.
235

236
00:10:23,350 --> 00:10:27,030
And after that here I say for i in range
236

237
00:10:28,540 --> 00:10:30,240
zero three
237

238
00:10:30,240 --> 00:10:33,160
and now I will use nested for loop okay?
238

239
00:10:33,160 --> 00:10:36,020
For j in range
239

240
00:10:36,020 --> 00:10:38,410
and again from zero to three.
240

241
00:10:38,410 --> 00:10:39,400
Okay?
241

242
00:10:39,400 --> 00:10:41,387
Normally what I need to say here
242

243
00:10:41,387 --> 00:10:45,263
I need to say btn numbers,
243

244
00:10:46,940 --> 00:10:48,160
I said btn numbers
244

245
00:10:48,160 --> 00:10:53,160
lets say it btn numbers because we have numbers right?
245

246
00:10:53,360 --> 00:10:56,310
Btn numbers, my number will be here.
246

247
00:10:56,310 --> 00:10:58,760
I need to use btn text okay?
247

248
00:10:58,760 --> 00:11:02,440
It means my first number okay?
248

249
00:11:02,440 --> 00:11:05,391
This is btn, now let me show you something.
249

250
00:11:05,391 --> 00:11:07,899
You can say like, btn...
250

251
00:11:07,899 --> 00:11:10,780
(typing)
251

252
00:11:10,780 --> 00:11:12,110
numbers
252

253
00:11:12,110 --> 00:11:14,290
and if you type something like a three
253

254
00:11:15,735 --> 00:11:17,700
that means you will call,
254

255
00:11:17,700 --> 00:11:22,500
because this is a list, and this is an index of our btn.
255

256
00:11:22,500 --> 00:11:23,570
Okay?
256

257
00:11:23,570 --> 00:11:25,533
And after that here what I need to do,
257

258
00:11:27,070 --> 00:11:29,970
for text I said btn number text okay?
258

259
00:11:29,970 --> 00:11:32,133
And after that here I will say place.
259

260
00:11:33,010 --> 00:11:35,070
Okay for the place I will say
260

261
00:11:35,070 --> 00:11:38,850
x is equal to 25 plus
261

262
00:11:38,850 --> 00:11:40,980
i times 90
262

263
00:11:42,890 --> 00:11:45,370
and after that I will change this
263

264
00:11:45,370 --> 00:11:49,050
y is equal to 70 plus
264

265
00:11:49,050 --> 00:11:50,756
j times
265

266
00:11:50,756 --> 00:11:52,830
70
266

267
00:11:52,830 --> 00:11:54,436
okay?
267

268
00:11:54,436 --> 00:11:56,967
And now if I want to, lets run it okay?
268

269
00:11:56,967 --> 00:11:59,790
(clicking)
269

270
00:11:59,790 --> 00:12:02,520
And you see now our button is here, only one
270

271
00:12:02,520 --> 00:12:05,990
why is like that because we didn't increase our text value.
271

272
00:12:05,990 --> 00:12:08,330
Here what I need to say, btn
272

273
00:12:08,330 --> 00:12:12,210
text plus equals one okay?
273

274
00:12:12,210 --> 00:12:13,653
Now if I run it again,
274

275
00:12:15,350 --> 00:12:16,940
as you see now our buttons are here.
275

276
00:12:16,940 --> 00:12:19,637
But something wrong here, why is like that?
276

277
00:12:21,400 --> 00:12:25,216
Right they should be here, one two three four five
277

278
00:12:25,216 --> 00:12:26,436
and on till nine right?
278

279
00:12:26,436 --> 00:12:27,620
So how can I solve this problem?
279

280
00:12:27,620 --> 00:12:30,170
Here I need to change to here
280

281
00:12:30,170 --> 00:12:31,490
i and j
281

282
00:12:31,490 --> 00:12:32,800
so for I
282

283
00:12:32,800 --> 00:12:34,160
I will say j
283

284
00:12:34,160 --> 00:12:36,350
and for j I will say i.
284

285
00:12:36,350 --> 00:12:40,210
Now, and if I run it again,
285

286
00:12:40,210 --> 00:12:41,430
as you see now it's correct.
286

287
00:12:41,430 --> 00:12:45,970
It's fine and why it's like that let me explain it.
287

288
00:12:45,970 --> 00:12:48,770
Here, I want to firstly print out my j and i.
288

289
00:12:52,714 --> 00:12:53,565
and I will now
289

290
00:12:53,565 --> 00:12:55,940
show you why it's like that.
290

291
00:12:55,940 --> 00:12:59,133
Now, lets come here and run it.
291

292
00:13:00,840 --> 00:13:01,673
So,
292

293
00:13:03,980 --> 00:13:08,250
first one our text is, so it's here right?
293

294
00:13:08,250 --> 00:13:09,703
And let me run it again,
294

295
00:13:11,100 --> 00:13:14,880
so its here our j value is zero
295

296
00:13:14,880 --> 00:13:16,230
and x value is zero
296

297
00:13:16,230 --> 00:13:19,390
that means btn one its location
297

298
00:13:19,390 --> 00:13:21,390
will be 25 for x
298

299
00:13:21,390 --> 00:13:24,420
because j is zero, it's here.
299

300
00:13:24,420 --> 00:13:28,450
And for y value it will be 25 and 70 okay?
300

301
00:13:28,450 --> 00:13:32,260
For this one, for second one it will be here right?
301

302
00:13:32,260 --> 00:13:36,550
The second button is here for j and i value is here.
302

303
00:13:36,550 --> 00:13:39,650
For j value it will be 25
303

304
00:13:39,650 --> 00:13:41,844
plus j is already one,
304

305
00:13:41,844 --> 00:13:44,210
times 90 that means
305

306
00:13:44,210 --> 00:13:46,710
115 right?
306

307
00:13:46,710 --> 00:13:49,530
so its here, x location okay?
307

308
00:13:49,530 --> 00:13:53,440
And for y location you see i is zero,
308

309
00:13:53,440 --> 00:13:56,700
so it will again be 70 and so on okay?
309

310
00:13:56,700 --> 00:14:00,000
So we will place our buttons
310

311
00:14:00,000 --> 00:14:03,200
to use i and j value like this okay?
311

312
00:14:03,200 --> 00:14:04,610
this is our formula 
312

313
00:14:04,610 --> 00:14:07,530
And after that what I need to do here,
313

314
00:14:07,530 --> 00:14:10,239
now I already create my numbers now.
314

315
00:14:10,239 --> 00:14:13,023
I need to also use here,
315

316
00:14:14,190 --> 00:14:15,080
command right
316

317
00:14:15,080 --> 00:14:17,140
for my buttons.
317

318
00:14:17,140 --> 00:14:21,980
So I will say command, and I will use lamda.
318

319
00:14:21,980 --> 00:14:23,770
For lamda what I need to do,
319

320
00:14:23,770 --> 00:14:27,223
I want to show you something else here, let me,
320

321
00:14:29,400 --> 00:14:30,870
take it here somewhere.
321

322
00:14:30,870 --> 00:14:35,560
For lamda you say x is equal to i okay?
322

323
00:14:35,560 --> 00:14:39,050
And colon after here I will say enter
323

324
00:14:41,050 --> 00:14:42,093
here number.
324

325
00:14:43,470 --> 00:14:46,360
And here I need to pass in a parameter x.
325

326
00:14:46,360 --> 00:14:47,360
Why is like that?
326

327
00:14:47,360 --> 00:14:51,340
Now here, by the way command is equal to...
327

328
00:14:53,420 --> 00:14:54,610
Now I use  " i " right?
328

329
00:14:54,610 --> 00:14:58,360
I say x is equal to "i" okay?
329

330
00:14:58,360 --> 00:15:00,410
And my function is enter number
330

331
00:15:00,410 --> 00:15:03,210
and my parameter number will be x why x?
331

332
00:15:03,210 --> 00:15:06,990
because I need to know which button was pressed okay?
332

333
00:15:06,990 --> 00:15:09,870
So this parameter will show me which button was pressed.
333

334
00:15:09,870 --> 00:15:12,379
For example here, we have nine buttons.
334

335
00:15:12,379 --> 00:15:15,200
If you press nine that x value
335

336
00:15:15,200 --> 00:15:17,480
will understand you have pressed nine, okay?
336

337
00:15:17,480 --> 00:15:19,370
That's why I need to use it like that.
337

338
00:15:19,370 --> 00:15:22,140
And here what I need to do, I will come here
338

339
00:15:22,140 --> 00:15:26,283
and create my function, here I will say.
339

340
00:15:30,090 --> 00:15:33,640
Functions, okay?
340

341
00:15:33,640 --> 00:15:38,640
and our first function will be def enter number.
341

342
00:15:38,930 --> 00:15:42,720
and here I will say enter number and x okay?
342

343
00:15:44,535 --> 00:15:47,031
And now what I need to do,
343

344
00:15:47,031 --> 00:15:49,458
we need to do here something else
344

345
00:15:49,458 --> 00:15:51,738
and let me say pass firstly
345

346
00:15:51,738 --> 00:15:52,720
(clicks)
346

347
00:15:52,720 --> 00:15:56,800
our default value is zero, actually its O
347

348
00:15:56,800 --> 00:15:58,707
but I call it zero okay?
348

349
00:15:58,707 --> 00:16:01,353
I need to remove this value okay?
349

350
00:16:02,720 --> 00:16:04,050
firstly, I will say
350

351
00:16:06,269 --> 00:16:08,410
if entry box.get
351

352
00:16:08,410 --> 00:16:11,300
okay this is our entry box value,
352

353
00:16:11,300 --> 00:16:14,200
is equals equals
353

354
00:16:15,320 --> 00:16:17,780
zero okay, and here what I need to do.
354

355
00:16:17,780 --> 00:16:21,030
I need to say entry box.delete,
355

356
00:16:21,030 --> 00:16:21,900
delete this value
356

357
00:16:23,782 --> 00:16:26,370
and first is zero
357

358
00:16:26,370 --> 00:16:28,300
from zero to end okay?
358

359
00:16:28,300 --> 00:16:29,970
And I will say here end.
359

360
00:16:29,970 --> 00:16:31,780
And after here what I need to do
360

361
00:16:32,711 --> 00:16:34,430
I need to say entry box.insert
361

362
00:16:35,777 --> 00:16:37,830
and my button value
362

363
00:16:37,830 --> 00:16:40,750
str x okay?
363

364
00:16:40,750 --> 00:16:42,573
Now if I run my application,
364

365
00:16:44,090 --> 00:16:46,920
if I look it's here now it's zero.
365

366
00:16:46,920 --> 00:16:49,330
If I press two, as you see now
366

367
00:16:49,330 --> 00:16:50,340
two is here.
367

368
00:16:50,340 --> 00:16:52,520
But if I press three, you see?
368

369
00:16:52,520 --> 00:16:55,430
It doesn't affect anything, nothing happens
369

370
00:16:55,430 --> 00:16:57,371
why is like that?
370

371
00:16:57,371 --> 00:16:59,400
Because here we need to use indexes, okay?
371

372
00:16:59,400 --> 00:17:03,430
First index is already taken by this two, okay?
372

373
00:17:03,430 --> 00:17:05,923
And here what I need to do is use else,
373

374
00:17:05,923 --> 00:17:09,557
and I will say, else length
374

375
00:17:09,557 --> 00:17:12,660
I will say length too for indices
375

376
00:17:12,660 --> 00:17:14,290
length is equal to len
376

377
00:17:15,218 --> 00:17:19,610
of my entry box.get value okay?
377

378
00:17:19,610 --> 00:17:21,540
And here I will say after that,
378

379
00:17:21,540 --> 00:17:23,870
entry box.insert
379

380
00:17:23,870 --> 00:17:25,520
this time,
380

381
00:17:25,520 --> 00:17:26,353
length
381

382
00:17:27,870 --> 00:17:31,180
and here str x.
382

383
00:17:31,180 --> 00:17:34,310
Okay for second one I need to use index number okay?
383

384
00:17:34,310 --> 00:17:35,890
This is the first one okay,
384

385
00:17:35,890 --> 00:17:38,130
for second index I need to use one here.
385

386
00:17:38,130 --> 00:17:40,080
And after two and that means
386

387
00:17:41,947 --> 00:17:43,993
it depends on my length okay?
387

388
00:17:47,057 --> 00:17:49,390
Length of my entry box value okay?
388

389
00:17:49,390 --> 00:17:52,340
Or length anyway, this is the short name of it.
389

390
00:17:52,340 --> 00:17:54,693
So if I run it again,
390

391
00:17:55,680 --> 00:17:57,557
now say I press one.
391

392
00:17:57,557 --> 00:18:01,950
One is fine, two it's working, three four five
392

393
00:18:01,950 --> 00:18:05,950
six seven eight nine, all of them is working.
393

394
00:18:05,950 --> 00:18:07,130
And in this lecture we have learnt
394

395
00:18:07,130 --> 00:18:08,860
how we can create these number buttons.
395

396
00:18:08,860 --> 00:18:10,723
And also we have create our window
396

397
00:18:13,360 --> 00:18:17,440
and in next lesson we will create other functions
397

398
00:18:17,440 --> 00:18:19,780
and of course also other buttons.
398

399
00:18:19,780 --> 00:18:21,793
For now that's all, see you in the next.
