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

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

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

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

      2. 具有動(dòng)態(tài)網(wǎng)格布局的 Kivy 模板

        Kivy template with dynamic grid layout(具有動(dòng)態(tài)網(wǎng)格布局的 Kivy 模板)
          <tbody id='kftPb'></tbody>
          <i id='kftPb'><tr id='kftPb'><dt id='kftPb'><q id='kftPb'><span id='kftPb'><b id='kftPb'><form id='kftPb'><ins id='kftPb'></ins><ul id='kftPb'></ul><sub id='kftPb'></sub></form><legend id='kftPb'></legend><bdo id='kftPb'><pre id='kftPb'><center id='kftPb'></center></pre></bdo></b><th id='kftPb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='kftPb'><tfoot id='kftPb'></tfoot><dl id='kftPb'><fieldset id='kftPb'></fieldset></dl></div>
        • <tfoot id='kftPb'></tfoot>

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

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

                  <legend id='kftPb'><style id='kftPb'><dir id='kftPb'><q id='kftPb'></q></dir></style></legend>
                • 本文介紹了具有動(dòng)態(tài)網(wǎng)格布局的 Kivy 模板的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在嘗試為布局創(chuàng)建一個(gè)模板,如下所示:

                  I'm trying to create a template for a layout which looks like the following:

                  |----------|
                  |          | 
                  | IMAGE    |   <--- Just an image (square)
                  |          |
                  |----------| 
                  |[btn][btn]|   <--- GridLayout cols=2 of buttons 
                  |[btn][btn]| 
                  |[btn][btn]| 
                  |[btn][btn]| 
                  |[btn][btn]| 
                  |[btn][btn]|
                  |----------|
                  

                  第一部分很簡(jiǎn)單(但我可能錯(cuò)了,因?yàn)槲沂?kivy 的新手)

                  the first part is easy (but I could be wrong, as I'm very new at kivy)

                  #:kivy 1.6
                  [SideBar@BoxLayout]:
                      orientation: 'vertical'
                      Image:
                          source: ctx.image
                          size_hint: (1, None)
                          height: root.width
                      GridLayout:
                          cols: 2
                          # What do I do here to make it easy to load a list of buttons?
                  

                  推薦答案

                  #!/usr/bin/env python2
                  from kivy.app import App
                  from kivy.lang import Builder
                  from kivy.uix.floatlayout import FloatLayout
                  from kivy.uix.button import Button
                  
                  Builder.load_string('''
                  #:kivy 1.6
                  [SideBar@BoxLayout]:
                      content: content
                      orientation: 'vertical'
                      size_hint: ctx.size_hint if hasattr(ctx, 'size_hint') else (1, 1)
                      Image:
                          source: ctx.image
                          size_hint: (1, None)
                          height: root.width
                      GridLayout:
                          cols: 2
                          # just add a id that can be accessed later on
                          id: content
                  
                  <Root>:
                      Button:
                          center_x: root.center_x
                          text: 'press to add_widgets'
                          size_hint: .2, .2
                          on_press:
                              # what comes after `:` is basically normal python code
                              sb.content.clear_widgets()
                              # however using a callback that you can control in python
                              # gives you more control
                              root.load_content(sb.content)
                      SideBar:
                          id: sb
                          size_hint: .2, 1
                          image: 'data/images/image-loading.gif'
                  ''')
                  
                  class Root(FloatLayout):
                  
                      def load_content(self, content):
                          for but in range(20):
                              content.add_widget(Button(
                                                  text=str(but)))
                  
                  class MyApp(App):
                      def build(self):
                          return Root()
                  
                  if __name__ == '__main__':
                      MyApp().run()
                  

                  我希望內(nèi)聯(lián)注釋使示例足夠清晰.在這種情況下,我們只是將內(nèi)容的 ref 傳遞給將小部件添加到內(nèi)容的函數(shù).

                  I hope the inline comments make the example clear enough. In this case we are just passing the ref of the content to the function that adds widgets to the content.

                  在某些情況下,您可能希望訪問(wèn) Widget 作為您自己類的屬性.在這種情況下,您可以使用以下 方法.

                  There are situations where you might want to have access to the Widget as a attribute of your own class. In that case you can Use the following method.

                  上面的方法基本上是加了一個(gè)ObjectProperty的與 id 同名,將 id 所引用的小部件的引用傳遞給它.因此,您現(xiàn)在擁有一個(gè)與 python 類中的 id 同名的屬性,以便于訪問(wèn).使用上述方法,您的代碼將如下所示.

                  The method above basically adds a ObjectProperty of the same name as the id, passes the reference of the widget referenced to by the id to it. So you, now have a attribute with the same name as the id in your python class for easy access. Using the above mentioned method your code would look something like this.

                  #!/usr/bin/env python2
                  from kivy.app import App
                  from kivy.lang import Builder
                  from kivy.uix.floatlayout import FloatLayout
                  from kivy.uix.button import Button
                  from kivy.properties import ObjectProperty
                  
                  Builder.load_string('''
                  #:kivy 1.6
                  [SideBar@BoxLayout]:
                      content: content
                      orientation: 'vertical'
                      size_hint: ctx.size_hint if hasattr(ctx, 'size_hint') else (1, 1)
                      Image:
                          source: ctx.image
                          size_hint: (1, None)
                          height: root.width
                      GridLayout:
                          cols: 2
                          # just add a id that can be accessed later on
                          id: content
                  
                  <Root>:
                      content: sb.content
                      Button:
                          center_x: root.center_x
                          text: 'press to add_widgets'
                          size_hint: .2, .2
                          on_press:
                              sb.content.clear_widgets()
                              root.load_content()
                      SideBar:
                          id: sb
                          size_hint: .2, 1
                          image: 'data/images/image-loading.gif'
                  ''')
                  
                  class Root(FloatLayout):
                  
                      content = ObjectProperty(None)
                      '''This is initialised to None and in kv code at line 28
                      above (the one with `content: sb.content`) a ref to the
                      actual content is passed'''
                  
                      def load_content(self):
                          content = self.content
                          for but in range(20):
                              content.add_widget(Button(
                                                  text=str(but)))
                  
                  class MyApp(App):
                      def build(self):
                          return Root()
                  
                  if __name__ == '__main__':
                          MyApp().run()
                  

                  這篇關(guān)于具有動(dòng)態(tài)網(wǎng)格布局的 Kivy 模板的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個(gè)在 Python 中提供角色的不和諧機(jī)器人?)
                  Discord bot isn#39;t responding to commands(Discord 機(jī)器人沒(méi)有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?Discord 機(jī)器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機(jī)器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動(dòng)更改角色顏色)

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

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

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

                            主站蜘蛛池模板: 久久久美女 | 国产精品一区二区欧美黑人喷潮水 | 国产在线精品一区 | 日韩欧美中文在线 | 91久久久久久久 | 日本欧美在线 | 毛片久久久 | 99久久精品国产麻豆演员表 | 在线视频成人 | 国产精品国产三级国产a | 女朋友的闺蜜3韩国三级 | 国产成人精品久久二区二区91 | 精品欧美一区二区三区久久久 | 91视频在线观看 | 欧美日韩国产在线观看 | 亚洲日日夜夜 | 在线成人精品视频 | 国产视频一区二区三区四区五区 | 国产小视频在线 | 亚洲欧美日韩国产 | 青娱乐av| 国产一区二区不卡 | 国产精品178页 | 日韩中文一区二区三区 | 国产日韩欧美激情 | 久久精品国产免费看久久精品 | 91亚洲国产成人久久精品网站 | 久久不卡| 国产福利91精品 | 精品1区2区| 伊人久久免费视频 | 男女视频在线观看网站 | 精品久久电影 | 麻豆av一区二区三区久久 | 国产精品成人在线观看 | 伊人精品| 精品国产乱码久久久久久蜜臀 | 欧美一级艳情片免费观看 | 日韩欧美一区二区三区免费观看 | 亚洲精品区 | 欧美日韩在线一区二区 |