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

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

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

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

    1. <tfoot id='RYJBT'></tfoot>

        Kivy:如何通過 id 獲取小部件(沒有 kv)

        Kivy : how to get widget by id (without kv)(Kivy:如何通過 id 獲取小部件(沒有 kv))

            • <tfoot id='eXuES'></tfoot>
              <legend id='eXuES'><style id='eXuES'><dir id='eXuES'><q id='eXuES'></q></dir></style></legend>
                <tbody id='eXuES'></tbody>

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

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

                3. 本文介紹了Kivy:如何通過 id 獲取小部件(沒有 kv)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  假設我在 Kivy 中動態定義了一些小部件(按鈕)并動態分配它們的 ID.在這個用例中我沒有使用 kv 語言.我可以在不跟蹤小部件本身的情況下保留小部件 ID 的引用:然后我想通過它的 ID 訪問小部件.我可以做類似通過 id 獲取小部件"之類的事情嗎?(如果我在 kv 文件中定義了小部件,我可以使用 self.ids.the_widget_id 通過其 id 訪問小部件本身)

                  Let's say I define on the fly in Kivy a few widgets (buttons) and dynamically assign their id. I'm not using kv language in this use case. I can keep a reference of a widget id without keeping track of the widget itself : then I'd like to access the widget through its id. Can I do something like "get widget by id" ? (If I had defined the widget in a kv file, I could have used self.ids.the_widget_id to access the widget itself through its id)

                  推薦答案

                  Kivy 小部件制作樹形結構.任何小部件的子級都可以通過 children 屬性獲得.如果需要,您可以只保留對根窗口的引用,然后使用 walk 方法迭代它的小部件:

                  Kivy widgets make tree structure. Children of any widget are avaiable through children atribute. If you want, you can keep reference only to root window and then iterate over it's widgets using walk method:

                  from kivy.app import App
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.uix.button import Button 
                  
                  class MyWidget(BoxLayout):
                      def __init__(self, **kwargs):
                          super().__init__(**kwargs)
                  
                          button = Button(text="...", id="1")
                          button.bind(on_release=self.print_label)
                  
                          l1 = BoxLayout(id="2")
                          l2 = BoxLayout(id="3")
                  
                          self.add_widget(l1)
                          l1.add_widget(l2)             
                          l2.add_widget(button)
                  
                      def print_label(self, *args):
                          for widget in self.walk():
                              print("{} -> {}".format(widget, widget.id))
                  
                  class MyApp(App):
                      def build(self):
                          return MyWidget()
                  
                  if __name__ == '__main__':
                      MyApp().run()
                  

                  walk()walk_reverse() 方法被添加到 Kivy 1.8.1 版本的 kivy.uix.widget.Widget 中.對于舊版本,您需要自己遞歸解析樹:

                  walk() and walk_reverse() method were added to kivy.uix.widget.Widget in 1.8.1 version of Kivy. For older versions you need to recursively parse tree yourself:

                  from kivy.app import App
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.uix.button import Button 
                  
                  class MyWidget(BoxLayout):
                      def __init__(self, **kwargs):
                          super().__init__(**kwargs)
                  
                          button = Button(text="...", id="1")
                          button.bind(on_release=self.print_label)
                  
                          l1 = BoxLayout(id="2")
                          l2 = BoxLayout(id="3")
                  
                          self.add_widget(l1)
                          l1.add_widget(l2)             
                          l2.add_widget(button)
                  
                      def print_label(self, *args):
                          children = self.children[:]
                          while children:
                              child = children.pop()
                              print("{} -> {}".format(child, child.id))
                              children.extend(child.children)
                  
                  class MyApp(App):
                      def build(self):
                          return MyWidget()
                  
                  if __name__ == '__main__':
                      MyApp().run()
                  

                  這篇關于Kivy:如何通過 id 獲取小部件(沒有 kv)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 自動更改角色顏色)

                    1. <legend id='62lJw'><style id='62lJw'><dir id='62lJw'><q id='62lJw'></q></dir></style></legend>
                      <tfoot id='62lJw'></tfoot>
                          <bdo id='62lJw'></bdo><ul id='62lJw'></ul>
                          • <small id='62lJw'></small><noframes id='62lJw'>

                          • <i id='62lJw'><tr id='62lJw'><dt id='62lJw'><q id='62lJw'><span id='62lJw'><b id='62lJw'><form id='62lJw'><ins id='62lJw'></ins><ul id='62lJw'></ul><sub id='62lJw'></sub></form><legend id='62lJw'></legend><bdo id='62lJw'><pre id='62lJw'><center id='62lJw'></center></pre></bdo></b><th id='62lJw'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='62lJw'><tfoot id='62lJw'></tfoot><dl id='62lJw'><fieldset id='62lJw'></fieldset></dl></div>
                              <tbody id='62lJw'></tbody>
                            主站蜘蛛池模板: 欧美一区二区精品 | 日韩在线精品视频 | 精品久久久久久 | 欧美精品第一页 | 秋霞电影一区二区三区 | 一区中文 | www.天天操| 99reav| 久久视频精品在线 | 欧美午夜精品 | 黄色免费在线观看网址 | 免费国产视频在线观看 | 欧美精品久久 | 欧美午夜精品 | 性欧美hd | 日韩网站在线观看 | 欧美男人天堂 | 国产成人在线视频 | 最新中文字幕久久 | 色综合视频 | 欧美国产精品 | 亚洲国产精品一区二区第一页 | 久久精品亚洲精品国产欧美 | 一级毛片免费视频 | 中文字幕一区二区三区四区五区 | 成人小视频在线观看 | 欧美精品一区二区蜜桃 | 狠狠色综合久久丁香婷婷 | 国产一区亚洲 | 国产精品久久久久久久白浊 | 久久精品一区二区 | 99国产精品久久久久 | av片毛片| 在线一区| 精品日本久久久久久久久久 | 欧美日韩国产精品一区 | 久久www免费视频 | 亚洲一区二区精品视频 | 最新日韩欧美 | 久久久国产一区二区三区 | 99伊人|