2024-06-06 18:51:15 发布
网友
我想更改.py文件中定义的调用函数的.kv中textbox的提示\u文本
我知道标签文字可以这样改变 self.root.ids.商标文本='[color=#FF0000]时间结束[/color]' 但对于textbox ex,这一点不起作用 self.root.ids一些_id.U文本:“一些特别的文字”
使用self.root.ids.text_input_id.hint_text = "Something special"
self.root.ids.text_input_id.hint_text = "Something special"
使用self.ids.text_input_id.hint_text = "Something special"
self.ids.text_input_id.hint_text = "Something special"
from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.lang import Builder Builder.load_string(""" <HintTextDemo>: orientation: 'vertical' TextInput: id: text_input hint_text: 'Write here' Button: text: 'Change hint text' on_release: app.change_hint_text() """) class HintTextDemo(BoxLayout): pass class TestApp(App): def build(self): return HintTextDemo() def change_hint_text(self): self.root.ids.text_input.hint_text = 'Type something here' if __name__ == "__main__": TestApp().run()
从应用程序类内更改
使用
self.root.ids.text_input_id.hint_text = "Something special"
从根类内更改
使用
self.ids.text_input_id.hint_text = "Something special"
示例
你知道吗主.py你知道吗
输出
相关问题 更多 >
编程相关推荐