0
1
00:00:04,430 --> 00:00:05,263
<v Volkan>Hello again.</v>
1

2
00:00:05,263 --> 00:00:06,439
In this lesson
2

3
00:00:06,439 --> 00:00:07,272
we are going to learn
3

4
00:00:07,272 --> 00:00:09,380
how we can use labels for our applications.
4

5
00:00:09,380 --> 00:00:11,320
Label is very very important
5

6
00:00:11,320 --> 00:00:12,190
widget why its like it
6

7
00:00:12,190 --> 00:00:13,917
because for almost every widget,
7

8
00:00:13,917 --> 00:00:16,880
every GUI application we need to use labels, right?
8

9
00:00:16,880 --> 00:00:19,730
To that I will try to show you all the functions,
9

10
00:00:19,730 --> 00:00:22,170
actually not all but the most important functions
10

11
00:00:22,170 --> 00:00:24,700
for only the labels, okay.
11

12
00:00:24,700 --> 00:00:25,980
And here what we need to do
12

13
00:00:25,980 --> 00:00:28,110
before creating our GUI application
13

14
00:00:28,110 --> 00:00:30,435
here I need to create a new Python file
14

15
00:00:30,435 --> 00:00:31,590
and here I will say right click,
15

16
00:00:31,590 --> 00:00:32,750
new Python file
16

17
00:00:32,750 --> 00:00:37,660
and I will say using labels for our Python file
17

18
00:00:37,660 --> 00:00:39,200
and click okay.
18

19
00:00:39,200 --> 00:00:42,070
Now I have created my Python file
19

20
00:00:42,070 --> 00:00:43,410
and here what I need to do,
20

21
00:00:43,410 --> 00:00:47,440
I need to say from Tkinter import asterisk, right?
21

22
00:00:47,440 --> 00:00:49,990
But this time I am not going to install.
22

23
00:00:49,990 --> 00:00:52,420
I'm not going to import a TTK module, okay,
23

24
00:00:52,420 --> 00:00:56,540
because I can use both modules to create a label
24

25
00:00:56,540 --> 00:00:57,520
and after that what I need to do,
25

26
00:00:57,520 --> 00:00:59,473
I need to create my top level window,
26

27
00:01:00,470 --> 00:01:02,609
top level widget it's root 
27

28
00:01:02,609 --> 00:01:04,343
and here I will say TK, right?
28

29
00:01:06,630 --> 00:01:07,463
After what I need to do?
29

30
00:01:07,463 --> 00:01:09,890
I need say root dot main loop
30

31
00:01:09,890 --> 00:01:12,437
but before main loop also let's use geometry
31

32
00:01:12,437 --> 00:01:13,890
for our root,
32

33
00:01:13,890 --> 00:01:15,780
root dot geometry
33

34
00:01:15,780 --> 00:01:20,780
and for geometry I will say 300 by 250, okay?
34

35
00:01:21,150 --> 00:01:24,660
And now we are ready to run our application.
35

36
00:01:24,660 --> 00:01:26,520
As you see now our window is here.
36

37
00:01:26,520 --> 00:01:27,353
So what we are to do now,
37

38
00:01:27,353 --> 00:01:29,750
we need to create our labels, right?
38

39
00:01:29,750 --> 00:01:31,320
Actually I will create only one label
39

40
00:01:31,320 --> 00:01:33,490
and after that I will try to show you
40

41
00:01:33,490 --> 00:01:36,796
how the default functions for our,
41

42
00:01:36,796 --> 00:01:38,130
different functions for a label.
42

43
00:01:38,130 --> 00:01:40,280
Here I will create a name.
43

44
00:01:40,280 --> 00:01:41,960
It's name will the label
44

45
00:01:41,960 --> 00:01:43,060
and after it what I need to do,
45

46
00:01:43,060 --> 00:01:46,160
I need to use label constructor method
46

47
00:01:46,160 --> 00:01:49,330
but here 'L' is capital okay!
47

48
00:01:49,330 --> 00:01:50,469
and after that
48

49
00:01:50,469 --> 00:01:51,302
what I need to do,
49

50
00:01:51,302 --> 00:01:52,210
I need to say root,
50

51
00:01:52,210 --> 00:01:53,270
my first parameter,
51

52
00:01:53,270 --> 00:01:56,320
and after it here I also want
52

53
00:01:56,320 --> 00:01:58,840
to use text property for my label.
53

54
00:01:58,840 --> 00:02:00,170
After text what I need to say,
54

55
00:02:00,170 --> 00:02:01,539
I need to use quotes,
55

56
00:02:01,539 --> 00:02:04,570
single or double quotes doesn't matter,
56

57
00:02:04,570 --> 00:02:08,310
and here I will say hello Python, okay,
57

58
00:02:08,310 --> 00:02:11,210
and also if I want to make my label visible,
58

59
00:02:11,210 --> 00:02:12,043
what I need to do
59

60
00:02:12,043 --> 00:02:14,100
I need to say label dot pack, right?
60

61
00:02:14,100 --> 00:02:15,640
Now our label is ready.
61

62
00:02:15,640 --> 00:02:16,713
Let's run it.
62

63
00:02:18,220 --> 00:02:20,070
As you see now our label is here
63

64
00:02:20,070 --> 00:02:22,280
and it says, "Hello Python."
64

65
00:02:22,280 --> 00:02:23,550
So now I want to show you
65

66
00:02:23,550 --> 00:02:26,630
how we can configure our label, okay?
66

67
00:02:26,630 --> 00:02:28,510
Of course to that we can come to here
67

68
00:02:28,510 --> 00:02:29,850
and add new,
68

69
00:02:29,850 --> 00:02:32,740
can specify new properties for our label, right?
69

70
00:02:32,740 --> 00:02:35,460
But also I want to show other ways to do that.
70

71
00:02:35,460 --> 00:02:36,700
Here the first way is
71

72
00:02:36,700 --> 00:02:38,840
we can say here label dot,
72

73
00:02:38,840 --> 00:02:39,673
sorry not dot,
73

74
00:02:39,673 --> 00:02:42,220
label and after it square brackets here.
74

75
00:02:42,220 --> 00:02:43,797
If you want to change your text property
75

76
00:02:43,797 --> 00:02:46,160
you can say text between quotes
76

77
00:02:46,160 --> 00:02:48,480
and after it for a new value for the text
77

78
00:02:48,480 --> 00:02:52,140
you can say hello Tkinter.
78

79
00:02:52,140 --> 00:02:53,110
This is the first way.
79

80
00:02:53,110 --> 00:02:54,623
Let's run our application.
80

81
00:02:55,840 --> 00:02:58,270
As you see now our text is hello Tkinter
81

82
00:02:58,270 --> 00:03:00,010
but I don't recommend this way.
82

83
00:03:00,010 --> 00:03:02,190
I will show you another way
83

84
00:03:02,190 --> 00:03:04,423
and let's comment out this guy here.
84

85
00:03:05,270 --> 00:03:06,400
What you need to do here,
85

86
00:03:06,400 --> 00:03:07,590
I need to say
86

87
00:03:07,590 --> 00:03:10,220
label dot config, okay.
87

88
00:03:10,220 --> 00:03:12,300
For new properties
88

89
00:03:12,300 --> 00:03:13,860
you can use this config method
89

90
00:03:13,860 --> 00:03:17,020
or if you want to modify your existing property
90

91
00:03:20,510 --> 00:03:22,250
you can use config method, okay?
91

92
00:03:22,250 --> 00:03:24,400
For new properties or the old one
92

93
00:03:24,400 --> 00:03:25,590
you can use config
93

94
00:03:25,590 --> 00:03:27,830
and let's use for text this time
94

95
00:03:27,830 --> 00:03:30,600
and after it we can add new properties for our label.
95

96
00:03:30,600 --> 00:03:35,600
Text is now going to be hello Tkinter, okay,
96

97
00:03:37,900 --> 00:03:40,940
and let's run our application now again.
97

98
00:03:40,940 --> 00:03:41,773
As you see now
98

99
00:03:41,773 --> 00:03:43,840
our text is hello Tkinter.
99

100
00:03:43,840 --> 00:03:47,300
Let's use also another properties for our label.
100

101
00:03:47,300 --> 00:03:50,280
For example we can use font property, right?
101

102
00:03:50,280 --> 00:03:52,810
Config and here I will say font.
102

103
00:03:52,810 --> 00:03:53,643
We can use the font.
103

104
00:03:53,643 --> 00:03:56,010
For the font you need to use font,
104

105
00:03:56,010 --> 00:03:58,600
constructor a font function, okay,
105

106
00:03:58,600 --> 00:04:01,470
and after that here you need to use quotes
106

107
00:04:01,470 --> 00:04:03,260
and after it font family name.
107

108
00:04:03,260 --> 00:04:05,040
I will use Times
108

109
00:04:05,040 --> 00:04:06,420
and after font family name
109

110
00:04:06,420 --> 00:04:08,460
you can use your font size.
110

111
00:04:08,460 --> 00:04:10,780
Let's say 15, okay?
111

112
00:04:10,780 --> 00:04:12,650
If I run my application again
112

113
00:04:12,650 --> 00:04:13,590
as you see now here
113

114
00:04:13,590 --> 00:04:15,030
our font is different
114

115
00:04:15,030 --> 00:04:17,610
and size is 15 pixels, okay?
115

116
00:04:17,610 --> 00:04:22,123
And also let's use foreground for our label.
116

117
00:04:23,210 --> 00:04:24,043
For the foreground
117

118
00:04:24,043 --> 00:04:26,993
I am to say FG equals,
118

119
00:04:27,900 --> 00:04:29,760
let's say red, okay,
119

120
00:04:29,760 --> 00:04:32,203
and this will be our font colour.
120

121
00:04:33,510 --> 00:04:36,180
As you see now our font is red now.
121

122
00:04:36,180 --> 00:04:37,013
Also of course
122

123
00:04:37,013 --> 00:04:39,980
we can change our background colour of our label.
123

124
00:04:39,980 --> 00:04:41,250
How we can do that?
124

125
00:04:41,250 --> 00:04:44,280
To that I will create another config method here.
125

126
00:04:44,280 --> 00:04:45,170
I will say,
126

127
00:04:45,170 --> 00:04:46,170
by the way it doesn't matter,
127

128
00:04:46,170 --> 00:04:48,110
we can also use it here or here
128

129
00:04:48,110 --> 00:04:49,780
or another new config method.
129

130
00:04:49,780 --> 00:04:50,640
Doesn't matter, okay.
130

131
00:04:50,640 --> 00:04:55,450
I try to show all possibilities for our widgets, okay?
131

132
00:04:55,450 --> 00:04:58,810
And here I will say BG, background colour.
132

133
00:04:58,810 --> 00:04:59,870
For the background colour
133

134
00:04:59,870 --> 00:05:01,690
I will say yellow, okay?
134

135
00:05:01,690 --> 00:05:02,890
If I run again
135

136
00:05:04,530 --> 00:05:06,540
as you see now our text colour is red
136

137
00:05:06,540 --> 00:05:08,840
and background colour is yellow
137

138
00:05:08,840 --> 00:05:11,970
and let's also create a long text here.
138

139
00:05:11,970 --> 00:05:14,300
I want to say label dot config
139

140
00:05:15,850 --> 00:05:17,513
and a new text property.
140

141
00:05:18,450 --> 00:05:22,274
For text property I will say hello Python.
141

142
00:05:22,274 --> 00:05:27,274
I love you so much.
142

143
00:05:27,340 --> 00:05:28,820
Okay, something like that
143

144
00:05:28,820 --> 00:05:30,430
and if I run it again
144

145
00:05:32,540 --> 00:05:33,373
as you see now
145

146
00:05:33,373 --> 00:05:36,250
our text is longer than before.
146

147
00:05:36,250 --> 00:05:39,110
Of course you can create a text as long as you need.
147

148
00:05:39,110 --> 00:05:40,300
Doesn't matter, okay,
148

149
00:05:40,300 --> 00:05:42,430
but here also I want to show you something else.
149

150
00:05:42,430 --> 00:05:47,100
Now we can also change our text length.
150

151
00:05:47,100 --> 00:05:48,120
Also I want to show it,
151

152
00:05:48,120 --> 00:05:49,960
how we can change our text length.
152

153
00:05:49,960 --> 00:05:51,350
To that we need to come here
153

154
00:05:51,350 --> 00:05:53,620
and you need to use another function
154

155
00:05:53,620 --> 00:05:55,710
to change our text length.
155

156
00:05:55,710 --> 00:05:58,630
Here I'll say label dot config
156

157
00:05:58,630 --> 00:06:02,820
and wrap length, okay?
157

158
00:06:02,820 --> 00:06:04,803
For the wrap length I will say,
158

159
00:06:05,850 --> 00:06:09,530
let's use 150, okay,
159

160
00:06:09,530 --> 00:06:14,530
and before it was almost 300 pixels.
160

161
00:06:14,550 --> 00:06:15,630
Well what's wrong here,
161

162
00:06:15,630 --> 00:06:19,183
wrap length and,
162

163
00:06:21,720 --> 00:06:23,363
sorry it must be here.
163

164
00:06:25,220 --> 00:06:26,590
Wrap length, right okay?
164

165
00:06:26,590 --> 00:06:28,010
And if I run it again
165

166
00:06:28,010 --> 00:06:29,000
as you see now here
166

167
00:06:29,000 --> 00:06:32,550
our text length is 150 pixels.
167

168
00:06:32,550 --> 00:06:36,500
Also I want to show you how we can change our text justify,
168

169
00:06:36,500 --> 00:06:37,840
okay, text alignment.
169

170
00:06:37,840 --> 00:06:41,290
By default our text alignment is left side, okay.
170

171
00:06:41,290 --> 00:06:43,720
Of course we can make it centre or right.
171

172
00:06:43,720 --> 00:06:46,280
I will try to show you how we can make right.
172

173
00:06:46,280 --> 00:06:49,270
Here to do that I will say label dot config
173

174
00:06:49,270 --> 00:06:53,130
and here I need to use justify function, okay.
174

175
00:06:53,130 --> 00:06:55,750
Justify equals, you can use here quotes,
175

176
00:06:55,750 --> 00:06:57,740
single quotes and after it right,
176

177
00:06:57,740 --> 00:06:58,970
something like that.
177

178
00:06:58,970 --> 00:07:01,250
You can do it like that
178

179
00:07:01,250 --> 00:07:02,923
and also you can say,
179

180
00:07:02,923 --> 00:07:04,410
you can remove the quotes
180

181
00:07:04,410 --> 00:07:08,164
and here you can use letters all,
181

182
00:07:08,164 --> 00:07:09,650
letters must be,
182

183
00:07:09,650 --> 00:07:11,170
all of them must be capital, okay?
183

184
00:07:11,170 --> 00:07:13,860
Also this way is acceptable.
184

185
00:07:13,860 --> 00:07:16,260
Now if I run my application
185

186
00:07:16,260 --> 00:07:19,900
as you see now our text length is 150 pixels
186

187
00:07:19,900 --> 00:07:23,160
and our text alignment is right side.
187

188
00:07:23,160 --> 00:07:25,910
This is how we can use labels for our applications.
188

189
00:07:25,910 --> 00:07:27,410
Of course there are more functions
189

190
00:07:27,410 --> 00:07:31,180
for the labels but we will learn them step by step.
190

191
00:07:31,180 --> 00:07:32,013
For now that's all.
191

192
00:07:32,013 --> 00:07:33,033
See you in the next.
