第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在 Kivy 中使用按鈕釋放清除 inputText

在 Kivy 中使用按鈕釋放清除 inputText

慕勒3428872 2021-06-27 12:00:15
讓我們想象一下我們有一個(gè)表單,這個(gè)人在輸入上寫了一些東西但需要清除它們,我將如何在 Kivy 中做到這一點(diǎn)?我試過(guò)這個(gè),但沒(méi)有用:主要.py:class CreateUra(GridLayout):    def clear_inputs(self, *args):            for item in args:                item = ''class UraApp(App):    def build(self):        return CreateUra()if __name__ == "__main__":    UraApp().run()烏拉.kv:<CreateUra>:    cols: 1    padding: 10    spacing: 10    row_force_default: True    row_default_height: '32dp'      BoxLayout:            Label:                 text: 'Contexto:'                TextInput:                 hint_text: "Contexto da ura"                focus: True                multiline: False                cursor_color: (0, 0, 0, 0.8)                id: context_input        BoxLayout:            Label:                 text: 'Nome da ura:'                TextInput:                 hint_text: "Nome do arquivo da ura"                multiline: False                cursor_color: (0, 0, 0, 0.8)                id: ura_file_name        Button:            text: 'Create Ura'            id: bt_create            on_press: root.uraConfig()            on_release: root.clear_inputs(context_input.text, ura_file_name.text)*忽略 on_press 上的 uraConfig我試過(guò)這種方式,它奏效了:Button:    text: 'Create Ura'    id: bt_create    on_press: root.uraConfig()    on_release: context_input.text = ''我對(duì) kivy 和 Python 很陌生,所以我不確定這是否是清除文本的最佳方式,但我做錯(cuò)了什么?或者,如果你們能以最好的方式來(lái)做這件事。
查看完整描述

1 回答

?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

您的情況的問(wèn)題是傳遞文本,但不是文本屬性,而是文本的副本,因此即使將其設(shè)置為空也不會(huì)反映在文本輸入中。您必須將 textinput 作為列表傳遞,迭代并使用空字符串設(shè)置屬性:


*.kv


Button:

    text: 'Create Ura'

    id: bt_create

    on_press: root.uraConfig()

    on_release: root.clear_inputs([context_input, ura_file_name]) # <-- add brackets

*.py


class CreateUra(GridLayout):

    def clear_inputs(self, text_inputs):

        for text_input in text_inputs:

            text_input.text = ""


查看完整回答
反對(duì) 回復(fù) 2021-07-06
  • 1 回答
  • 0 關(guān)注
  • 317 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)