Write a GUI program using Python tkinter module that calculates a car’s gas mileage. The program’s window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. Use the kilo_converter.py program as a design reference for this assignment. When a Calculate MPG button is clicked, the program should display the number of miles that the car may be driven per gallon of gas. Use the Python tkinter module for this Python program. Use the following formula to calculate miles-per-gallon: MPG = miles/gallons kilo_converter.py program:
Write a GUI program using Python tkinter module that calculates a car’s gas mileage. The program’s window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. Use the kilo_converter.py program as a design reference for this assignment. When a Calculate MPG button is clicked, the program should display the number of miles that the car may be driven per gallon of gas. Use the Python tkinter module for this Python program. Use the following formula to calculate miles-per-gallon: MPG = miles/gallons kilo_converter.py program:
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Write a GUI program using Python tkinter module that calculates a car’s gas mileage. The program’s window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. Use the kilo_converter.py program as a design reference for this assignment. When a Calculate MPG button is clicked, the program should display the number of miles that the car may be driven per gallon of gas. Use the Python tkinter module for this Python program. Use the following formula to calculate miles-per-gallon:
MPG = miles/gallons
kilo_converter.py program:

Transcribed Image Text:Program 15-9 (kilo_converter.py)
1 # This program converts distances in kilometers
2 # to miles. The result is displayed in an info
3 # dialog box.
4
import tkinter
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class KiloConverterGUI:
definit__(self):
#Create the main window.
self.main_window= tkinter.Tk ()
# Create two frames to group widgets.
self.top_frame= tkinter. Frame(self.main_window)
self.bottom_frame = tkinter. Frame(self.main_window)
#Create the widgets for the top frame.
self.prompt_label= tkinter.Label(self.top_frame, \
text='Enter a distance in kilometers:')
self.kilo_entry tkinter.Entry(self.top_frame, \
# Pack the top frame's widgets.
self.prompt_label.pack (side='left')
self.kilo_entry.pack (side='left')
#Create the button widgets for the bottom frame.
self.calc_button tkinter. Button(self.bottom_frame, \
text='Convert', \
command-self.convert)
self.quit_button = tkinter. Button(self.bottom_frame, \
text='Quit', \
command=self.main_window.destroy)
width=10)
#Pack the buttons.
self.calc_button.pack (side="left')
self.quit_button.pack (side='left')
#Pack the frames.
self.top_frame.pack()
self.bottom_frame.pack()
#Enter the Tkinter main loop.
tkinter.mainloop()
# The convert method is a callback function for
#the Calculate button.
def convert (self):
# Get the value entered by the user into the
#kilo_entry widget.
kilo float (self.kilo_entry.get())
# Convert kilometers to miles.
miles kilo * 0.6214
# Display the results in an info dialog box.
tkinter.messagebox.showinfo('Results', \
str(kilo) + kilometers is equal to +\
str(miles) + miles.')
'
60
61
62 # Create an instance of the KiloConverterGUI class.
63 kilo_conv=KiloConverterGUI ()
Page 122
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY