0
1
00:00:04,361 --> 00:00:05,194
<v Narrator>In this lecture,</v>
1

2
00:00:05,194 --> 00:00:06,370
we are going to learn how we can
2

3
00:00:06,370 --> 00:00:08,343
create a scrollbar for our applications,
3

4
00:00:08,343 --> 00:00:11,150
as you see here, we have  here a text editor
4

5
00:00:11,150 --> 00:00:14,690
and we have a really quite long text.
5

6
00:00:14,690 --> 00:00:16,667
As you seen now, I scroll up and down,
6

7
00:00:16,667 --> 00:00:20,780
but of course this is, I am using my mouse now
7

8
00:00:20,780 --> 00:00:22,745
and we don't have a scrollbar here.
8

9
00:00:22,745 --> 00:00:26,940
So, we need to create our scrollbar for this application.
9

10
00:00:26,940 --> 00:00:30,763
Scrollbar, we can use scrollbar for text editor,
10

11
00:00:30,763 --> 00:00:35,763
treeview or canvas or listbox widget and so on.
11

12
00:00:35,789 --> 00:00:39,041
And it's not only for the text editor widget, okay?
12

13
00:00:39,041 --> 00:00:42,520
And so what we need to do to create a scrollbar
13

14
00:00:42,520 --> 00:00:45,400
and of course we can create a vertical scrollbar
14

15
00:00:45,400 --> 00:00:47,830
or horizontal scrollbar, for our widgets.
15

16
00:00:47,830 --> 00:00:49,360
So, what we need to do here,
16

17
00:00:49,360 --> 00:00:51,980
I will create, by the way, our text editor, it's here.
17

18
00:00:51,980 --> 00:00:54,526
What I need to do if I want to create a scrollbar,
18

19
00:00:54,526 --> 00:00:57,397
I will create here a variable
19

20
00:00:57,397 --> 00:01:00,950
Scroll is equal to ttk module and I need
20

21
00:01:00,950 --> 00:01:03,700
to say here "scrollbar" and our
21

22
00:01:03,700 --> 00:01:05,085
first parameter will be "root"
22

23
00:01:05,085 --> 00:01:08,090
and second one is our "orient".
23

24
00:01:08,090 --> 00:01:12,133
For orient, I will say, in this case, vertical, okay?
24

25
00:01:14,090 --> 00:01:15,550
And after that what I need to do now,
25

26
00:01:15,550 --> 00:01:18,970
here I need to make connections between my widgets,
26

27
00:01:18,970 --> 00:01:23,970
scrollbar and for my text box and for connection,
27

28
00:01:24,066 --> 00:01:28,637
I will say "command" is equal to "textbox.yview".
28

29
00:01:30,393 --> 00:01:33,889
This is for without parentheses, by the way.
29

30
00:01:33,889 --> 00:01:36,840
You need to also create this connection
30

31
00:01:36,840 --> 00:01:40,920
for our text box two and for scrollbar, is like that.
31

32
00:01:40,920 --> 00:01:43,230
And after, what I need to do here, now I will
32

33
00:01:43,230 --> 00:01:46,220
create a scroll, I need to use geometry manager
33

34
00:01:46,220 --> 00:01:49,717
and for my scrollbar, I will say "scroll.grid".
34

35
00:01:54,210 --> 00:01:59,210
And here, I will say "row" is equal to "0, column=1"
35

36
00:02:00,245 --> 00:02:04,050
because I already used column zero for my text box.
36

37
00:02:04,050 --> 00:02:08,680
Okay, and after that I want to use "sticky" property
37

38
00:02:08,680 --> 00:02:10,887
and for the sticky I will use "N+S".
38

39
00:02:14,315 --> 00:02:17,856
And what is next, we need to make connections
39

40
00:02:17,856 --> 00:02:22,540
also for our text box, I will say "textBox.config"
40

41
00:02:22,540 --> 00:02:24,353
and here I will say,
41

42
00:02:25,516 --> 00:02:30,516
"yscrollcommand" is equal to "scroll.set".
42

43
00:02:33,658 --> 00:02:36,182
Okay, and now it's ready.
43

44
00:02:36,182 --> 00:02:38,280
If I run my application now
44

45
00:02:41,008 --> 00:02:43,610
and here our scroll bar is here,
45

46
00:02:43,610 --> 00:02:46,330
by the way, I will paste my text.
46

47
00:02:46,330 --> 00:02:48,369
As you seen now, our text is here and our
47

48
00:02:48,369 --> 00:02:52,131
scrollbar is here, we can go up and down now,
48

49
00:02:52,131 --> 00:02:54,879
we can make up and down and it's working.
49

50
00:02:54,879 --> 00:02:58,220
And, as I said, you can use scrollbar for
50

51
00:02:58,220 --> 00:03:02,151
other widgets like canvas, listbox,
51

52
00:03:02,151 --> 00:03:05,750
treeview and textbox and so on.
52

53
00:03:05,750 --> 00:03:08,453
for now, that's all, see you in the next.
