0
1
00:00:04,710 --> 00:00:06,120
<v Volkan>In this lecture we are going to learn</v>
1

2
00:00:06,120 --> 00:00:09,320
how we can create a Spinbox for our application.
2

3
00:00:09,320 --> 00:00:11,380
To do that, what we need to do, like before,
3

4
00:00:11,380 --> 00:00:13,750
we will create another variable here
4

5
00:00:13,750 --> 00:00:16,360
for our Spinbox, and I will name it Year.
5

6
00:00:16,360 --> 00:00:20,620
Year is equal to StringVar, again, okay?
6

7
00:00:20,620 --> 00:00:23,170
And after that, now we can create our Spinbox.
7

8
00:00:23,170 --> 00:00:24,713
But something important about Spinbox.
8

9
00:00:24,713 --> 00:00:27,600
Spinbox is only available in Tkinter.
9

10
00:00:27,600 --> 00:00:30,400
It's not available in Ttk module, okay?
10

11
00:00:30,400 --> 00:00:31,233
Don't forget that.
11

12
00:00:31,233 --> 00:00:33,040
To do that I will say, I will say here,
12

13
00:00:34,530 --> 00:00:38,300
Spinbox, and the first parameter will be root again.
13

14
00:00:38,300 --> 00:00:42,100
And the second one is our numbers.
14

15
00:00:42,100 --> 00:00:45,930
For example, I will create a Spinbox with years.
15

16
00:00:45,930 --> 00:00:49,030
It's from 1990 to 2018.
16

17
00:00:51,259 --> 00:00:53,290
To do that, what I need to say , I need to say from,
17

18
00:00:53,290 --> 00:00:54,600
but something important here.
18

19
00:00:54,600 --> 00:00:57,190
From is a special keyword for Python.
19

20
00:00:57,190 --> 00:00:59,320
That's why we need to use here underscore,
20

21
00:00:59,320 --> 00:01:02,463
From underscore is equal to 1990.
21

22
00:01:03,627 --> 00:01:05,620
Okay, and after that, here,
22

23
00:01:05,620 --> 00:01:10,620
I will say To, for 2018, okay?
23

24
00:01:11,260 --> 00:01:15,170
And after that, what, like Comboboxes, but we said,
24

25
00:01:15,170 --> 00:01:19,470
here, remember use text variable property, right?
25

26
00:01:19,470 --> 00:01:22,403
Here we again say, text variable,
26

27
00:01:25,504 --> 00:01:30,483
text variable is equal to year.
27

28
00:01:32,560 --> 00:01:34,830
Okay, and after that, also,
28

29
00:01:34,830 --> 00:01:38,760
now we can use grid Manager to add our window.
29

30
00:01:38,760 --> 00:01:41,020
Here I say Grid for the Row,
30

31
00:01:41,020 --> 00:01:43,060
I will use again six, okay?
31

32
00:01:43,060 --> 00:01:46,130
Row is equal to six, but for Column I will say,
32

33
00:01:46,130 --> 00:01:49,840
Column is equal to one, okay?
33

34
00:01:49,840 --> 00:01:51,563
If I run my application now,
34

35
00:01:53,220 --> 00:01:58,220
you see our Spinbox is here, and we can make up and down.
35

36
00:01:58,400 --> 00:02:01,490
It's working, but like a Combobox, it's also now,
36

37
00:02:01,490 --> 00:02:04,540
we can edit this value, right?
37

38
00:02:04,540 --> 00:02:08,580
We can see, not numbers, you can also use letters.
38

39
00:02:08,580 --> 00:02:10,230
You can edit with letters.
39

40
00:02:10,230 --> 00:02:12,390
To solve this problem, it's very simple.
40

41
00:02:12,390 --> 00:02:14,640
It's like how we learned before.
41

42
00:02:14,640 --> 00:02:18,130
For Combobox we said, state='readonly', right?
42

43
00:02:18,130 --> 00:02:23,130
And we will use this function for also our Spinbox, okay?
43

44
00:02:24,770 --> 00:02:27,340
Now, we cannot edit our Spinbox.
44

45
00:02:27,340 --> 00:02:28,410
Let's check it.
45

46
00:02:28,410 --> 00:02:29,980
Now, you see we cannot edit it,
46

47
00:02:29,980 --> 00:02:32,020
but, of course, it's working.
47

48
00:02:32,020 --> 00:02:37,020
It's up and down, but now users can't edit our Spinbox.
48

49
00:02:37,020 --> 00:02:38,780
And the last thing about our Spinbox,
49

50
00:02:38,780 --> 00:02:41,500
how we get its value, it's also very, very simple,
50

51
00:02:41,500 --> 00:02:45,040
like before, we come here and we will say,
51

52
00:02:45,040 --> 00:02:50,040
print(year.get()), that's all.
52

53
00:02:50,040 --> 00:02:52,323
If I run my application now, let's see it.
53

54
00:02:54,080 --> 00:02:57,293
Now, here, again, David.
54

55
00:02:58,360 --> 00:03:01,650
And for the Password, one, two, three, four.
55

56
00:03:01,650 --> 00:03:04,320
Remember Me, Male.
56

57
00:03:04,320 --> 00:03:06,260
And here let's say six this time,
57

58
00:03:06,260 --> 00:03:10,370
and this time, let's say, for example, 2000.
58

59
00:03:10,370 --> 00:03:12,450
If I hit Enter button,
59

60
00:03:12,450 --> 00:03:14,270
now let's check our console.
60

61
00:03:14,270 --> 00:03:17,050
As you see here, our name, password, and the gender,
61

62
00:03:17,050 --> 00:03:20,970
and also this is the value from Combobox,
62

63
00:03:20,970 --> 00:03:23,323
and this value is from our Spinbox.
63

64
00:03:24,430 --> 00:03:27,623
This is how we can use Spinboxes for our applications.
64

65
00:03:28,470 --> 00:03:31,107
For now that's all, see you in the next.
