久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='9OTE9'><tr id='9OTE9'><dt id='9OTE9'><q id='9OTE9'><span id='9OTE9'><b id='9OTE9'><form id='9OTE9'><ins id='9OTE9'></ins><ul id='9OTE9'></ul><sub id='9OTE9'></sub></form><legend id='9OTE9'></legend><bdo id='9OTE9'><pre id='9OTE9'><center id='9OTE9'></center></pre></bdo></b><th id='9OTE9'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9OTE9'><tfoot id='9OTE9'></tfoot><dl id='9OTE9'><fieldset id='9OTE9'></fieldset></dl></div>
      <bdo id='9OTE9'></bdo><ul id='9OTE9'></ul>
  • <small id='9OTE9'></small><noframes id='9OTE9'>

        <tfoot id='9OTE9'></tfoot>

        <legend id='9OTE9'><style id='9OTE9'><dir id='9OTE9'><q id='9OTE9'></q></dir></style></legend>

        kivy python通過按鈕單擊將參數(shù)傳遞給函數(shù)

        kivy python passing parameters to fuction with button click(kivy python通過按鈕單擊將參數(shù)傳遞給函數(shù))
          <tbody id='F9vy3'></tbody>

          <bdo id='F9vy3'></bdo><ul id='F9vy3'></ul>

          <tfoot id='F9vy3'></tfoot>

            <i id='F9vy3'><tr id='F9vy3'><dt id='F9vy3'><q id='F9vy3'><span id='F9vy3'><b id='F9vy3'><form id='F9vy3'><ins id='F9vy3'></ins><ul id='F9vy3'></ul><sub id='F9vy3'></sub></form><legend id='F9vy3'></legend><bdo id='F9vy3'><pre id='F9vy3'><center id='F9vy3'></center></pre></bdo></b><th id='F9vy3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='F9vy3'><tfoot id='F9vy3'></tfoot><dl id='F9vy3'><fieldset id='F9vy3'></fieldset></dl></div>

          1. <legend id='F9vy3'><style id='F9vy3'><dir id='F9vy3'><q id='F9vy3'></q></dir></style></legend>
                • <small id='F9vy3'></small><noframes id='F9vy3'>

                  本文介紹了kivy python通過按鈕單擊將參數(shù)傳遞給函數(shù)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  按下按鈕調(diào)用函數(shù)時,我無法將參數(shù)傳遞給函數(shù).用 kivy 語言可以這樣做:

                  I am having trouble passing parameters to function when calling it with button press. One could do it like this in kivy language:

                  Button: 
                     on_press: root.my_function('btn1')
                  

                  但我想用 python 來做,因為我想用循環(huán)創(chuàng)建更多的按鈕.目前我在 python 中這樣調(diào)用我的函數(shù):

                  but I would like to do it in python, as I would like to create a larger number of buttons with a loop. Currently I call my function in python like this:

                  Button(on_press=self.my_function)
                  

                  但正如我所說,如果我嘗試像這樣將參數(shù)傳遞給函數(shù),我會得到一個AssertionError: None is not callable",如下所示:

                  but as I said, if I try to pass a parameter to the function like this, I get an 'AssertionError: None is not callable', like this:

                  Button(on_press=self.my_function('btn1'))
                  

                  推薦答案

                  Button(on_press=self.my_function)
                  

                  這是傳遞函數(shù)作為參數(shù).

                  Button(on_press=self.my_function('btn1'))
                  

                  這是調(diào)用函數(shù)并將返回值作為參數(shù)傳遞給on_press.由于返回值為 None,因此您會收到錯誤消息.

                  This is calling the function and passing the returned value as the argument to on_press. Since the returned value is None, you get your error.

                  您需要傳遞一個調(diào)用普通函數(shù)并自動傳遞參數(shù)的新函數(shù).總的來說,使用 functools.partial 比較方便:

                  You instead need to pass a new function that calls your normal function and automatically passes the argument. In general, it's convenient to use functools.partial:

                  from functools import partial
                  Button(on_press=partial(self.my_function, 'btn1'))
                  

                  您還可以使用 lambda 函數(shù):

                  You can also use a lambda function:

                  Button(on_press=lambda *args: self.my_function('btn1', *args))
                  

                  這篇關于kivy python通過按鈕單擊將參數(shù)傳遞給函數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

                      • <bdo id='eJjJc'></bdo><ul id='eJjJc'></ul>
                        <legend id='eJjJc'><style id='eJjJc'><dir id='eJjJc'><q id='eJjJc'></q></dir></style></legend>
                        <tfoot id='eJjJc'></tfoot>

                          <small id='eJjJc'></small><noframes id='eJjJc'>

                            <tbody id='eJjJc'></tbody>

                          • <i id='eJjJc'><tr id='eJjJc'><dt id='eJjJc'><q id='eJjJc'><span id='eJjJc'><b id='eJjJc'><form id='eJjJc'><ins id='eJjJc'></ins><ul id='eJjJc'></ul><sub id='eJjJc'></sub></form><legend id='eJjJc'></legend><bdo id='eJjJc'><pre id='eJjJc'><center id='eJjJc'></center></pre></bdo></b><th id='eJjJc'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eJjJc'><tfoot id='eJjJc'></tfoot><dl id='eJjJc'><fieldset id='eJjJc'></fieldset></dl></div>

                          • 主站蜘蛛池模板: 在线国产一区 | 一区二区三区在线 | 视频1区2区 | 国产福利免费视频 | 久久国产精品免费一区二区三区 | 久久91av | 亚洲视频www | 亚洲xx在线| 美女视频网站久久 | 天天激情综合 | 精品在线99 | 日本不卡一区二区三区 | 99精品久久久久久 | 高清一区二区三区 | 国产超碰人人爽人人做人人爱 | 精品日本久久久久久久久久 | 国产成人在线免费 | av国产在线观看 | 黄瓜av| 欧美激情国产日韩精品一区18 | 国产精品黄色 | 五月婷六月丁香 | 精品久久久一区 | h视频免费观看 | 国产高清精品在线 | 午夜资源| 黄a在线播放 | 国产乱肥老妇国产一区二 | 在线看中文字幕 | 亚洲午夜精品一区二区三区 | 天天草天天射 | 中文字幕精品一区 | 亚洲精品视频播放 | 国产一级免费在线观看 | 中文字幕在线网 | 99爱在线免费观看 | 99精品在线免费观看 | 久草资源在线 | 久热国产精品 | 一区二区三区四区在线 | 久久精品一 |