我想将textinput转换为float,请
目前我有以下代码:
TextInput:
id: latitude1
multiline: False
pos_hint: {"x":0.16, "top":0.5}
input_filter:"float"
Button:
pos_hint: {"x":0.08, "top":0.8}
text: "Modify map"
on_press: mapview1.center_on(longitude1,latitude1)
我已经用mapview1.center_on(46.02,3.02)
替换了参数mapview1.center_on(longitude1,latitude1)
,以测试按钮是否工作正常,是否工作正常,地图是否会随着新闻协调刷新
另一方面,当参数为:mapview1.center_on(longitude1,latitude1)
时,我得到以下错误:
File "kivy\weakproxy.pyx", line 70, in kivy.weakproxy.WeakProxy.__richcmp__
TypeError: '>' not supported between instances of 'TextInput' and 'float'.
我不明白如何将TextInput直接转换为Float
latitude1
是对TextInput
{latitude1.text
。要将其转换为float
,请使用float()
函数:所以你的
on_press
应该是这样的:相关问题 更多 >
编程相关推荐