【发布时间】:2015-01-28 18:36:43
【问题描述】:
我正在尝试在 python tkinter 中制作一个基本的计算器。我制作了一个输入框,用户可以在其中输入他的第一个数字。但是,如果有人输入的不是数字而是文本怎么办?我的问题是,如何使您只能在输入框中输入数字,或者如何忽略普通字母。
顺便说一下,我的半成品代码在这里:
from tkinter import *
okno = Tk()
okno.title("Kalkulačka")
okno.geometry("400x500")
firstLabel = Label(text="Vaše první číslo").place(x=25, y=25)
firstInput = Entry(text="Vaše první číslo").place(x=130, y=25, width=140)
buttonplus = Button(text="+").place(x=130, y=75)
buttonminus = Button(text="-").place(x=165, y=75)
buttonkrat = Button(text="・").place(x=197, y=75)
buttondeleno = Button(text=":").place(x=237, y=75)
【问题讨论】:
标签: python input tkinter limit