我正在尝试用pythontkinter制作一个基本的计算器。我做了一个输入框,用户输入他的第一个号码。但是,如果有人输入的不是数字,而是文本呢?我的问题是,如何使您可以只在输入框中输入数字,或者它如何可以忽略普通字母。在
顺便说一下,我完成一半的代码在这里:
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)
我个人要做的是在接受每个用户输入作为输入之前,通过一个整数验证函数运行每个用户输入。像这样简单:
相关问题 更多 >
编程相关推荐