Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the assignment template file you will find an outline for an object-oriented GUI that allows you to computes a Body Mass Index (BMI) .

In the assignment template file you will find an outline for an object-oriented GUI that allows you to computes a Body Mass Index (BMI). The GUI has eight widgets: three labels, three entries, and two buttons. The labels appear next to each of the entries and provide information about what is contained in the entry. The first two entries are for the user to enter his/her height and weight (in inches and pounds respectively). Below these labels and entries there is a button "Compute BMI" that takes the information in the height and weight entries, computes the BMI using the information (see the formula below), and places the result into the entry immediately below the "Compute BMI" button. Finally, the "Clear All" button clears all three entries. The constructor for the class is complete and should not be changed.

write the three other methods of the class:

make_widgets: the method places the labels, entries, and buttons into the GUI as described above and seen below. It also attaches the handlers the appropriate buttons, that is, the compute handler to the "Compute BMI" button and the clear handler to the "Clear All" button. I highly recommend that you use grid as the geometry manager since forming a reasonable-looking GUI with pack is very challenging. Note that although pack is used in the constructor, you will be able to use grid without problems in writing the GUI.

compute: the event handler retrieves whatever the user has typed into the height entry and whatever the user has typed into the weight entry, converts both into numbers, and computes the BMI using the formula weight * 703 / height ** 2. It then places the computed value into the BMI entry. If the user enters something into either the height or weight entries that cannot be evaluated as a number, the handler places the string 'INVALID #' into the BMI entry.

clear: this event handler clears all three entries, meaning the entires in which the height, weight, and BMI are stored.

Template DO NOT UPDATE THE CONSTRUCTOR ONLY MAKE_WIDGETS, CLEAR, AND COMPUTE:

image text in transcribed

Output:

image text in transcribed

If the user presses the Compute BMI button, the following information appears in the BMI entry:

image text in transcribed

If the user enters an invalid number into either (or both) of the height or weight entries and then presses the Compute BMI button such as the following:?

image text in transcribed

The user can then press Clear All to clear the entries:

image text in transcribed

9 from tkinter import * 1 class BMI(Frame): Body Mass Index app' # Do not change this method def _init__(self,parent-None): constructor Frame.__init__(self, parent) # Note that you should use grid in make-widgets # The use of pack here will not cause a problem self.pack() BMI.make widgets(self) # write this method def make widgets(self): pass # write this method def clear(self): pass # write this method def compute(self): pass

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

What are the categories protected under copyright laws?

Answered: 1 week ago