How to Divide the Contents of a TkInter Entry With a Number?

家住魔仙堡 提交于 2021-02-20 05:14:01

问题


I've been trying to figure out how to divide the contents of a TkInter entry box with a number (a float, to be precise). I looked it up on Google, and I found nothing that answered my question, other than doing .get() for getting a number from a entry. I want to have a number already there (or have a static variable) that I can divide to get the results I need.

Any help would be appreciated! Thanks a billion!! :D

P.S. Here's the website results I saw before I posted this question:

Results of search


回答1:


To divide an input from entrybox using float: if you want entrybox to be in int form not float use int()

num = 3.0
temp = float(entrybox.get())
divided = temp / num

or divide/split a string:

temp = entrybox.get().split(" ")# enter what to split by in speech marks


来源:https://stackoverflow.com/questions/45019798/how-to-divide-the-contents-of-a-tkinter-entry-with-a-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!