如何在函数中从和到获取 spinbox 的值?
sbDays=tk.Spinbox(frame,from_=0,to=366)
sbDays.place(relx=initialX,rely=yDistance)
sbDays.configure(validate='all',validatecommand=(windows.register(validate),'%P'))
def validate(userInput):
if userInput=="":
return True
try:
val=int(float(userInput))
except ValueError:
return False
return val>=0 and val<=366
而不是return val>=0 and val<=366
. 我需要这个:
minVal=spinbox 'from' value of '0'
maxVal=spinbox 'to' value of '366'
return val>=minVal and val<=maxVal
在 C# 中,是这样的:
minVal=this.From()
maxVal=this.To()