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

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

    <tfoot id='Y6TST'></tfoot>

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

      Kivy:訪問不同類的方法

      Kivy: accessing a method on a different class(Kivy:訪問不同類的方法)
        <tbody id='omAdS'></tbody>

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

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

              • <tfoot id='omAdS'></tfoot>

              • 本文介紹了Kivy:訪問不同類的方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                假設我正在構建一個井字游戲(因為它與結構非常相似)我希望結果顯示在帶有新游戲按鈕的彈出窗口中,并且我希望此彈出窗口允許我訪問設置(使用另一個按鈕)并更改它們,始終保持在彈出窗口中,然后離開并最終關閉它并開始一個新游戲.

                Let's pretend I am building a tic-tac-toe game (becouse it's pretty similar as a structure) I want the result to be shown in a popup, with a new game button, and I want this popup to let me access settings (with another button) and change them, always staying within the popup, then leave and finally close it and start a new game.

                我希望我可以保持有序,因此有一個單獨的彈出窗口類,我可以在其中構建我的自定義彈出窗口.

                I wish i could keep things ordered and therefore have a separate popup class where i can build my custom popup.

                很明顯,我有 newgame 方法和 reset 方法作為我的游戲網格類的方法.另一方面,更改設置的方法是在自定義設置類上

                I have the newgame method and reset method as method of my game-grid class, as obvious. Methods for changing settings are, on the other hand, on a custom settings class

                在設計彈出類時,如何將其按鈕(例如新游戲)綁定到完全不同的類中包含的方法?我查看了一些 kv 示例,他們通常使用 root.blabla.method 來訪問位于同一棵樹的不同位置(在 .kv 文件中)的方法,但這里我試圖達到的方法超出了樹!

                While designing the popup class how can I bind it's buttons (e.g new game) to methods that are contained on a completly different class? I've looked on some kv examples and they usually use root.blabla.method to acces a method that is in a different position of the same tree (in the .kv file) but here the methods I am trying to reach are out of the tree!

                我會嘗試放一些示例代碼以使其更清晰

                I'll try to put some example code to make it more clear

                class Settings():
                
                    def changeSettings(self):
                        ....
                
                class GmeGrid(GridLayout):
                
                    def newGame(self):
                        ....
                
                    def reset(self):
                        ...
                
                class customPopup(Popup):
                
                    pass
                

                然后,在一個 .kv 文件上,我希望我可以將一些彈出按鈕綁定到 newGame 并更改設置方法

                Then, on a .kv file I wish I could bind some popup's buttons to the newGame and change settings methods

                這里的問題是我應該將 popop 類上的按鈕綁定到完全不同的類的方法上,但我不知道該怎么做(尤其是在 .kv 文件上)

                The problem here is that I should bind buttons on the popop class to the mothods of completly different class and I don't know how to to that (on the .kv file especially)

                推薦答案

                只要widget已經完全實例化并添加到widget樹中,就可以使用self.parent來訪問widget的父母.不過,您可能會考慮傳遞引用:

                As long as the widget has been fully instantiated and added to the widget tree, you can use self.parent to access the widget's parent. You might look into passing references instead though:

                Builder.load_string('''
                <CustomPopup>:
                    BoxLayout:
                        orientation: 'vertical'
                        # some settings stuff here
                        BoxLayout:
                            orientation: 'horizontal'
                            Button:
                                text: 'New Game'
                                on_press: root.do_new_game()
                ''')
                
                class CustomPopup(Popup):
                    settings_widget = ObjectProperty()
                    new_game = ObjectProperty()
                
                    def do_new_game(self):
                        self.settings_widget.some_property = some_value
                        self.dismiss()
                        self.new_game()
                
                p = CustomPopup(settings_widget=my_widget, new_game=mygame.newGame)
                p.open()
                

                這比假設父級具有設置更好,因為如果您更改保存設置的位置,您只需要更改一個引用.

                This is better that assuming the parent has the settings, because if you change where you keep the settings, you just need to change one reference.

                這篇關于Kivy:訪問不同類的方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 自動更改角色顏色)
                  <tbody id='jfGqc'></tbody>

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

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

                    • <tfoot id='jfGqc'></tfoot>

                          主站蜘蛛池模板: 91中文字幕在线观看 | 一区二区精品 | 中文字幕日韩一区 | 91免费视频 | 欧美在线日韩 | 久久精品久久久 | 在线免费观看成人 | 日韩精品av一区二区三区 | 一区二区视频在线 | 中文福利视频 | 久久久久国产一区二区三区 | 国产精品视频yy9299一区 | 国产一区二区av | 少妇久久久 | 亚洲第一网站 | 四虎影院欧美 | 欧美一区二区在线 | 国产91在线 | 欧美 | 国内自拍偷拍一区 | 超黄视频网站 | 日韩国产一区二区三区 | 欧美性生活一区二区三区 | 中文字幕成人av | 亚洲精品成人网 | 91 中文字幕 | 国产成人免费视频网站高清观看视频 | 国产三级一区二区三区 | jlzzjlzz国产精品久久 | 亚洲精品在线观看视频 | 日本不卡一区二区三区 | 成人福利视频网站 | 中文字幕在线播放第一页 | av黄色在线 | 日韩精品av一区二区三区 | 中文字幕一区二区三区乱码图片 | 日韩精品一区二 | 免费在线看黄视频 | 精品乱码一区二区三四区 | 日韩国产在线 | 久久躁日日躁aaaaxxxx | 久久久久久黄 |