【问题标题】:Gui programming in python tkinterpython tkinter中的GUI编程
【发布时间】:2021-10-08 13:07:26
【问题描述】:
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()

以公斤为单位输入您的体重: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

我正在尝试在没有任何知识的情况下进行 GUI 编程,但我遇到了一个错误。

【问题讨论】:

  • 你不能只输入你希望能工作的代码。您应该从学习 tkinter 教程开始,以便学习基础知识。

标签: python-3.x tkinter graphical-programming


【解决方案1】:

嗯,首先,你所做的一切都是错误的。在尝试之前,您应该去阅读一些文档。在 tk() 之后放置 print 和 input 语句不是可行的方法。

Here's some useful information.

【讨论】:

  • 兄弟,我怎样才能获得一些项目来增强我的个人资料。
  • 同意,但这确实是一个答案,例如,您没有准确回答为什么会出现错误或应该改进什么? @DSG 我也建议使用教程,对于初学者来说可能更容易理解:tutorial series by Codemy.com on YouTube
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-22
  • 1970-01-01
相关资源
最近更新 更多