
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
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 nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images

Knowledge Booster
Similar questions
- A county collects property taxes on the assessment value of property, which is 60 percent of the property’s actual value. If an acre of land is valued at $10,000, its assessment value is $6,000. The property tax is then $0.64 for each $100 of the assessment value. The tax for the acre assessed at $6,000 will be $38.40. In Python, design a GUI program that displays the assessment value and property tax when a user enters the actual value of a property. Use a class to implement the GUI window display and functionality.arrow_forwardIn Python with comments please Celsius to FahrenheitWrite a GUI program that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, then see the equivalent Fahrenheit temperature. Use the following formula to make the conversion: F=9/5C+32arrow_forwardA variable should be used to store the results of an application's calculation. What do you think?arrow_forward
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

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