0
1
00:00:04,920 --> 00:00:05,940
<v Volkan>Hello again, in previous lecture</v>
1

2
00:00:05,940 --> 00:00:09,350
what we did we created our find dialog window.
2

3
00:00:09,350 --> 00:00:11,560
Right, it's here Edit, Find,
3

4
00:00:11,560 --> 00:00:13,100
and now what I want to do,
4

5
00:00:13,100 --> 00:00:16,090
I want to create functions for find
5

6
00:00:16,090 --> 00:00:18,500
and also replace button okay.
6

7
00:00:18,500 --> 00:00:19,430
So, how can I do that?
7

8
00:00:19,430 --> 00:00:23,460
To do that first of all I need to use command property
8

9
00:00:23,460 --> 00:00:24,780
these buttons right,
9

10
00:00:24,780 --> 00:00:29,780
and my first find button is here, so I will say here
10

11
00:00:29,890 --> 00:00:34,693
command=equals self.parent.findWords
11

12
00:00:38,920 --> 00:00:39,753
right,
12

13
00:00:39,753 --> 00:00:42,753
and for replace here I will say,
13

14
00:00:42,753 --> 00:00:46,533
command=self.parent.replaceWords.
14

15
00:00:49,700 --> 00:00:54,700
Okay, and let's create these functions here.
15

16
00:00:54,830 --> 00:00:57,893
I will copy this name and come here,
16

17
00:00:59,070 --> 00:01:01,300
end of my page.
17

18
00:01:01,300 --> 00:01:04,570
Okay, its here under find function.
18

19
00:01:04,570 --> 00:01:05,950
Here what I need to say, I say,
19

20
00:01:05,950 --> 00:01:10,950
def findWords, right like before self and args
20

21
00:01:12,260 --> 00:01:15,655
right, and after, also let's create other function
21

22
00:01:15,655 --> 00:01:17,072
def replaceWords.
22

23
00:01:18,908 --> 00:01:20,908
Okay self and also args,
23

24
00:01:22,903 --> 00:01:26,371
and for replace let's say pass now okay,
24

25
00:01:26,371 --> 00:01:30,121
and now let's create our find words function.
25

26
00:01:31,330 --> 00:01:33,830
What I need to do that to create my function
26

27
00:01:33,830 --> 00:01:37,100
first of all I need to go to
27

28
00:01:37,100 --> 00:01:37,933
get
28

29
00:01:39,580 --> 00:01:44,580
find get value of this find input okay,
29

30
00:01:46,500 --> 00:01:50,100
and here, sorry find input enter is here right,
30

31
00:01:50,100 --> 00:01:52,170
so then user enter something here
31

32
00:01:52,170 --> 00:01:55,000
and hit the button I need to get this value right?
32

33
00:01:55,000 --> 00:01:56,060
So how can I do that?
33

34
00:01:56,060 --> 00:01:58,270
This is another class, find dialogue class,
34

35
00:01:58,270 --> 00:02:01,513
and I am creating my function in another class,
35

36
00:02:01,513 --> 00:02:02,757
to do that, what I need to do,
36

37
00:02:02,757 --> 00:02:05,680
here I need to access this entry okay.
37

38
00:02:05,680 --> 00:02:08,253
Find entry and here I will say,
38

39
00:02:10,230 --> 00:02:12,050
find words, right here I will say
39

40
00:02:12,050 --> 00:02:17,050
word=self object name, find, right?
40

41
00:02:17,760 --> 00:02:19,270
This is my object name,
41

42
00:02:19,270 --> 00:02:21,450
and it's widget which widget,
42

43
00:02:21,450 --> 00:02:25,121
find input widget okay and get.
43

44
00:02:25,121 --> 00:02:28,093
Okay, now let's print it out, print word.
44

45
00:02:29,110 --> 00:02:31,210
If I run my application now
45

46
00:02:33,250 --> 00:02:37,400
and Edit, Find, this is my find input.
46

47
00:02:37,400 --> 00:02:38,570
Let's say something like that.
47

48
00:02:38,570 --> 00:02:41,750
Okay and after that I will hit Find button.
48

49
00:02:41,750 --> 00:02:42,663
Now let's see.
49

50
00:02:43,940 --> 00:02:47,790
Close this one, you see our input is here okay.
50

51
00:02:47,790 --> 00:02:51,350
We got our input from this widget.
51

52
00:02:51,350 --> 00:02:54,653
So what I need to do now, I need to create here,
52

53
00:02:55,760 --> 00:03:00,156
I need to find match right?
53

54
00:03:00,156 --> 00:03:02,430
To find match what I need to do here,
54

55
00:03:02,430 --> 00:03:06,270
I will say matches=0, okay.
55

56
00:03:06,270 --> 00:03:10,020
First of all, and after that here I will say if word
56

57
00:03:11,410 --> 00:03:14,631
and after that I need to create a start position
57

58
00:03:14,631 --> 00:03:17,214
start_pos=, and I will say
58

59
00:03:19,980 --> 00:03:22,730
1.0 okay and now what I need to do,
59

60
00:03:24,894 --> 00:03:26,220
I need to create here
60

61
00:03:26,220 --> 00:03:27,970
while True loop okay.
61

62
00:03:29,258 --> 00:03:31,445
For while True what I need to do,
62

63
00:03:31,445 --> 00:03:33,695
I need to say start position,
63

64
00:03:34,568 --> 00:03:35,401
start_pos
64

65
00:03:37,712 --> 00:03:40,712
=self.texteditors.search, okay,
65

66
00:03:42,719 --> 00:03:45,597
search function and here what I need to pass in
66

67
00:03:45,597 --> 00:03:48,680
I need to pass in word start position.
67

68
00:03:50,305 --> 00:03:54,840
Okay and other one is last parameter will be stop index.
68

69
00:03:54,840 --> 00:03:58,950
Okay, stop index is going to be end.
69

70
00:03:58,950 --> 00:04:01,353
Okay, and after that what I need to do,
70

71
00:04:01,353 --> 00:04:04,483
I need to say if not start_position
71

72
00:04:06,519 --> 00:04:09,244
and I will say here break okay,
72

73
00:04:09,244 --> 00:04:12,827
and after that here I will say end position
73

74
00:04:14,275 --> 00:04:15,858
and other variable,
74

75
00:04:16,867 --> 00:04:18,867
okay, end_position=
75

76
00:04:20,767 --> 00:04:22,341
here I will use
76

77
00:04:22,341 --> 00:04:24,508
format okay and {}+{}
77

78
00:04:30,565 --> 00:04:33,507
curly bracket here, and after that c.
78

79
00:04:33,507 --> 00:04:36,813
Now I will say here that format,
79

80
00:04:36,813 --> 00:04:38,230
my start position
80

81
00:04:39,439 --> 00:04:41,522
and len of my word okay,
81

82
00:04:44,760 --> 00:04:46,630
and after that what I need to do here,
82

83
00:04:46,630 --> 00:04:48,670
I will say self.texteditor
83

84
00:04:51,650 --> 00:04:56,120
and now I need to add a tag, tag_add okay,
84

85
00:04:56,120 --> 00:05:00,200
and here I will say match okay, my tag name is match
85

86
00:05:00,200 --> 00:05:04,340
and after here I need to say start_position
86

87
00:05:04,340 --> 00:05:06,327
and end_position.
87

88
00:05:07,750 --> 00:05:09,993
Okay and after that what I need to do,
88

89
00:05:09,993 --> 00:05:12,150
I need to increase my match.
89

90
00:05:12,150 --> 00:05:15,640
marches +=1.
90

91
00:05:15,640 --> 00:05:17,230
Okay, and here what I will say
91

92
00:05:17,230 --> 00:05:21,673
start_position=end_position, okay,
92

93
00:05:22,920 --> 00:05:24,140
and
93

94
00:05:24,140 --> 00:05:27,870
now what I need to do, I say here finally,
94

95
00:05:27,870 --> 00:05:29,540
self.text editor
95

96
00:05:31,500 --> 00:05:34,100
tag_config, okay,
96

97
00:05:34,100 --> 00:05:38,030
and my tag name was match,
97

98
00:05:38,030 --> 00:05:41,300
right, and for foreground,
98

99
00:05:41,300 --> 00:05:42,133
foreground,
99

100
00:05:44,704 --> 00:05:47,153
color is going to be red.
100

101
00:05:47,153 --> 00:05:49,492
That means my fore color is going to be red,
101

102
00:05:49,492 --> 00:05:54,492
and background color is going to be yellow okay
102

103
00:05:54,569 --> 00:05:56,902
background=yellow okay,
103

104
00:05:58,950 --> 00:06:01,400
and now what I did,
104

105
00:06:01,400 --> 00:06:03,930
now I used a text right?
105

106
00:06:03,930 --> 00:06:07,200
The first one is I used a text config
106

107
00:06:07,200 --> 00:06:09,360
and now here what I need to do,
107

108
00:06:09,360 --> 00:06:12,840
I need to say here tag remove okay,
108

109
00:06:12,840 --> 00:06:15,987
and here I will say self.,
109

110
00:06:20,180 --> 00:06:21,550
sorry, it's here, yes.
110

111
00:06:21,550 --> 00:06:23,527
Self.texteditor.tag_remove
111

112
00:06:27,580 --> 00:06:29,320
and I will remove my tag.
112

113
00:06:29,320 --> 00:06:32,530
My tag name was match right,
113

114
00:06:32,530 --> 00:06:35,480
and I will remove it from
114

115
00:06:35,480 --> 00:06:38,570
first 1.0,
115

116
00:06:38,570 --> 00:06:41,530
and until end okay?
116

117
00:06:41,530 --> 00:06:43,340
That's all for find,
117

118
00:06:43,340 --> 00:06:45,330
find words function okay,
118

119
00:06:45,330 --> 00:06:47,597
and even we can run our application now
119

120
00:06:47,597 --> 00:06:49,710
and we can see it.
120

121
00:06:49,710 --> 00:06:50,910
So it's here.
121

122
00:06:50,910 --> 00:06:53,670
Let's create a text here.
122

123
00:06:53,670 --> 00:06:58,453
Hello how are you python?
123

124
00:06:59,600 --> 00:07:01,160
Or something like that okay,
124

125
00:07:01,160 --> 00:07:02,720
and if I say
125

126
00:07:02,720 --> 00:07:05,270
Find let's find here
126

127
00:07:06,590 --> 00:07:07,423
python,
127

128
00:07:08,780 --> 00:07:10,430
and let's say Find
128

129
00:07:10,430 --> 00:07:12,633
you see now we have found the python.
129

130
00:07:13,520 --> 00:07:15,770
Let's create some another
130

131
00:07:15,770 --> 00:07:16,603
python and
131

132
00:07:19,940 --> 00:07:24,640
python, python okay, and again I will say
132

133
00:07:24,640 --> 00:07:27,773
Find and here I will say python.
133

134
00:07:29,964 --> 00:07:31,320
Sorry.
134

135
00:07:31,320 --> 00:07:32,153
Find,
135

136
00:07:35,230 --> 00:07:38,930
python and now let's see it.
136

137
00:07:38,930 --> 00:07:42,680
As you see now it works very well so what I need to do,
137

138
00:07:42,680 --> 00:07:45,900
also I need to create here replace function right?
138

139
00:07:45,900 --> 00:07:48,860
To create replace function what I need to do,
139

140
00:07:48,860 --> 00:07:50,883
I need to come here and say,
140

141
00:07:53,220 --> 00:07:55,007
I will create here
141

142
00:07:55,007 --> 00:07:57,910
a variable, replaceText, okay.
142

143
00:07:57,910 --> 00:07:58,743
Equals, I will say,
143

144
00:07:58,743 --> 00:08:03,610
self., now I say replace.
144

145
00:08:03,610 --> 00:08:07,580
Sorry, self.find and the replaceInput okay.
145

146
00:08:07,580 --> 00:08:09,160
Now I to use replace input,
146

147
00:08:09,160 --> 00:08:11,660
I need to get this value from this input,
147

148
00:08:11,660 --> 00:08:13,970
and after that I will go to use it okay.
148

149
00:08:13,970 --> 00:08:17,556
Get and I know my replace word now
149

150
00:08:17,556 --> 00:08:22,556
and here I will say word=self.find.findinput okay.
150

151
00:08:24,750 --> 00:08:27,610
Word comes from there and get.
151

152
00:08:27,610 --> 00:08:31,420
Okay this word and the other one they are not the same,
152

153
00:08:31,420 --> 00:08:36,020
actually same but in another function okay,
153

154
00:08:36,020 --> 00:08:38,283
and after that what I need to do here,
154

155
00:08:38,283 --> 00:08:40,400
I need create a variable content=
155

156
00:08:40,400 --> 00:08:44,330
I will say self.texteditor.get.
156

157
00:08:44,330 --> 00:08:49,330
I will get all the content from first until end okay,
157

158
00:08:49,520 --> 00:08:51,566
and here what I need to say,
158

159
00:08:51,566 --> 00:08:54,316
enter newValue of this text okay.
159

160
00:08:56,104 --> 00:08:57,437
Content.replace.
160

161
00:08:58,766 --> 00:09:02,644
This is a simple Python function, replace okay,
161

162
00:09:02,644 --> 00:09:06,061
and I will replace word with replaceText.
162

163
00:09:07,507 --> 00:09:11,430
This my existing text and this is new value okay,
163

164
00:09:11,430 --> 00:09:13,610
and here what I need to do,
164

165
00:09:13,610 --> 00:09:16,230
I need to delete my text editor.
165

166
00:09:16,230 --> 00:09:20,640
First I will say self.texteditor.delete,
166

167
00:09:20,640 --> 00:09:25,130
and here from first until end I will delete my editor,
167

168
00:09:25,130 --> 00:09:28,860
and after that I need to insert this new value
168

169
00:09:28,860 --> 00:09:30,170
to my text editor okay.
169

170
00:09:30,170 --> 00:09:35,170
Self.texteditor.insert,
170

171
00:09:35,680 --> 00:09:36,513
and
171

172
00:09:37,760 --> 00:09:41,220
from first, you now how we can do that,
172

173
00:09:41,220 --> 00:09:44,233
and I will insert new value okay,
173

174
00:09:45,940 --> 00:09:48,770
and remember now the new value will replace
174

175
00:09:48,770 --> 00:09:52,960
all the words with word okay.
175

176
00:09:52,960 --> 00:09:55,390
Replace text and I will create a new value.
176

177
00:09:55,390 --> 00:09:58,180
After that I will delete all the text from my editor
177

178
00:09:58,180 --> 00:10:00,733
and after that I will insert this new value
178

179
00:10:00,733 --> 00:10:03,130
into my text editor okay.
179

180
00:10:03,130 --> 00:10:05,083
Now if I run my application,
180

181
00:10:07,120 --> 00:10:08,403
and let's say here,
181

182
00:10:09,700 --> 00:10:14,273
hey python how are you?
182

183
00:10:15,200 --> 00:10:18,960
I hope you are doing well.
183

184
00:10:20,720 --> 00:10:23,940
Let's say again python, okay python
184

185
00:10:23,940 --> 00:10:25,670
because we are going to use this word.
185

186
00:10:25,670 --> 00:10:28,823
So let's copy this one and Edit, Find.
186

187
00:10:30,020 --> 00:10:32,880
Let's say python and instead of python
187

188
00:10:32,880 --> 00:10:34,900
let's say my name okay,
188

189
00:10:34,900 --> 00:10:38,250
and first I will find it, find see,
189

190
00:10:38,250 --> 00:10:41,020
and let's replace it using hey Volkan how are you?
190

191
00:10:41,020 --> 00:10:43,490
I hope you are doing well Volkan.
191

192
00:10:43,490 --> 00:10:46,400
So, this is how we can create find dialog button
192

193
00:10:46,400 --> 00:10:47,700
for our application,
193

194
00:10:47,700 --> 00:10:49,700
For now that's all, see you in the next.
