久久久久久久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通過按鈕單擊將參數傳遞給函數

        kivy python passing parameters to fuction with button click(kivy python通過按鈕單擊將參數傳遞給函數)
          <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通過按鈕單擊將參數傳遞給函數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  按下按鈕調用函數時,我無法將參數傳遞給函數.用 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 來做,因為我想用循環創建更多的按鈕.目前我在 python 中這樣調用我的函數:

                  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)
                  

                  但正如我所說,如果我嘗試像這樣將參數傳遞給函數,我會得到一個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)
                  

                  這是傳遞函數作為參數.

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

                  這是調用函數并將返回值作為參數傳遞給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.

                  您需要傳遞一個調用普通函數并自動傳遞參數的新函數.總的來說,使用 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 函數:

                  You can also use a lambda function:

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

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

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

                  相關文檔推薦

                  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>

                          • 主站蜘蛛池模板: 精品欧美一区二区在线观看 | 天天干天天操天天爽 | 综合色导航 | 女人牲交视频一级毛片 | 国产三级电影网站 | 中文字幕成人免费视频 | 午夜寂寞福利视频 | 亚洲av毛片成人精品 | 日韩一区二区三区视频 | 国产欧美一区二区三区在线看 | 亚洲成人一区二区三区 | 日韩欧美中文字幕在线视频 | 精品三级在线观看 | 久久99视频精品 | 久久久久国产一区二区三区 | 亚洲一区久久 | 成人一区二区三区在线观看 | 欧美一区在线看 | 欧美日韩在线精品 | 99久热在线精品视频观看 | 亚洲视频区 | 国产一级在线 | 成人午夜激情 | 成人精品一区二区三区中文字幕 | 黄色国产视频 | 中文字幕电影在线观看 | 色偷偷888欧美精品久久久 | 欧美视频精品 | 亚洲v日韩v综合v精品v | 国产精品久久久一区二区三区 | 欧美国产日韩一区二区三区 | 久久精品国产亚洲一区二区 | a级免费黄色片 | 国产精品欧美日韩 | 亚洲一区二区三区免费在线 | av天天澡天天爽天天av | 精品日韩在线观看 | 91天堂网| 亚洲大片| 视频一二三区 | 久久99国产精品 |