Hi.
This is my code to build the average speed calculator app, so that's an overview of my code.
If you want to stop the video and take a look.
And let me quickly explain what it does.
So I imported all the widgets in here, and since I created a class inheriting from Q widgets here,
I instantiated the Q widget parent class.
I set the title for the app.
Then I used a grid layout.
Here I created some widgets such as a distance label widget Q Line edit.
Which corresponds to that and that.
And then the other label and the text box here as well.
Then I've got the combo box with these two lines in here, which reflects to that combo box there.
Then next there's the button with these two lines.
And then the empty label, which is below the button.
Then I added all these widgets to the grid layout.
And then I added the grid layout to self.
So self is the widget, the queue widget, the main widget.
Then I have the calculate.
Methods.
First I the distance and time from self that distance input and self that time input the two text boxes
that I created up here.
I made sure that these are converted to float.
Otherwise the type all the values entered by the user will be read as strings.
Then I calculated the speed using those two.
There you go.
Maybe some space between the two.
Then I check what the user has selected in the combo box if they selected metric kilometers here.
Then I applied this.
Rounding to the speed.
I calculate it's in here.
Otherwise I added this coefficient, so I multiply the speed by this coefficient to convert it into
miles per hour.
Perhaps you did it differently.
It doesn't matter if we both have the same results more or less.
So that's the result label.
So I set the text to this invisible label and that will display average speed and the units after that.
And these are the routine calls which initialize the application.
And yeah, that's it.
Thanks for following and I'll talk to you in the next day with more code.
See you there.