Search code examples
python-3.xtkintergraphical-programming

Gui programming in python tkinter


import tkinter as tk
weight = tk(float(input("Enter your weight in kgs : ")))
height = tk(float(input("Enter your height cms : ")))
bmi = weight/ (height/100)**2

if bmi <= 17.5:
    tk(print("You are severely underweight:"))
elif bmi <= 18.5:
    tk(print("You are underweight:"))
elif bmi  <= 25:
    tk(print("You have Normal weight"))
elif bmi <= 30:
    tk(print("You are overweight"))
elif bmi <= 40:
    tk(print("You are obese"))
else:
    tk(print("You are severely obese"))

tk(print(bmi))

m.mainloop()

Enter your weight in kg: 85

Traceback (most recent call last):
  File "/Users/damanbir singh/Desktop/ffc.py", line 2, in <module>
    weight = tk(float(input("Enter your weight in kgs : ")))
TypeError: 'module' object is not callable

I'm trying to do GUI programming without any knowledge I have got an error.


Solution

  • Well, for starters, everything you did is quite wrong. You should go and read some documentation before trying it out. Putting print and input statements after tk() isn't the way to go.

    Here's some useful information.