簡體   English   中英

在 kv 文件中單擊時更改文本輸入文本

[英]changing textinput text when clicked in a kv file

當用戶單擊它時,我試圖更改文本輸入的文本。 我嘗試了 def on_enter,但在整個文件中我使用了一個屏幕,所以這就是窗口。

def test(self, *args):
    self.ids.text_input.text = "test"
    #self.ids.text_input.bind(on_text_validate = self.test)?


TextInput:
    multiline: False
    id: text_input
    text:'00:00'
    on_enter: app.test() #? problem area
    on_press: app.test() #? problem area

您可以使用on_focus代替on_enteron_press

TextInput:
    multiline: False
    id: text_input
    text:'00:00'
    on_focus: app.test(self)  # call app.test() and pass reference to the TextInput

那么App中的方法可以是:

def test(self, ti):
    ti.text = "test"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM