久久久久久久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ù)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  按下按鈕調用函數(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 中這樣調用我的函數(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'))
                  

                  這是調用函數(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.

                  您需要傳遞一個調用普通函數(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)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(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>

                          • 主站蜘蛛池模板: 久产久精国产品 | 女人牲交视频一级毛片 | 91.com在线观看 | 欧美精品一区三区 | 精品国产乱码久久久久久a丨 | 黄色一级电影在线观看 | 国产电影一区二区在线观看 | 日操夜操| 成人网址在线观看 | 日韩资源 | 蜜桃视频一区二区三区 | 久久在线免费 | 久久久亚洲一区 | 九九热精品视频 | 久久久久久久一区二区三区 | 日韩无 | 午夜精品影院 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 欧美一级艳情片免费观看 | 一区二区成人 | 国产伦精品一区二区三区照片91 | 国产精品1区2区 | 精品一区二区三区在线观看国产 | 精品国产乱码一区二区三 | 亚洲视频免费在线观看 | 91影片 | 欧美亚洲一区二区三区 | 日本网站在线看 | 欧美视频在线播放 | 午夜免费视频 | 在线亚洲一区 | 国产精品一区二区不卡 | 日韩在线观看视频一区 | 在线资源视频 | 精品乱码一区二区三四区 | 欧美一区二区三区四区在线 | 午夜资源| 天天干天天草 | 亚洲人成免费 | 亚洲第一福利视频 | 中文日韩字幕 |