我在我的应用程序中使用了一个微调按钮,让用户选择一个介于 -1 和 100 之间的数字。在我的应用程序中,-1 表示无穷大。因此,如果用户选择值 -1,我想显示文本“Infinity”。这是我的代码:
def spin_output(spin):
digits = int(spin.props.digits)
value = spin.props.value
if value < 0:
spin.props.text = "Infinity" # u"\u221E"
else:
spin.props.text = '{0:.{1}f}'.format(value, digits)
return True
self.my_spin.connect('output', spin_output)
When the "Infinity"-value is selected and the user presses the "up"-button the value changes to 100 instead of 0. When i replace "Infinity" with u"\u221E" and the user presses the "up"-button当它被选中时,值变为 1。
我想要的是,用户可以按以下顺序选择值:Infinity, 0, 1, ... 我的错误是什么?
我认为当用户更改值时只会更改底层调整,而我的函数仅用于显示当前值。