1
00:00:00,590 --> 00:00:08,180
Hi, welcome back in this video, we will build a desktop app which converts between different currencies,

2
00:00:09,110 --> 00:00:17,450
and it gets the currency from a real time website and its uses of that current currency rates to do

3
00:00:17,450 --> 00:00:19,910
the conversion between different currencies.

4
00:00:20,690 --> 00:00:27,560
So to be able to understand this video, you should have taken the previous video where we built a census

5
00:00:27,560 --> 00:00:31,820
maker app, a very simple app, which looks like this.

6
00:00:33,980 --> 00:00:36,650
So you enter some text on it makes a sentence, all of that.

7
00:00:37,040 --> 00:00:39,380
So now let's make the currency converter.

8
00:00:39,650 --> 00:00:47,360
I'm going to actually duplicate this file copied and pasted in the same directory.

9
00:00:47,840 --> 00:00:49,140
Give it another name.

10
00:00:49,820 --> 00:00:58,670
Currency converter, because now I'm just going to add more codes to this because the two apps are very

11
00:00:58,670 --> 00:00:59,390
similar.

12
00:01:00,260 --> 00:01:04,640
So I'm going to change the title to currency converter.

13
00:01:09,070 --> 00:01:16,030
For this video, all we're going to have is this input box here and then the button and then we get

14
00:01:16,030 --> 00:01:17,230
the outputs in here.

15
00:01:17,440 --> 00:01:22,540
So we're going to answer something like 10 and we're going to get the currency converted into euros.

16
00:01:22,690 --> 00:01:26,110
So for this app, we're going to focus only from USD two euros.

17
00:01:26,140 --> 00:01:32,830
Then in the next video, I'll show you how to add drop down lists here so that you can let the user

18
00:01:32,830 --> 00:01:35,650
convert between any currencies.

19
00:01:35,980 --> 00:01:38,860
For now, let's take things step by step as usual.

20
00:01:41,070 --> 00:01:44,910
So let's have a textbooks here, bottles and the label.

21
00:01:46,740 --> 00:01:51,690
That's the window, that's the layout, that's the text textbooks in here.

22
00:01:52,650 --> 00:01:55,000
The button, let's say, convert.

23
00:01:56,940 --> 00:02:05,100
And we added to the layout and then when the button is clicked, we're going to call a function also

24
00:02:05,100 --> 00:02:08,610
known as a slot in pie kutty.

25
00:02:09,150 --> 00:02:11,730
So this function currently is makes sentence.

26
00:02:12,540 --> 00:02:20,980
So I'm going to replace this with show currency and then provide it to you as well.

27
00:02:21,000 --> 00:02:22,020
Show currency.

28
00:02:22,470 --> 00:02:24,840
No need to call it just mentioned.

29
00:02:24,840 --> 00:02:26,970
It's inside the connect method.

30
00:02:27,330 --> 00:02:34,230
So show currency, show currency and then we give input, text, text, text, text points to this.

31
00:02:35,430 --> 00:02:36,390
Input books.

32
00:02:36,570 --> 00:02:39,870
Then we extract the actual value of that, the user enters.

33
00:02:40,290 --> 00:02:41,670
Let's say it is 10.

34
00:02:42,390 --> 00:02:44,670
So input tax will be equal to 10.

35
00:02:45,570 --> 00:02:48,660
Then what should we do to that value?

36
00:02:49,890 --> 00:02:52,650
Well, the input tax is going to be.

37
00:02:55,630 --> 00:02:59,980
Multiplied by the current exchange rate.

38
00:03:02,830 --> 00:03:11,590
And we're going to get the exchange rate from a function which we built previously in the course using

39
00:03:12,100 --> 00:03:13,210
beautiful soup.

40
00:03:14,200 --> 00:03:22,960
So if you didn't take that video is the ends and near the end of browser automation and the subscription

41
00:03:22,970 --> 00:03:23,380
section.

42
00:03:24,310 --> 00:03:28,450
So this was the code of ads, a function that we need.

43
00:03:31,620 --> 00:03:37,530
Also, we need the imports here, so I'm going to copy that and paste it won't talk in here.

44
00:03:39,680 --> 00:03:47,330
So we import some beautiful soup in this line, we import requests, and then this function gets an

45
00:03:47,330 --> 00:03:54,680
increase in all its currency value as arguments, and then it constructs this URL.

46
00:03:54,980 --> 00:04:03,680
So the URL is the URL that points to the excretes website, which gives us current currencies.

47
00:04:04,550 --> 00:04:14,030
So for example, if I gave this URL and I go to the browser, I answer it here and replace this port

48
00:04:15,500 --> 00:04:22,850
with from USD and to euro and enter.

49
00:04:23,120 --> 00:04:25,100
And it takes me to this page.

50
00:04:25,190 --> 00:04:27,680
So that's the current rate.

51
00:04:27,680 --> 00:04:30,920
As I am speaking, it changes every minute or so.

52
00:04:32,540 --> 00:04:39,410
So Python then is going to give a source code or that you URL of that page and then it's going to be

53
00:04:39,410 --> 00:04:49,160
extracting that elements of the email of that page where that value is, where that rate is.

54
00:04:49,790 --> 00:04:50,540
This one in here.

55
00:04:51,470 --> 00:04:52,230
So we did that.

56
00:04:52,270 --> 00:04:53,540
We built that already.

57
00:04:53,780 --> 00:04:58,550
And then we claim that value because it says this euro string.

58
00:04:58,550 --> 00:04:59,660
So we clean that out.

59
00:05:00,020 --> 00:05:05,270
We remove that euro and we end up with a float, which is going to be this number only.

60
00:05:05,630 --> 00:05:15,530
So this function, what this does is it returns the float, the rates, currency rate between any two

61
00:05:15,530 --> 00:05:16,790
exchange rates.

62
00:05:17,990 --> 00:05:25,070
So since we said that for this video, we're going to work only on exchanging from USD to euro.

63
00:05:25,670 --> 00:05:30,860
I'm just going to give them some default values for now.

64
00:05:31,070 --> 00:05:34,490
In the next video, we're going to have this completely dynamic.

65
00:05:35,120 --> 00:05:38,630
So for now, we have from USD two euros.

66
00:05:39,320 --> 00:05:50,000
And so back to our show currency function, no, this function is responsible to interact with our widgets,

67
00:05:50,210 --> 00:05:52,510
and this function is another thing.

68
00:05:52,580 --> 00:05:52,820
See?

69
00:05:52,910 --> 00:05:54,470
So this calculates stuff.

70
00:05:54,470 --> 00:06:02,330
It's processes external calculations, as it does in this case, it does a web scraping.

71
00:06:02,570 --> 00:06:09,830
This is not related to our graphical user interface, so we simply call this function in here now.

72
00:06:10,490 --> 00:06:13,220
So let's say.

73
00:06:14,960 --> 00:06:24,140
The rates, a sequel to get currency, and that's it, and then input tax times the rate, so let's

74
00:06:24,140 --> 00:06:31,510
say the user enters 10, we multiply that by the rate, which is this one, for example.

75
00:06:34,330 --> 00:06:35,440
And then we get.

76
00:06:37,050 --> 00:06:46,020
The ultimate so let's call this the ultimate, a sequel to that and then involved with labor.

77
00:06:47,580 --> 00:06:52,140
We provide the ultimate value of this one in here.

78
00:06:53,980 --> 00:06:55,230
Yes, so let's try this.

79
00:06:55,740 --> 00:07:03,120
First, I need to install this beautiful soup, which you can install by using PIP.

80
00:07:03,120 --> 00:07:10,590
Install Beauty for soup for beautiful soup for.

81
00:07:14,460 --> 00:07:17,650
I have a typo beauty, I'm missing an eye.

82
00:07:18,240 --> 00:07:24,420
Beautiful suit for the packages installed, and then we also need to install requests.

83
00:07:26,500 --> 00:07:26,840
Right.

84
00:07:26,860 --> 00:07:30,940
Once you install those, you're ready to run this code.

85
00:07:33,400 --> 00:07:41,050
So answer 10 press converts and the window disappears, and when that happens, it means you have an

86
00:07:41,050 --> 00:07:41,350
error.

87
00:07:41,500 --> 00:07:48,730
So look at your terminal and you see here I have an error in this line line 20.

88
00:07:50,120 --> 00:07:52,440
Twenty is here outputs.

89
00:07:53,420 --> 00:07:56,410
It says that it cannot multiply sequence by nonsense.

90
00:07:56,900 --> 00:08:00,410
That is because inputs text a string.

91
00:08:01,190 --> 00:08:03,590
So when the user enters 10.

92
00:08:06,490 --> 00:08:12,880
And here, Python will read it as a string, so what you want to do is you want to convert it into a

93
00:08:12,880 --> 00:08:13,480
float.

94
00:08:16,470 --> 00:08:21,210
And then you can use it to do multiplication and other math operations.

95
00:08:21,390 --> 00:08:22,140
So run again.

96
00:08:23,010 --> 00:08:23,910
And there's 10 here.

97
00:08:23,910 --> 00:08:26,910
Convert another error.

98
00:08:27,210 --> 00:08:29,520
Let's see this time it's in line 21.

99
00:08:32,429 --> 00:08:34,980
So ultimately will set texts, altitudes.

100
00:08:36,210 --> 00:08:47,350
This time it says that South Texas, as you see here, it accepts a screen as arguments, but argument

101
00:08:47,380 --> 00:08:48,960
was followed.

102
00:08:50,340 --> 00:08:58,020
So we have the floats here, which is a product of that times.

103
00:08:58,020 --> 00:09:04,260
That's so for this to work with sets text, you need to convert it into a string.

104
00:09:08,560 --> 00:09:09,310
So we're on again.

105
00:09:11,040 --> 00:09:13,290
Triton converts.

106
00:09:14,680 --> 00:09:15,730
And is the ultimate.

107
00:09:16,000 --> 00:09:22,540
So 10 euros is equal to eight point eight dollars.

108
00:09:23,410 --> 00:09:26,830
And of course, you can run this up using a round function.

109
00:09:29,830 --> 00:09:35,500
And have, for example, to numbers often the decimal point run.

110
00:09:37,510 --> 00:09:41,410
Twenty converts, and now it looks better.

111
00:09:41,980 --> 00:09:44,170
Six, six after the decimal points.

112
00:09:48,630 --> 00:09:51,720
And that's our scripts for now.

113
00:09:53,430 --> 00:10:02,160
So we built what we planned to build, and that was making an app which converts between euros and dollars

114
00:10:02,430 --> 00:10:09,900
now to make this even more advanced and let the user select what currencies they want to convert from

115
00:10:09,900 --> 00:10:15,420
and to, we need to use drop dropdown lists widgets.

116
00:10:16,710 --> 00:10:19,380
So we're going to do that in the next video.

117
00:10:19,380 --> 00:10:26,070
We're going to add to dropdown lists widgets before these other widgets.

118
00:10:26,340 --> 00:10:27,510
So sue in the next with you.

