469,358 Members | 1,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

BMI Calculator with GUI

18
Alright.. I have the basic interface of the Body Mass Index worked out. However, I dont know how to get the feet,inches, and weight to be be multiplied:
Expand|Select|Wrap|Line Numbers
  1. (w / (h * 12 + x) * (h * 12 + x)) * 703)
Here is my code for the BMI Calculator:
Expand|Select|Wrap|Line Numbers
  1. from graphics import *
  2. from math import *
  3. def main():
  4.     win = GraphWin("BMI Calculator", 800, 600)
  5.     win.setCoords(-2.0, -2.0, 11, 11.5)
  6.     Text(Point(5,5), "Feet:").draw(win)
  7.     Text(Point(5,3), "Inches:").draw(win)
  8.     Text(Point(5,1), "Weight:").draw(win)
  9.     h = Entry(Point(7,5), 5)
  10.     h.setText("0")
  11.     h.draw(win)
  12.     x = Entry(Point(7,3), 5)
  13.     x.setText("0")
  14.     x.draw(win)
  15.     w = Entry(Point(7,1), 5)
  16.     w.setText("0")
  17.     w.draw(win)
  18.  
  19.    # Create Function Box
  20.     Text(Point(3, 0), "BMI").draw(win)
  21.     stng = Entry(Point(4,0), 7)
  22.     stng.setText("0")
  23.     stng.draw(win)
  24.  
  25.     output = Entry(Point(4,1), "" )
  26.     output.draw(win)
  27.     button = Text(Point(1.5,2.0), "Convert")
  28.     button.draw(win)
  29.     Rectangle(Point(1,1.5), Point(2,2.5)).draw(win)
  30.  
  31.     ## wait for a mouse click
  32.     win.getMouse()
  33.  
  34.     ## convert input
  35.     h =  float(eval(h.getText()))
  36.     x =  float(eval(x.getText()))
  37.     w =  float(eval(w.getText()))
  38.  
  39.  
  40.  
  41.  
  42.  
  43.     ## display output and change button
  44.     BMI
  45.  
  46.  
  47.     ## wait for click and then quit
  48.     win.getMouse()
  49.     win.close()
  50.  
  51.     main()
  52.  
So I guess I now prompt my question.. How can I get an output box that (using the calculation that I put above) "prints" the answer..
Mar 14 '07 #1
0 1412

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by mwh | last post: by
6 posts views Thread by Rafael | last post: by
3 posts views Thread by Paul | last post: by
3 posts views Thread by PieMan2004 | last post: by
24 posts views Thread by firstcustomer | last post: by
Deathwing
5 posts views Thread by Deathwing | last post: by
3 posts views Thread by mandy335 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.