我如何获取用户的输入并将答案显示到标签中,例如在 tkinter 中?
我正在尝试使用 Tkinter 创建一个基本计算器。
基本上,用户输入圆的半径,然后它应该打印出圆的直径、周长和面积。
我一直在尝试 Entry()
和 .get()
但我还没有发现任何关于我的问题的信息。
多谢。
I'm trying to create a basic calculator with Tkinter.
Basically the user types in the radius of a circle and then it should print out the diameter, circumference and the area of the circle.
I've been experimenting with Entry()
and .get()
but yeah i haven't found out anything yet about my problem.
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找这样的东西:
然后,如果您运行
radius.get()
,您将获得当前条目。您还可以使用跟踪来跟踪输入何时发生变化: https://www. geeksforgeeks.org/tracing-tkinter-variables-in-python/
我建议您查看学习 tkinter 的在线教程以获取更多信息。当我开始 tkinter 时,这个教程对我帮助很大: https://www.pythontutorial.net/tkinter/
I think you're looking for something like this:
Then if you run
radius.get()
you get the current entry.You can also track when the input changes with trace: https://www.geeksforgeeks.org/tracing-tkinter-variables-in-python/
I recommend taking a look at an online tutorial for learning tkinter to get more information. This tutorial helped me a lot when I started tkinter: https://www.pythontutorial.net/tkinter/