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

  • <legend id='Pudzd'><style id='Pudzd'><dir id='Pudzd'><q id='Pudzd'></q></dir></style></legend>
  • <small id='Pudzd'></small><noframes id='Pudzd'>

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

      1. 如何從 Kivy 中的另一個小部件訪問某些小部件屬

        How to access some widget attribute from another widget in Kivy?(如何從 Kivy 中的另一個小部件訪問某些小部件屬性?)

        <tfoot id='UliFo'></tfoot>

            • <bdo id='UliFo'></bdo><ul id='UliFo'></ul>

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

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

                  本文介紹了如何從 Kivy 中的另一個小部件訪問某些小部件屬性?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  好吧,假設我希望某個小部件中的標簽使用另一個小部件內標簽中的文本:

                  Ok let's say I want that label in some widget to use text from label inside another widget:

                  <SubWidget@RelativeLayout>:
                      Label:
                          text: str(root.parent.ids.first.text)
                  
                  <RootWidget>:
                      Label:
                          id: first
                          center_x: 100
                          text: "text"
                  
                      SubWidget:
                          id: second
                          center_x: 200
                  

                  這可行,但似乎不是很好的解決方案.如果我將 first 放在另一個小部件中,我需要在代碼中的任何地方更改對它的引用(這可能導致錯誤).

                  This works but doesn't seem to be nice solution. If I'll place first inside another widget I'll need to change reference to that it everywhere in the code (that can lead to errors).

                  我的第一個想法是至少在根級別存儲對 first 的引用并對其進行引用:

                  My first idea was at least to store reference to first at root level and reference to it:

                  <SubWidget@RelativeLayout>:
                      Label:
                          text: str(root.parent.l.text)
                  
                  
                  <RootWidget>:
                      l: first
                  
                      Label:
                          id: first
                          center_x: 100
                          text: "text"
                  
                      SubWidget:
                          id: second
                          center_x: 200
                  

                  但這會導致異常:

                  AttributeError: 'NoneType' object has no attribute 'text'
                  

                  這很令人困惑,因為如果我寫類似 text: str(root.parent.l) 我會看到 Label object 而不是 NoneType.

                  This is confusing since if I'll write something like text: str(root.parent.l) I'll see Label object rather than NoneType.

                  所以我有兩個問題:

                  1. 為什么第二種解決方案不起作用?如何解決?
                  2. 一般來說,從另一個小部件訪問某些小部件屬性的最佳方式是什么?我可以讓它獨立于小部件層次結構嗎?

                  推薦答案

                  1. 對象屬性 l 可能會在第一次事件循環迭代之后 被填充,而您正試圖在第一次迭代中訪問它.您可以將其延遲到第二次迭代以使其正常工作.

                  1. The object property l probably gets populated after the first event loop iteration, while you are trying to access it within the first. You could delay it till the second iteration to make it work.

                  最強大的方法是從 python 代碼中綁定這些屬性,但是有一些 kv lang 技巧可以使其更簡單.這是我最喜歡的方法:

                  The most powerful approach is to bind those properties from inside python code, but there are some kv lang tricks to make it simpler. This is my favorite method:

                  BoxLayout
                  
                      Label
                          id: label
                          text: 'hello world'
                  
                      SubWidget
                          label_text: label.text
                  
                  <SubWidget@BoxLayout>
                      label_text: 'none'
                  
                      Label
                          text: root.label_text
                  

                  這篇關于如何從 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 - 自動更改角色顏色)
                  <tfoot id='WOxMW'></tfoot>
                    <tbody id='WOxMW'></tbody>

                  • <bdo id='WOxMW'></bdo><ul id='WOxMW'></ul>
                    • <small id='WOxMW'></small><noframes id='WOxMW'>

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

                            主站蜘蛛池模板: 国产精品久久久久久久久久免费 | 狠狠的干| 一区二区三区在线电影 | 青青激情网 | 中文字幕亚洲一区 | 国产精品一区二区在线播放 | 国产这里只有精品 | 一区二区日韩 | 久草网址 | 一级黄色毛片子 | 久久手机在线视频 | 特黄一级 | 成人精品系列 | 亚洲一区 中文字幕 | 一区二区三区四区不卡视频 | 国产日韩欧美 | 毛片一级片 | 97日日碰人人模人人澡分享吧 | 九九在线视频 | 日韩精品一区二区三区中文在线 | 久草在线青青草 | 一区二区三区四区日韩 | 九九综合| 国产精品资源在线观看 | 久久久久久国产精品免费免费狐狸 | 精品国产成人 | 国产三级精品三级在线观看四季网 | av在线播放一区二区 | 福利视频一区二区三区 | 精品国产乱码久久久久久蜜柚 | www.日本国产 | 精品国产99 | 久草在线在线精品观看 | 香蕉视频在线播放 | av乱码 | 理论片午午伦夜理片影院 | 欧美一区二区三区在线观看视频 | 午夜成人免费视频 | 综合久久综合久久 | 91久久久久久久久久久久久 | 午夜网站视频 |