0
1
00:00:04,950 --> 00:00:05,783
<v Instructor>Hello again.</v>
1

2
00:00:05,783 --> 00:00:06,820
In previous lecture to what we did,
2

3
00:00:06,820 --> 00:00:09,560
let me run our project first.
3

4
00:00:09,560 --> 00:00:12,280
And here we updated our status bar, right?
4

5
00:00:12,280 --> 00:00:13,113
Here.
5

6
00:00:13,113 --> 00:00:15,490
We are displaying now how many letters
6

7
00:00:15,490 --> 00:00:17,610
and how many words we have, right?
7

8
00:00:17,610 --> 00:00:18,550
It's here.
8

9
00:00:18,550 --> 00:00:20,710
So, what I want to do?
9

10
00:00:20,710 --> 00:00:24,760
I want to create functions for my menu items, okay?
10

11
00:00:24,760 --> 00:00:29,760
And for the first one we are going to create new menu item,
11

12
00:00:30,522 --> 00:00:33,401
function for new menu item.
12

13
00:00:33,401 --> 00:00:34,516
What we need to do here?
13

14
00:00:34,516 --> 00:00:36,040
I need to find my new item.
14

15
00:00:36,040 --> 00:00:39,620
New is here and I will create here a command property.
15

16
00:00:39,620 --> 00:00:43,510
Here I will say command equals self.parent.newFile, okay?
16

17
00:00:43,510 --> 00:00:48,016
Here I will say command equals self.parent.newFile, okay?
17

18
00:00:48,016 --> 00:00:52,428
Here I will say command equals self.parent.newFile, okay?
18

19
00:00:52,428 --> 00:00:57,428
Here I will say command equals self.parent.newFile, okay?
19

20
00:00:58,684 --> 00:01:00,510
I am going to use parent
20

21
00:01:00,510 --> 00:01:04,560
because I will create this function in my main application.
21

22
00:01:04,560 --> 00:01:05,393
Okay?
22

23
00:01:05,393 --> 00:01:06,750
So here what I need to do?
23

24
00:01:06,750 --> 00:01:07,950
I need to copy this name
24

25
00:01:08,790 --> 00:01:10,663
and go here.
25

26
00:01:11,880 --> 00:01:14,940
Class main application and I will create my function.
26

27
00:01:14,940 --> 00:01:17,350
We can create it here actually.
27

28
00:01:17,350 --> 00:01:19,690
Before changed.
28

29
00:01:19,690 --> 00:01:21,290
Here what I will say?
29

30
00:01:21,290 --> 00:01:25,110
I will create def and newFile function,
30

31
00:01:25,110 --> 00:01:28,053
self and also let's use *args.
31

32
00:01:29,110 --> 00:01:31,890
Here what I need to do before creating my function?
32

33
00:01:31,890 --> 00:01:35,486
I need to create a variable here, a global variable.
33

34
00:01:35,486 --> 00:01:37,000
URL variable.
34

35
00:01:37,000 --> 00:01:39,186
To do that here what I will do?
35

36
00:01:39,186 --> 00:01:41,722
I will go to here, top,
36

37
00:01:41,722 --> 00:01:45,634
and I will create here a global url variable
37

38
00:01:45,634 --> 00:01:48,134
and I will name it url equals.
38

39
00:01:49,019 --> 00:01:50,640
And for now it's empty, okay?
39

40
00:01:50,640 --> 00:01:52,200
It is null.
40

41
00:01:52,200 --> 00:01:54,430
And after here what I need to do?
41

42
00:01:54,430 --> 00:01:55,973
I need to find my function.
42

43
00:01:57,490 --> 00:02:00,060
My function is here, right?
43

44
00:02:00,060 --> 00:02:02,603
First I will say global url.
44

45
00:02:04,400 --> 00:02:07,560
After that, here I will use try and except.
45

46
00:02:07,560 --> 00:02:12,393
Try and after that here I will say except, okay?
46

47
00:02:13,690 --> 00:02:15,677
For except I will say pass.
47

48
00:02:17,202 --> 00:02:18,710
Actually we are not going to use except,
48

49
00:02:18,710 --> 00:02:20,730
only try we are going to use.
49

50
00:02:20,730 --> 00:02:22,150
Here what I need to do?
50

51
00:02:22,150 --> 00:02:25,820
I will say if I want to create a new file what I need to do.
51

52
00:02:25,820 --> 00:02:30,820
First of all, I need to say here my url again equals empty.
52

53
00:02:30,940 --> 00:02:33,635
First of all, I need to say here my url again equals empty.
53

54
00:02:33,635 --> 00:02:34,468
It's already empty now, I know,
54

55
00:02:34,468 --> 00:02:37,250
but we are going to use this url variable
55

56
00:02:37,250 --> 00:02:38,680
in other functions.
56

57
00:02:38,680 --> 00:02:43,680
So that means it cannot be empty sometimes, okay?
57

58
00:02:44,280 --> 00:02:47,851
So first of all, when we create a new file,
58

59
00:02:47,851 --> 00:02:50,360
a new file means we didn't save it.
59

60
00:02:50,360 --> 00:02:52,210
So when we save our file,
60

61
00:02:52,210 --> 00:02:55,230
we will also create a url variable for our file.
61

62
00:02:55,230 --> 00:02:57,653
For the new file, we didn't save it, okay?
62

63
00:02:58,540 --> 00:02:59,373
It's a new file.
63

64
00:02:59,373 --> 00:03:03,220
That's why this file doesn't have any url, okay?
64

65
00:03:03,220 --> 00:03:04,767
And here we also...
65

66
00:03:04,767 --> 00:03:08,100
When your create a new file what you are going to do?
66

67
00:03:08,100 --> 00:03:13,100
Actually you delete all text from your text editor, okay?
67

68
00:03:13,410 --> 00:03:14,980
And here we are going to do it.
68

69
00:03:14,980 --> 00:03:19,980
I will say self.texteditor.delete and from the first one,
69

70
00:03:21,210 --> 00:03:23,133
first character until end.
70

71
00:03:24,240 --> 00:03:26,530
And here I will say end.
71

72
00:03:26,530 --> 00:03:28,173
Let me run our application.
72

73
00:03:29,720 --> 00:03:31,620
I will show you what we are going to do
73

74
00:03:31,620 --> 00:03:33,270
and you will understand it better.
74

75
00:03:33,270 --> 00:03:34,390
Our function.
75

76
00:03:34,390 --> 00:03:38,100
Here for example, you are here and you are doing something.
76

77
00:03:38,100 --> 00:03:39,910
This is your text editor.
77

78
00:03:39,910 --> 00:03:41,720
You want to create a new file.
78

79
00:03:41,720 --> 00:03:43,007
What you are going to do?
79

80
00:03:43,007 --> 00:03:45,960
You are going to click File and you say.
80

81
00:03:45,960 --> 00:03:50,010
You click New and now we delete everything.
81

82
00:03:50,010 --> 00:03:52,390
And we created a new file.
82

83
00:03:52,390 --> 00:03:56,820
This is how new file function will work for us, okay?
83

84
00:03:56,820 --> 00:03:59,540
And actually that's all for the file.
84

85
00:03:59,540 --> 00:04:01,690
Next lesson what we are going to do?
85

86
00:04:01,690 --> 00:04:04,030
We are going to create the function
86

87
00:04:04,030 --> 00:04:07,940
for this open menu item, okay?
87

88
00:04:07,940 --> 00:04:08,940
For now that's all.
88

89
00:04:08,940 --> 00:04:09,940
See you in the next!
