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

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

為什么MDCard無(wú)法在KivyMD中添加on_touch_down?

為什么MDCard無(wú)法在KivyMD中添加on_touch_down?

莫回?zé)o 2023-08-15 18:35:53
我已經(jīng)實(shí)施了以下。底部有兩個(gè)按鈕。單擊第一個(gè)按鈕時(shí),它會(huì)從主屏幕轉(zhuǎn)到第一個(gè)屏幕。在第一個(gè)屏幕上,單擊右上角按鈕將創(chuàng)建 10 張卡片。但是當(dāng)嘗試添加on_touch_down時(shí)它會(huì)崩潰。我添加了toast print一些功能,但沒(méi)有任何效果。那么這個(gè)問(wèn)題的解決方案是什么?謝謝main.py 我已經(jīng)評(píng)論過(guò)on_touch_down = toast('clicked')。沒(méi)有它它也可以工作,但是當(dāng)取消注釋時(shí),應(yīng)用程序就會(huì)崩潰。如何實(shí)施?這樣該卡就可以點(diǎn)擊了。build_string.pyhelper_string = """<MenuButton@MDIconButton>:    icon: "menu"    theme_text_color: "Custom"    text_color: 1,0,0,1    halign: 'bottom'      on_press: app.show_main_grid_bottom_sheet()<TButton@MDIconButton>:    icon: "menu"    theme_text_color: "Custom"    text_color: 1,0,0,1    halign: 'center'  <TitleText@MDLabel>    pos_hint: {"center_y": .95}    halign: "center"    theme_text_color: "Custom"    text_color: 0, 0, 1, 1    font_style: "Subtitle1"ScreenManager:    id: screen_manager    MainScreen:    FirstScreen:        id: first_screen_id    SecondScreen:<MainScreen>:    name: 'main_screen'    BoxLayout:        orientation: "vertical"        spacing: "5dp"        MDToolbar:            id: toolbar            pos_hint: {'bottom': 1}            #right_action_items: [["dots-vertical", lambda x: app.show_main_grid_bottom_sheet()]]            left_action_items: [["menu", lambda x: app.show_main_grid_bottom_sheet()]]   <FirstScreen>:    name: 'first_screen'    BoxLayout:        id: first_screen_box        orientation: "vertical"        spacing: "5dp"        MDToolbar:            id: toolbar            title: "First Screen"            elevation: 5            pos_hint: {'top': 1}            right_action_items: [["refresh", lambda x: app.make_card()]]        ScrollView:                            MDBoxLayout:                id: first_screen_box_layout                orientation: 'vertical'                adaptive_height: True                padding: dp(15)                spacing: dp(5) 
查看完整描述

1 回答

?
慕尼黑的夜晚無(wú)繁華

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

是on_touch_down您可以綁定的事件,它不是MDCard您可以設(shè)置的屬性。所以你可以像這樣進(jìn)行綁定:


def make_card(self):

    for i in range(10):

        card = MDCard(

            orientation="vertical",

            padding="8dp",

            ripple_behavior=True,

            size_hint=[1, None],

            #on_touch_down = toast('clicked')

        )

        card.bind(on_touch_down=self.clicked)  # set binding


        label_link = MDLabel(text="Card" + str(i))

        label_link.font_style = "Caption"


        label_header = MDLabel(text="Title" + str(i))

        label_header.size_hint = [1, 1]


        card.add_widget(label_link)

        card.add_widget(label_header)


        self.sm.ids.first_screen_id.ids.first_screen_box_layout.add_widget(card)


# method called by binding

def clicked(self, card, touch):

    if card.collide_point(*touch.pos):

        print('clicked on', card.children[0].text)


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

添加回答

舉報(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)