如何解决Kivy:使用按钮更新 TextInput 元素
我最近开始制作 Kivy 应用。
到目前为止它应该做的是将 TextInput 元素从“密码将出现在这里”更改为“已清除!”当用户按下“清除”按钮时。
不幸的是什么也没发生,我不知道为什么。
代码:
class Main(FloatLayout):
def __init__(self,**kwargs):
super(Main,self).__init__(**kwargs)
self.cols = 2
self.rows = 3
self.add_widget(Label(text=str("Random Password Generator"),size_hint_y=None,pos=(20,600),color=(1,204/255,102/255)))
self.checkBox1 = CheckBox(active=False)
self.add_widget(self.checkBox1)
self.dropdown = DropDown()
for index in range(50):
btn = Button(text='%d' % index,pos_hint=(200,200),height=44)
btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
self.dropdown.add_widget(btn)
self.mainbutton = Button(text='Char Count',size_hint=(0.08,0.05),pos=(427,400))
self.mainbutton.bind(on_release=self.dropdown.open)
self.add_widget(self.mainbutton)
self.dropdown.bind(on_select=lambda instance,x: setattr(self.mainbutton,'text',"Char Count: " + x))
self.textBox = TextInput(text="Password will appear here",size_hint=(0.4,520))
self.add_widget(self.textBox)
self.clearButton = Button(text="Clear",440))
self.clearButton.bind(on_select=self.clearBox)
self.add_widget(self.clearButton)
def clearBox(self):
self.textBox.text = "Cleared!"
class KeycardApp(App):
def build(self):
return Main()
if __name__ == '__main__':
KeycardApp().run()
如果我是愚蠢的,请随意笑...
解决方法
通过这样做修复:
update c1
set c1.valor = x.tot_cap
from OBM2019.compproj c1
inner join (
select chave_projecto,ascendente a,sum(valor) tot_cap
from OBM2019.compproj
where chave_projecto = '1'
group by chave_projecto,ascendente
) x
on c1.chave_projecto = x.chave_projecto
where c1.chave_projecto = '1'
and c1.numero = x.a;
更改为 on_release 给了我错误代码“需要 0 个位置参数,但给出了 1 个”,所以我添加了 lambda a: 以将参数重新路由为空......并且它起作用了!!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。