0
1
00:00:04,670 --> 00:00:06,330
<v Volkan>Hello everybody, in this lesson we are going</v>
1

2
00:00:06,330 --> 00:00:10,130
to learn how we can use check boxes for our applications.
2

3
00:00:10,130 --> 00:00:12,690
So what we need to do, if you want to create a check box
3

4
00:00:12,690 --> 00:00:15,580
here firstly, of course we need to create our variable,
4

5
00:00:15,580 --> 00:00:20,580
and I will name it 'check box', something like that, okay?
5

6
00:00:20,613 --> 00:00:24,060
'Check box is equal to', and after that what I need to do,
6

7
00:00:24,060 --> 00:00:26,400
I need to use my constructor method, right?
7

8
00:00:26,400 --> 00:00:29,900
I can use the TK or TTK module, it doesn't matter.
8

9
00:00:29,900 --> 00:00:32,950
But I am going to use the TK module, okay?
9

10
00:00:32,950 --> 00:00:37,330
So, my constructor method will be a 'check button', okay?
10

11
00:00:37,330 --> 00:00:39,520
And now we need to create our properties.
11

12
00:00:39,520 --> 00:00:42,550
The first property will be 'root', our top level window,
12

13
00:00:42,550 --> 00:00:46,330
and after it here, I want to create text property.
13

14
00:00:46,330 --> 00:00:47,883
For the text I will say:
14

15
00:00:49,280 --> 00:00:52,040
'Remember me', okay?
15

16
00:00:52,040 --> 00:00:54,950
And after that, I need to create
16

17
00:00:54,950 --> 00:00:57,740
a variable for my check box.
17

18
00:00:57,740 --> 00:01:00,180
I will tell you why we are using check box variable,
18

19
00:01:00,180 --> 00:01:02,410
and here I will name it:
19

20
00:01:02,410 --> 00:01:06,570
'Check box variable', okay, something like that.
20

21
00:01:06,570 --> 00:01:09,070
And also let's use font for our
21

22
00:01:09,070 --> 00:01:13,003
check box, 'font equals', here what I need to say,
22

23
00:01:13,003 --> 00:01:16,510
let's use, quote 'Arial' for our font family,
23

24
00:01:16,510 --> 00:01:19,773
and for the size, I'll say '16', okay?
24

25
00:01:20,610 --> 00:01:23,000
And also, after that what I need to use,
25

26
00:01:23,000 --> 00:01:26,450
I need to use here grid geometry manager, right?
26

27
00:01:26,450 --> 00:01:29,510
For my check box.
27

28
00:01:29,510 --> 00:01:33,860
I will say 'grid, row equals four'.
28

29
00:01:33,860 --> 00:01:34,693
Why four?
29

30
00:01:34,693 --> 00:01:37,720
Because our last row was three, right?
30

31
00:01:37,720 --> 00:01:41,870
Now, I will use four for check box, okay?
31

32
00:01:41,870 --> 00:01:45,498
And also, 'column' will be zero, okay?
32

33
00:01:45,498 --> 00:01:48,500
And now what I need to do here, I need to
33

34
00:01:48,500 --> 00:01:50,180
create this variable right here.
34

35
00:01:50,180 --> 00:01:51,263
I will say:
35

36
00:01:52,507 --> 00:01:57,470
'check box var equals integer var'.
36

37
00:01:57,470 --> 00:01:58,640
Why is integer?
37

38
00:01:58,640 --> 00:01:59,823
Let me explain it.
38

39
00:02:01,550 --> 00:02:05,410
Now, if our check box is checked, it's value will be one.
39

40
00:02:05,410 --> 00:02:09,280
If it's not checked, by default it will be zero, okay?
40

41
00:02:09,280 --> 00:02:12,170
That's why we need to use here, integer variable,
41

42
00:02:12,170 --> 00:02:16,350
and also after that here I will say 'check box var,
42

43
00:02:16,350 --> 00:02:20,510
dot set', and I will set it to 'zero', okay?
43

44
00:02:20,510 --> 00:02:22,950
Zero means not checked, okay?
44

45
00:02:22,950 --> 00:02:25,283
And if I run my application now, let's see.
45

46
00:02:27,620 --> 00:02:30,130
As you see now, our check box is here,
46

47
00:02:30,130 --> 00:02:32,450
but it is here on the left side, but why is like that?
47

48
00:02:32,450 --> 00:02:36,500
Because we said here remember, column number zero,
48

49
00:02:36,500 --> 00:02:39,770
so this is the first column, right?
49

50
00:02:39,770 --> 00:02:42,497
If you want to, we can align it to the
50

51
00:02:42,497 --> 00:02:44,330
right side, how we can do that?
51

52
00:02:44,330 --> 00:02:47,010
To do that, here we need to use another property
52

53
00:02:47,010 --> 00:02:50,233
and it will sticky  property, and here I will say,
53

54
00:02:50,233 --> 00:02:54,570
'sticky equals E', okay?
54

55
00:02:54,570 --> 00:02:57,723
And now it will be on the right side.
55

56
00:02:59,920 --> 00:03:02,647
And here something's wrong, why is it like that?
56

57
00:03:02,647 --> 00:03:04,253
Let me check it again.
57

58
00:03:05,090 --> 00:03:06,988
And here also what we need to use,
58

59
00:03:06,988 --> 00:03:09,233
we need to also use 'column span', okay?
59

60
00:03:09,233 --> 00:03:13,150
And because if we don't use
60

61
00:03:13,150 --> 00:03:15,120
'column span', it will stay here,
61

62
00:03:15,120 --> 00:03:17,603
so after 'sticky', I will say here,
62

63
00:03:18,580 --> 00:03:23,580
'column span equals two',
63

64
00:03:23,980 --> 00:03:24,820
okay?
64

65
00:03:24,820 --> 00:03:27,093
And if I run my application now again,
65

66
00:03:28,750 --> 00:03:31,050
as you see now, our check box is good,
66

67
00:03:31,050 --> 00:03:34,560
this place is good and it's on the right side, okay?
67

68
00:03:34,560 --> 00:03:38,290
So what I need to do now, here I want to create
68

69
00:03:38,290 --> 00:03:41,230
a function okay, for my button.
69

70
00:03:41,230 --> 00:03:44,040
When I hit this button, I want to get this value
70

71
00:03:44,040 --> 00:03:47,020
of the first entry and also the second entry,
71

72
00:03:47,020 --> 00:03:51,250
also I want to check if my check box is checked or not.
72

73
00:03:51,250 --> 00:03:53,020
Okay, so how can I do that?
73

74
00:03:53,020 --> 00:03:56,440
To do that I need to find my button first,
74

75
00:03:56,440 --> 00:03:58,220
my button is somewhere here, right?
75

76
00:03:58,220 --> 00:03:59,103
It was here,
76

77
00:04:01,972 --> 00:04:04,630
and check box, and my button is here, right?
77

78
00:04:04,630 --> 00:04:07,850
And even we can say here, 'button configure method',
78

79
00:04:07,850 --> 00:04:09,130
we can also use that, we don't
79

80
00:04:09,130 --> 00:04:10,780
have to go to our button.
80

81
00:04:10,780 --> 00:04:13,410
Or you can create your command property here,
81

82
00:04:13,410 --> 00:04:18,410
or also, you can use config method, sorry, here.
82

83
00:04:18,790 --> 00:04:21,943
So for the button, I say 'button dot config', okay?
83

84
00:04:25,120 --> 00:04:27,843
And here, what I need to say, I need to say here:
84

85
00:04:30,040 --> 00:04:35,001
'command equals', let's name it 'callback', okay?
85

86
00:04:35,001 --> 00:04:37,965
Our definition name is 'callback'.
86

87
00:04:37,965 --> 00:04:39,400
So what I need to do now, I need to create
87

88
00:04:39,400 --> 00:04:41,150
my callback function, right?
88

89
00:04:41,150 --> 00:04:44,503
Here I will come and say 'def callback'
89

90
00:04:47,447 --> 00:04:48,280
Okay?
90

91
00:04:48,280 --> 00:04:50,600
And here what I need to say, firstly
91

92
00:04:50,600 --> 00:04:54,680
I want to get my entry fields, okay?
92

93
00:04:54,680 --> 00:04:56,800
And the value of my entries.
93

94
00:04:56,800 --> 00:04:57,993
And here I will say,
94

95
00:05:00,364 --> 00:05:01,197
or
95

96
00:05:03,620 --> 00:05:04,560
what we can do,
96

97
00:05:04,560 --> 00:05:07,300
or something else, let's use here 'print', okay?
97

98
00:05:07,300 --> 00:05:10,397
And here I will say, 'your name',
98

99
00:05:11,640 --> 00:05:12,960
and our name will be,
99

100
00:05:12,960 --> 00:05:16,860
'plus symbol, entry dot get' okay?
100

101
00:05:16,860 --> 00:05:18,810
This is our first entry remember,
101

102
00:05:18,810 --> 00:05:21,230
and the other one is entry two, right?
102

103
00:05:21,230 --> 00:05:25,337
And I will print out my name in the first entry value.
103

104
00:05:25,337 --> 00:05:28,407
And for the second I will say 'your password',
104

105
00:05:31,739 --> 00:05:32,620
password,
105

106
00:05:32,620 --> 00:05:35,110
and here, colon after that here, and what I need to say,
106

107
00:05:35,110 --> 00:05:40,110
I need to say 'entry two dot get', okay?
107

108
00:05:40,530 --> 00:05:44,330
And for the check box what I need to do now here,
108

109
00:05:44,330 --> 00:05:46,930
now we have, remember, for the check box
109

110
00:05:46,930 --> 00:05:48,840
we have two options, the first one is 'checked',
110

111
00:05:48,840 --> 00:05:51,020
the other one is 'not checked', right?
111

112
00:05:51,020 --> 00:05:52,810
So here I need to check it.
112

113
00:05:52,810 --> 00:05:57,810
I will say here, 'if check box variable dot get',
113

114
00:05:57,940 --> 00:05:59,110
okay,
114

115
00:05:59,110 --> 00:06:02,320
equals, equals one, that means my check box is checked',
115

116
00:06:02,320 --> 00:06:03,153
okay?
116

117
00:06:03,153 --> 00:06:08,120
So I will say here, 'print, remember me selected' okay?
117

118
00:06:08,120 --> 00:06:09,770
Or checked, that doesn't matter.
118

119
00:06:09,770 --> 00:06:13,270
And if not, right, I will say: 'else'.
119

120
00:06:13,270 --> 00:06:16,420
For else, that means my variable value is zero,
120

121
00:06:16,420 --> 00:06:21,320
so I will say 'print not selected',
121

122
00:06:21,320 --> 00:06:22,890
okay?
122

123
00:06:22,890 --> 00:06:25,530
And here now, what I need to do,
123

124
00:06:25,530 --> 00:06:27,833
I will run my application.
124

125
00:06:29,870 --> 00:06:33,233
Now here for the name, I will say:
125

126
00:06:34,470 --> 00:06:35,597
let's say 'Volkan',
126

127
00:06:38,950 --> 00:06:40,930
and for the password, 'one, two, three,
127

128
00:06:40,930 --> 00:06:43,230
four, five, and six' now.
128

129
00:06:43,230 --> 00:06:45,570
Firstly, I will not check this check box, okay?
129

130
00:06:45,570 --> 00:06:48,950
And let's focus on here, our console okay?
130

131
00:06:48,950 --> 00:06:51,960
I hit the enter button, as you see now,
131

132
00:06:51,960 --> 00:06:54,140
what it says, your name is 'Volkan',
132

133
00:06:54,140 --> 00:06:56,480
your passowrd is 'one, two, three, four,
133

134
00:06:56,480 --> 00:06:59,090
five, and six', and not selected, right?
134

135
00:06:59,090 --> 00:07:00,493
So let's redo that.
135

136
00:07:01,560 --> 00:07:04,220
Password is okay, so I will run it again,
136

137
00:07:04,220 --> 00:07:06,770
and this time I will check my check box, okay?
137

138
00:07:06,770 --> 00:07:08,257
So again, let's say 'George',
138

139
00:07:10,070 --> 00:07:12,280
'one, two, three, four', okay?
139

140
00:07:12,280 --> 00:07:15,670
And 'remember me', okay, let's check it,
140

141
00:07:15,670 --> 00:07:17,883
and now I will hit the enter button.
141

142
00:07:18,920 --> 00:07:21,080
As you see now, it said your name is 'George',
142

143
00:07:21,080 --> 00:07:23,680
your password is 'one, two, three, four',
143

144
00:07:23,680 --> 00:07:25,070
remember me is selected.
144

145
00:07:25,070 --> 00:07:26,710
This is how we can use check boxes.
145

146
00:07:26,710 --> 00:07:28,710
For now that's all, see you in the next.
