0
1
00:00:05,066 --> 00:00:05,899
<v Volkan>Hello again.</v>
1

2
00:00:05,899 --> 00:00:07,470
in this lesson I will try to show you how we can
2

3
00:00:07,470 --> 00:00:09,440
use entries for our applications.
3

4
00:00:09,440 --> 00:00:10,470
To do that what I need to do,
4

5
00:00:10,470 --> 00:00:12,020
I will create a new Python file
5

6
00:00:13,166 --> 00:00:16,587
and here I will say entries, okay?
6

7
00:00:16,587 --> 00:00:17,624
And after that here,
7

8
00:00:17,624 --> 00:00:19,686
what I need to do,
8

9
00:00:19,686 --> 00:00:23,019
I need to say from tkinter import asterisk
9

10
00:00:25,093 --> 00:00:26,612
and also I want to import TTK
10

11
00:00:26,612 --> 00:00:29,112
from tkinter import TTK, okay?
11

12
00:00:31,023 --> 00:00:31,856
And after it,
12

13
00:00:31,856 --> 00:00:32,912
what I need to do
13

14
00:00:32,912 --> 00:00:35,000
I need to say root equals TK, right?
14

15
00:00:35,000 --> 00:00:38,100
Like before and also let's define here
15

16
00:00:38,100 --> 00:00:40,650
geometry for our root,
16

17
00:00:40,650 --> 00:00:42,120
root dot geometry
17

18
00:00:43,090 --> 00:00:44,680
and I will say for X
18

19
00:00:44,680 --> 00:00:49,300
300 and by 300,
19

20
00:00:49,300 --> 00:00:51,670
for Y value also 300, okay?
20

21
00:00:51,670 --> 00:00:52,570
And also what I need to do,
21

22
00:00:52,570 --> 00:00:56,130
I need to say root dot main loop, right?
22

23
00:00:56,130 --> 00:00:58,110
And now if I run my application
23

24
00:00:59,460 --> 00:01:01,140
as you see now our window is here.
24

25
00:01:01,140 --> 00:01:02,400
So what I want to do,
25

26
00:01:02,400 --> 00:01:05,697
I want to get here two different entries, okay,
26

27
00:01:05,697 --> 00:01:07,471
and also one button.
27

28
00:01:07,471 --> 00:01:09,600
Let's get started.
28

29
00:01:09,600 --> 00:01:12,010
How we can create an entry,
29

30
00:01:12,010 --> 00:01:14,440
it's also very similar to create button
30

31
00:01:14,440 --> 00:01:15,710
or other widgets.
31

32
00:01:15,710 --> 00:01:19,780
We need to say here entry is our variable name.
32

33
00:01:20,950 --> 00:01:22,900
Entry equals, I need to use here,
33

34
00:01:22,900 --> 00:01:25,470
I want to use actually TTK module this time, okay?
34

35
00:01:25,470 --> 00:01:28,080
Of course you can use also tkinter, doesn't matter.
35

36
00:01:28,080 --> 00:01:29,930
TTK dot, you need to say
36

37
00:01:29,930 --> 00:01:32,360
entry constructor method, okay?
37

38
00:01:32,360 --> 00:01:35,430
And my first parameter will be root, okay,
38

39
00:01:35,430 --> 00:01:37,767
and also I want to use here width, okay.
39

40
00:01:37,767 --> 00:01:40,341
Width equals 30.
40

41
00:01:40,341 --> 00:01:42,673
What does mean width here?
41

42
00:01:43,530 --> 00:01:45,610
Width doesn't mean here pixels
42

43
00:01:45,610 --> 00:01:50,300
or how many characters you can type in your entry.
43

44
00:01:50,300 --> 00:01:52,300
It means size of my entry, okay?
44

45
00:01:52,300 --> 00:01:53,420
This is important
45

46
00:01:53,420 --> 00:01:58,420
and also now I will press Control+D and duplicate my entry.
46

47
00:01:58,550 --> 00:01:59,470
For entry two
47

48
00:01:59,470 --> 00:02:02,410
I will say entry2, okay,
48

49
00:02:02,410 --> 00:02:03,740
and here what I need to do,
49

50
00:02:03,740 --> 00:02:05,000
if I want to display them
50

51
00:02:05,000 --> 00:02:06,660
I am to use geometry manager
51

52
00:02:06,660 --> 00:02:08,630
and I will say pack geometry manager
52

53
00:02:09,580 --> 00:02:12,633
and again Control+D for second one is,
53

54
00:02:13,470 --> 00:02:15,930
you say entry2 dot pack, okay?
54

55
00:02:15,930 --> 00:02:18,180
Now if I run my application
55

56
00:02:19,360 --> 00:02:20,193
as you see now
56

57
00:02:20,193 --> 00:02:23,840
our entries they are here, right?
57

58
00:02:23,840 --> 00:02:26,280
And now I can use them
58

59
00:02:26,280 --> 00:02:27,980
but also I want to show you
59

60
00:02:27,980 --> 00:02:29,810
how we can use placeholder text.
60

61
00:02:29,810 --> 00:02:31,490
What I mean placeholder text,
61

62
00:02:31,490 --> 00:02:32,323
I mean hint,
62

63
00:02:32,323 --> 00:02:34,620
how we can show hints to users.
63

64
00:02:34,620 --> 00:02:36,200
Also let me show it.
64

65
00:02:36,200 --> 00:02:37,730
To use hints here
65

66
00:02:38,848 --> 00:02:43,190
we can say entry dot insert for the first one
66

67
00:02:43,190 --> 00:02:46,550
and here now I will press Control+D,
67

68
00:02:46,550 --> 00:02:49,210
Control+P, sorry, to see our hints.
68

69
00:02:49,210 --> 00:02:50,530
As you see it says,
69

70
00:02:50,530 --> 00:02:55,530
Control+P again, index and string, right?
70

71
00:02:55,660 --> 00:02:56,610
So for the index
71

72
00:02:56,610 --> 00:02:57,443
what I need to do,
72

73
00:02:57,443 --> 00:02:59,730
I need to use zero, okay,
73

74
00:02:59,730 --> 00:03:01,460
from the first character that means
74

75
00:03:01,460 --> 00:03:03,242
and after it here
75

76
00:03:03,242 --> 00:03:04,870
I will insert my hint,
76

77
00:03:04,870 --> 00:03:06,190
my placeholder text
77

78
00:03:06,190 --> 00:03:07,023
and I will say,
78

79
00:03:07,023 --> 00:03:12,010
"Please enter your name," okay.
79

80
00:03:12,010 --> 00:03:13,360
If I run my application now
80

81
00:03:16,110 --> 00:03:16,943
as you see now
81

82
00:03:16,943 --> 00:03:18,380
our hint is here
82

83
00:03:18,380 --> 00:03:19,280
and now for example
83

84
00:03:19,280 --> 00:03:22,330
for name I can insert anything I want.
84

85
00:03:22,330 --> 00:03:23,820
Also the other problem here,
85

86
00:03:23,820 --> 00:03:25,890
this is our password field, right?
86

87
00:03:25,890 --> 00:03:26,940
So it is visible.
87

88
00:03:26,940 --> 00:03:28,550
I need to hide these characters,
88

89
00:03:28,550 --> 00:03:29,430
right, password characters.
89

90
00:03:29,430 --> 00:03:30,290
How can I do that?
90

91
00:03:30,290 --> 00:03:35,290
To that here I will say entry2 dot config
91

92
00:03:40,200 --> 00:03:43,013
and for the config I need to say here show,
92

93
00:03:44,080 --> 00:03:45,060
I need to use show method,
93

94
00:03:45,060 --> 00:03:47,870
show instead of password,
94

95
00:03:47,870 --> 00:03:49,230
use for example,
95

96
00:03:49,230 --> 00:03:51,140
let's use star symbol, okay.
96

97
00:03:51,140 --> 00:03:52,250
If I run it again
97

98
00:03:53,320 --> 00:03:54,520
now let's type it.
98

99
00:03:54,520 --> 00:03:59,520
As you see now we hide our password characters
99

100
00:04:00,150 --> 00:04:03,140
and they only show star symbols to users.
100

101
00:04:03,140 --> 00:04:05,630
Okay and also what I want to do,
101

102
00:04:05,630 --> 00:04:07,848
now I want to here create a button.
102

103
00:04:07,848 --> 00:04:08,690
When I hit,
103

104
00:04:08,690 --> 00:04:09,759
when I click this button
104

105
00:04:09,759 --> 00:04:12,924
I want to get the value of my entries, okay?
105

106
00:04:12,924 --> 00:04:13,881
So how can I do that?
106

107
00:04:13,881 --> 00:04:14,820
To do that here
107

108
00:04:14,820 --> 00:04:16,166
I will create a button
108

109
00:04:16,166 --> 00:04:18,719
and I will say button equals,
109

110
00:04:18,719 --> 00:04:20,710
let's use TTK again.
110

111
00:04:20,710 --> 00:04:22,870
Button constructor method here
111

112
00:04:22,870 --> 00:04:23,800
and for the button
112

113
00:04:23,800 --> 00:04:25,250
first parameter will be root.
113

114
00:04:25,250 --> 00:04:27,023
Second one will be text.
114

115
00:04:28,270 --> 00:04:29,610
Text equals,
115

116
00:04:29,610 --> 00:04:31,703
let's say click me.
116

117
00:04:32,830 --> 00:04:34,533
Okay and also what I need to do,
117

118
00:04:34,533 --> 00:04:36,790
I need to use commands property here
118

119
00:04:36,790 --> 00:04:40,420
and command equals callback, okay?
119

120
00:04:40,420 --> 00:04:41,763
And after that what I need to do,
120

121
00:04:41,763 --> 00:04:43,730
I need to create my definition here.
121

122
00:04:43,730 --> 00:04:48,730
Def callback and here I will get my value of entries.
122

123
00:04:51,170 --> 00:04:52,003
How can I do that?
123

124
00:04:52,003 --> 00:04:54,210
To that I will say here create a variable.
124

125
00:04:54,210 --> 00:04:56,300
Variable one equals,
125

126
00:04:56,300 --> 00:05:00,410
I will say entry one dot get, okay?
126

127
00:05:00,410 --> 00:05:04,510
And for the second one I will press Control+D.
127

128
00:05:04,510 --> 00:05:09,510
Value two equals entry two dot get, okay,
128

129
00:05:09,687 --> 00:05:11,520
and let's print out them.
129

130
00:05:11,520 --> 00:05:12,353
How can I do that?
130

131
00:05:12,353 --> 00:05:13,463
I will say here print,
131

132
00:05:15,060 --> 00:05:17,513
your name is,
132

133
00:05:18,500 --> 00:05:19,333
okay and here after it
133

134
00:05:19,333 --> 00:05:21,290
I am to use plus symbol
134

135
00:05:21,290 --> 00:05:24,060
and I will say value one, okay.
135

136
00:05:24,060 --> 00:05:26,420
For the password also let's use it.
136

137
00:05:26,420 --> 00:05:31,420
Print, your password is,
137

138
00:05:33,460 --> 00:05:36,800
and here again let's use here colon
138

139
00:05:36,800 --> 00:05:38,650
and like that
139

140
00:05:40,160 --> 00:05:41,900
and here again
140

141
00:05:41,900 --> 00:05:44,070
plus value two.
141

142
00:05:44,070 --> 00:05:47,440
Okay and now if I run my application again
142

143
00:05:51,420 --> 00:05:54,210
here for the name let's say something like that.
143

144
00:05:54,210 --> 00:05:56,365
For the password something like that.
144

145
00:05:56,365 --> 00:05:59,180
Now focus on here,
145

146
00:05:59,180 --> 00:06:00,380
on our console,
146

147
00:06:00,380 --> 00:06:01,390
sorry, here by the way
147

148
00:06:01,390 --> 00:06:04,630
we forgot to add our button, right?
148

149
00:06:04,630 --> 00:06:05,700
So for the button
149

150
00:06:05,700 --> 00:06:06,533
what I need to do,
150

151
00:06:06,533 --> 00:06:07,650
I need to say here
151

152
00:06:07,650 --> 00:06:10,220
button dot pack, right?
152

153
00:06:10,220 --> 00:06:13,310
And now our button will be there.
153

154
00:06:13,310 --> 00:06:15,890
Run and here is,
154

155
00:06:15,890 --> 00:06:17,023
why it's like that?
155

156
00:06:17,023 --> 00:06:22,023
I am to use pack geometry manager after my entries.
156

157
00:06:22,500 --> 00:06:26,433
So here and now it will be fine.
157

158
00:06:27,550 --> 00:06:29,720
As you see now my button is here.
158

159
00:06:29,720 --> 00:06:30,700
Now if I,
159

160
00:06:30,700 --> 00:06:33,740
for example here let's say George
160

161
00:06:33,740 --> 00:06:35,880
for the George one, two, three, four, five
161

162
00:06:35,880 --> 00:06:37,970
and six for the password, okay?
162

163
00:06:37,970 --> 00:06:39,240
And if I hit,
163

164
00:06:39,240 --> 00:06:40,940
click the button,
164

165
00:06:40,940 --> 00:06:41,773
as you see now
165

166
00:06:41,773 --> 00:06:42,660
your name is George.
166

167
00:06:42,660 --> 00:06:46,760
Your password is 12345 and 6
167

168
00:06:46,760 --> 00:06:48,490
and also I want to show you
168

169
00:06:48,490 --> 00:06:52,950
how we can use state function for our entries.
169

170
00:06:52,950 --> 00:06:55,610
Here I will come and say
170

171
00:06:55,610 --> 00:06:59,360
entry dot state, okay,
171

172
00:06:59,360 --> 00:07:03,060
and if you want to make disable your entry
172

173
00:07:03,060 --> 00:07:05,860
you need to say here disabled,
173

174
00:07:05,860 --> 00:07:07,780
simply disabled, okay,
174

175
00:07:07,780 --> 00:07:09,350
and if I run it again
175

176
00:07:10,530 --> 00:07:11,363
as you see now
176

177
00:07:11,363 --> 00:07:12,940
our first entry is disabled.
177

178
00:07:12,940 --> 00:07:14,610
How can I make it normal?
178

179
00:07:14,610 --> 00:07:15,820
It's very simple.
179

180
00:07:15,820 --> 00:07:17,730
I will press Control+D here
180

181
00:07:17,730 --> 00:07:19,367
and instead of disabled
181

182
00:07:19,367 --> 00:07:22,720
I need to say not disabled, okay?
182

183
00:07:22,720 --> 00:07:24,573
And let's run it again.
183

184
00:07:25,490 --> 00:07:30,490
As you see now it is now our entry is working
184

185
00:07:30,930 --> 00:07:34,930
and we can type something, right?
185

186
00:07:34,930 --> 00:07:37,210
And the last function I want to show you,
186

187
00:07:37,210 --> 00:07:39,640
it is read only for entries
187

188
00:07:39,640 --> 00:07:42,830
and here entry dot state
188

189
00:07:42,830 --> 00:07:46,940
and here I will say again square brackets
189

190
00:07:46,940 --> 00:07:50,370
and here I will say read only, okay.
190

191
00:07:50,370 --> 00:07:51,790
Read only will let me,
191

192
00:07:51,790 --> 00:07:53,650
let's run first our application.
192

193
00:07:53,650 --> 00:07:54,600
As you see now here
193

194
00:07:55,750 --> 00:07:57,200
for the second one I did,
194

195
00:07:57,200 --> 00:07:59,573
actually let's do it for the first one, okay.
195

196
00:08:00,620 --> 00:08:03,480
Entry dot state read only.
196

197
00:08:03,480 --> 00:08:05,193
Now you see it's here.
197

198
00:08:06,088 --> 00:08:08,060
What I can do here,
198

199
00:08:08,060 --> 00:08:10,850
now I cannot edit my entry
199

200
00:08:10,850 --> 00:08:12,770
but I can copy this value, okay.
200

201
00:08:12,770 --> 00:08:15,600
For example copy and I will paste it here.
201

202
00:08:15,600 --> 00:08:17,320
You see, please enter your name.
202

203
00:08:17,320 --> 00:08:20,790
So let me run it again.
203

204
00:08:20,790 --> 00:08:23,850
For which kind of purposes I can use this readonly?
204

205
00:08:23,850 --> 00:08:26,200
for example if you want to create a clipboard
205

206
00:08:26,200 --> 00:08:29,580
and if you want to generate keys for your users
206

207
00:08:29,580 --> 00:08:32,420
you can use this function read only, okay,
207

208
00:08:32,420 --> 00:08:36,160
and this is how we can use entries for our GUI applications.
208

209
00:08:36,160 --> 00:08:37,160
For now that's all.
209

210
00:08:37,160 --> 00:08:38,160
See you in the next.
