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

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

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

        <bdo id='C2KtP'></bdo><ul id='C2KtP'></ul>
      1. <tfoot id='C2KtP'></tfoot>
      2. 小部件在 GridLayout 中的位置

        Position of widgets in GridLayout(小部件在 GridLayout 中的位置)

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

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

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

                • 本文介紹了小部件在 GridLayout 中的位置的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試創(chuàng)建一個小部件網(wǎng)格,每個單元格"小部件都有一個矩形,我可以稍后更改顏色.當我使用 grid.add_widget(Button(text=str(i))) 行運行下面的代碼時,按鈕會填充窗口(如文檔中所示).但是,當我在 grid.add_widget(Cell()) 中使用我的 Cell 小部件時,所有小部件都聚集在左下角(position=[0,0], size=[100,100]).我發(fā)現(xiàn)了這個問題 Kivy: Add rawWidget 為 GridLayout(與 Image、Button 等相反) 并將我的 Cell 類更改為從 Layout 而不是 Widget 繼承但這無濟于事.關(guān)于我做錯了什么的任何想法?我想要的是一個彩色矩形網(wǎng)格.

                  I'm trying to create a grid of widgets with each "cell" widget having a rectangle I can change the color of later. When I run the code below with the line grid.add_widget(Button(text=str(i))) the buttons fill the window (as in the docs). However, when I use my Cell widget as in grid.add_widget(Cell()) all the widgets are bunched in the lower left corner (position=[0,0], size=[100,100]). I found this question Kivy: Add raw Widget to GridLayout (as opposed to Image, Button, etc) and changed my Cell class to inherit from Layout instead of Widget but that didn't help things. Any ideas on what I'm doing wrong? What I'd like is a grid of colored rectangles.

                  版本

                  [INFO   ] [Kivy        ] v1.9.1
                  [INFO   ] [Python      ] v2.7.6 (default, Jun 22 2015, 17:58:13) 
                  

                  代碼

                  from kivy.app import App
                  from kivy.core.window import Window
                  from kivy.uix.widget import Widget
                  from kivy.uix.button import Button
                  from kivy.uix.gridlayout import GridLayout
                  from kivy.uix.layout import Layout
                  from kivy.graphics import Rectangle, Color
                  
                  XSIZE=2
                  YSIZE=2
                  
                  class Cell(Layout):
                      def __init__(self, *args, **kwargs):
                          super(Cell, self).__init__(*args, **kwargs)
                          with self.canvas:
                              Rectangle(size=self.size, pos=self.pos)
                              Color((0.2, 0.2, 0.2, 1.0))
                  
                  class GameApp(App):
                      def build(self):
                          grid = GridLayout(rows=YSIZE, cols=XSIZE, size=Window.size)
                          for i in xrange(4):
                              print 'i={}'.format(i)
                  #            grid.add_widget(Cell())
                              grid.add_widget(Button(text=str(i)))
                          return grid
                  
                  if __name__ == '__main__':
                      GameApp().run()
                  

                  推薦答案

                  我將展示如何實現(xiàn)這一目標的示例.我將創(chuàng)建一個網(wǎng)格類,并向其中添加單元格小部件.但我只會使用一個畫布(gridlayouts 畫布).所以單元格類將包含一個 InstructionGroup,而不是制作多個畫布.
                  為了以后能夠設(shè)置每個單元格的大小、位置和顏色,這些屬性必須是單元格類的屬性.
                  屬性將在 MyGridset_attributes 方法中設(shè)置.
                  首先,當應用程序運行時,您可以獲得單元格的位置,因此我使用 Clock.schedule_once 方法.這將執(zhí)行下一幀.
                  為了演示如何更改顏色,我創(chuàng)建了一個 Clock.schedule_interval,用隨機顏色為單元格的顏色設(shè)置動畫.

                  I will show an example on how you can achieve this. I will create a grid class, and add the cell widgets to it. But I will only use one canvas (the gridlayouts canvas). So the cell class will contain an InstructionGroup, rather than make multiple canvases.
                  To be able to set size, position and color of each cell later, those attributes must be attributes of the cell class.
                  The attributes will be set in MyGrid's set_attributes method.
                  First when the app is running, you can get the positions of the cells, hence I use the Clock.schedule_once method. That will execute the next frame.
                  And to demonstrate how to change the colors, I create a Clock.schedule_interval, to animate the colors of the cells with random colors.

                  下面是例子:

                  from kivy.app import App
                  from kivy.uix.widget import Widget
                  from kivy.uix.button import Button
                  from kivy.uix.gridlayout import GridLayout
                  from kivy.graphics import Rectangle, Color, InstructionGroup
                  from kivy.clock import Clock
                  
                  from random import uniform
                  
                  XSIZE=2
                  YSIZE=2
                  
                  class Cell(Widget):
                      def __init__(self, i, **kwargs):
                          super(Cell, self).__init__(**kwargs)
                          self.ig = InstructionGroup()
                          self.rect = Rectangle()
                          self.color = Color(0.2, 0.2, 0.2*i)
                          self.ig.add(self.color)
                          self.ig.add(self.rect)
                  
                  
                  
                  class MyGrid(GridLayout):
                      def __init__(self,**kwargs):
                          super(MyGrid,self).__init__(**kwargs)
                          self.rows=YSIZE
                          self.cols=XSIZE
                          for i in xrange(4):
                              self.add_widget(Cell(i))
                              self.canvas.add(self.children[0].ig)
                  
                          Clock.schedule_once(self.set_attributes)
                          Clock.schedule_interval(self.change_color,1)
                  
                      def set_attributes(self,dt):
                          for i in self.children:
                              i.rect.pos = i.pos
                              i.rect.size = i.size
                  
                      def change_color(self,dt):
                          for i in self.children:
                              i.color.rgb = (uniform(0.0,1.0),uniform(0.0,1.0),uniform(0.0,1.0))
                  
                  
                  class GameApp(App):
                      def build(self):
                          return MyGrid()
                  
                  
                  if __name__ == '__main__':
                      GameApp().run()
                  

                  這篇關(guān)于小部件在 GridLayout 中的位置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  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)(你能得到“關(guān)于我嗎?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='10Dyo'></small><noframes id='10Dyo'>

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

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

                              <tbody id='10Dyo'></tbody>
                          • 主站蜘蛛池模板: 国产一区二区三区免费 | 午夜大片| 日韩免费视频一区二区 | 91在线一区 | 911网站大全在线观看 | 国产精品国产成人国产三级 | 中文字幕第一页在线 | 日韩一级免费电影 | 久久久久久久av | 国产精品免费小视频 | 日韩a视频| 一色一黄视频 | 国产欧美精品一区二区 | 国产三级 | 久久精品免费一区二区 | 久久尤物免费一区二区三区 | 日本久久精品视频 | 亚洲成人一区二区 | 精品亚洲永久免费精品 | 一区二区三区精品视频 | 亚洲情侣视频 | 成人在线视频网址 | 国产欧美日韩久久久 | 91高清视频在线观看 | 毛片入口| 国产精品永久免费 | 欧美日韩国产一区二区 | 日本久久网 | 国产精品观看 | 国产成人av一区二区三区 | 日韩成人精品 | 国产伦精品一区二区三区照片91 | 羞羞视频网站在线观看 | 超碰操| 国产免费观看一区 | 亚洲国产二区 | 国产精品污www一区二区三区 | 亚洲最大av | 久久精品亚洲国产 | 亚洲国产一区二区三区 | 欧美成人精品一区 |