【发布时间】:2017-07-04 16:57:55
【问题描述】:
框架:我说的是一个用 Python 2.7 编写并使用 Builtdozer 打包的 Android 应用
我在应用程序中有一个带有按钮的生成器
Builder.load_string('''
FloatLayout:
orientation: 'horizontal'
Button:
text: str(root.name)
font_size: '20sp'
pos_hint: {'x':.0, 'y':.3}
size_hint: .4, .8
''')
我想创建一个函数change_name,如果我按下上面的按钮,就会打开安卓键盘来接受用户raw_input
用户提供的raw_input要替换上面按钮的文字。
我的想法是:
1) 创建变量name = StringProperty('Me')
2) 创建函数:
def change_name(self):
self.name = raw_input()
3) 使用on_release 调用按钮内的函数
Builder.load_string('''
FloatLayout:
orientation: 'horizontal'
Button:
text: str(root.name)
font_size: '20sp'
pos_hint: {'x':.0, 'y':.3}
size_hint: .4, .8
on_release: root.change_name()
''')
正确吗?因为实际上,在 Ubuntu 上运行该应用程序时,我试图单击该按钮,但该应用程序不要求输入(它似乎被阻止)。
因此,我相信它也无法在 Android 上运行。
你能帮我理解我哪里错了吗?
【问题讨论】: