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

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

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

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

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

        在 Kivy 中加載應用程序時元素的大小不會更新

        Elements#39; sizes don#39;t update on application loading in Kivy(在 Kivy 中加載應用程序時元素的大小不會更新)
        <legend id='amZIe'><style id='amZIe'><dir id='amZIe'><q id='amZIe'></q></dir></style></legend>
        <i id='amZIe'><tr id='amZIe'><dt id='amZIe'><q id='amZIe'><span id='amZIe'><b id='amZIe'><form id='amZIe'><ins id='amZIe'></ins><ul id='amZIe'></ul><sub id='amZIe'></sub></form><legend id='amZIe'></legend><bdo id='amZIe'><pre id='amZIe'><center id='amZIe'></center></pre></bdo></b><th id='amZIe'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='amZIe'><tfoot id='amZIe'></tfoot><dl id='amZIe'><fieldset id='amZIe'></fieldset></dl></div>

            <tbody id='amZIe'></tbody>

              <tfoot id='amZIe'></tfoot>

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

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

                  本文介紹了在 Kivy 中加載應用程序時元素的大小不會更新的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有 on_size() 事件,它在我調整窗口大小時有效,但我無法使其在應用程序加載時正常工作(它有效,但不是必須的):

                  I have on_size() event, it works when I resize window, but I can't make it work on application loading correctly (it works, but not like it must):

                  from random import random, randint
                  
                  import kivy
                  
                  kivy.require('1.8.0')
                  
                  from kivy.config import Config
                  
                  Config.set('graphics', 'fullscreen', '0')
                  Config.set('graphics', 'width', 640)
                  Config.set('graphics', 'height', 480)
                  Config.set('graphics', 'position', 'custom')
                  Config.set('graphics', 'top', 40)
                  Config.set('graphics', 'left', 40)
                  
                  from kivy.app import App
                  from kivy.uix.layout import Layout
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.uix.label import Label
                  from kivy.graphics import Color, Line, Rectangle
                  
                  
                  class Main(BoxLayout):
                      side_padding = 20
                  
                      def __init__(self, **kwargs):
                          super(Main, self).__init__(**kwargs)
                          self.size = (0, 0)  # Doesn't help.
                          self.on_size()  # Doesn't help.
                  
                      def on_size(self, *args):
                          left, middle, right = self.ids.left, self.ids.middle, self.ids.right
                          left.width = max([x.texture_size[0] for x in left.children]) + self.side_padding
                          right.width = max([x.texture_size[0] for x in right.children]) + self.side_padding
                          available_space = self.width - left.width - right.width
                          if available_space > self.height:
                              middle.size = (self.height, self.height)
                              extra = (self.width - self.height - left.width - right.width) // 2
                              left.width += extra
                              right.width += extra
                          else:
                              middle.size = (available_space, available_space)
                  
                  
                  class SidePanel(BoxLayout):
                      def __init__(self, **kwargs):
                          super(SidePanel, self).__init__(**kwargs)
                  
                  
                  class GameField(Layout):
                      def __init__(self, **kwargs):
                          super(GameField, self).__init__(**kwargs)
                          self.array_size = randint(4, 8)
                          self.bind(pos=self.update, size=self.update)
                          self.update()
                  
                      def update(self, *args):
                          s_padding = 1 / 16
                          s_sq_size = 1 - 2 * s_padding
                          self.canvas.clear()
                          with self.canvas:
                              block_size = self.width / self.array_size
                              sq_size = block_size * s_sq_size
                              padding = block_size * s_padding
                              Color(1, 1, 1)
                              for j in range(self.array_size):
                                  for i in range(self.array_size):
                                      Rectangle(pos=(self.x + padding + i * block_size, self.y + padding + j * block_size),
                                                size=(sq_size, sq_size))
                              for i in range(self.array_size + 1):
                                  shift = self.width * i / self.array_size
                                  Line(points=(self.x, self.y + shift, self.x + self.width, self.y + shift))
                                  Line(points=(self.x + shift, self.y, self.x + shift, self.y + self.height))
                  
                  
                      def on_touch_up(self, touch):
                          self.array_size = randint(4, 8)
                          self.update()
                  
                  
                  class Application(App):
                      def build(self):
                          return Main()
                  
                  
                  if __name__ == '__main__':
                      Application().run()
                  

                  *.kv:

                  #:kivy 1.8.0
                  
                  <Main>:
                      orientation: 'horizontal'
                      canvas:
                          Color:
                              rgb: 1, 1, .9
                          Rectangle:
                              pos: self.pos
                              size: self.size
                      SidePanel:
                          id: left
                          Label:
                              size_hint_y: None
                              color: 0, 0, 0, 1
                              text: 'Score'
                          Label:
                              color: 0, 0, 0, 1
                              text: 'Event log log log loooooooooog'
                          Label:
                              color: 0, 0, 0, 1
                              text: 'Event log log log
                  123'
                          Label:
                              color: 0, 0, 0, 1
                              text: '35mdbj65 qewr'
                          Label:
                              color: 0, 0, 0, 1
                              text: '3qht6ju7ustju'
                      GameField:
                          id: middle
                      SidePanel:
                          id: right
                          Button:
                              size_hint_y: None
                              text: 'Menu'
                          Label:
                              color: 0, 0, 0, 1
                              text: 'Bonuses bonuses'
                  <SidePanel>:
                      orientation: 'vertical'
                      size_hint_x: None
                      size: self.size
                  
                  <GameField>:
                      pos_hint: {'center_y': .5}
                      size_hint: None, None
                      canvas.before:
                          Color:
                              rgb: .9, .9, .9
                          Rectangle:
                              pos: self.pos
                              size: self.size
                  

                  也許有什么錯誤?

                  推薦答案

                  當我根據里面的標簽和按鈕更新班級孩子的大小時,我已經向他們添加了 on_size 事件:

                  As I update my class's children's sizes depending on labels and buttons inside of it, I've added to them on_size event:

                  def on_size(self, *args):
                      self.parent.parent.on_size()
                  
                  
                  class SideLabel(Label):
                      on_size = on_size
                  
                  
                  class SideButton(Button):
                      on_size = on_size
                  

                  我還替換了 kv 中這些類的按鈕和標簽.它現在似乎可以正常工作了.

                  And also I have replaced Buttons and Labels on these classes in kv. It seems to work correctly now.

                  這篇關于在 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 - 自動更改角色顏色)

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

                    <tbody id='MN5ez'></tbody>
                      <tfoot id='MN5ez'></tfoot>

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

                        • <legend id='MN5ez'><style id='MN5ez'><dir id='MN5ez'><q id='MN5ez'></q></dir></style></legend>
                          • <bdo id='MN5ez'></bdo><ul id='MN5ez'></ul>
                            主站蜘蛛池模板: 久久久精品一区二区三区 | 每日更新av | 精品一区二区三区在线观看 | 国产美女久久 | 色吧久久 | 另类专区亚洲 | 亚洲 一区 | 亚洲国产精品人人爽夜夜爽 | 91中文在线观看 | 免费国产视频 | 国产精品3区 | 国产精品国产精品国产专区不片 | 日本不卡在线视频 | 国精品一区二区 | 成人高清在线视频 | 偷拍亚洲色图 | 国产成人免费视频 | 91九色婷婷 | 中文字幕在线视频免费视频 | 久久一级大片 | 亚洲一区久久 | 久久99国产精一区二区三区 | 9久9久9久女女女九九九一九 | 日日日日日日bbbbb视频 | 综合网视频 | 国产美女黄色片 | 看真人视频一级毛片 | 99综合| 黄色免费观看 | 欧美精品在线免费 | 九九热最新视频 | 精品国产一区二区三区性色av | 成人一区二区视频 | 日韩精品久久一区二区三区 | 91精品国产91 | 久久久久久久一区 | 国产精品久久久亚洲 | 国产一级视频 | 亚洲免费网址 | 在线观看成人小视频 | 精品视频一区二区三区在线观看 |