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

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

      2. <legend id='iDp7b'><style id='iDp7b'><dir id='iDp7b'><q id='iDp7b'></q></dir></style></legend>

      3. 使用自定義小部件 kivy

        Use custom widgets kivy(使用自定義小部件 kivy)
        <tfoot id='2DvC5'></tfoot>
          <bdo id='2DvC5'></bdo><ul id='2DvC5'></ul>

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

            1. <legend id='2DvC5'><style id='2DvC5'><dir id='2DvC5'><q id='2DvC5'></q></dir></style></legend>

              <small id='2DvC5'></small><noframes id='2DvC5'>

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

                  問題描述

                  我正在嘗試使用一些自定義小部件構建一個 kivy 應用程序.但是,每當我嘗試使用它們時,它們都不會與我的布局一起使用.使用普通按鈕:

                  I'm trying to build a kivy app using some custom widgets. However whenever I try to use them they never work with my layout. Using a normal button:

                  import kivy
                  kivy.require('1.8.0')
                  
                  from kivy.app import App
                  from kivy.uix.widget import Widget
                  from kivy.properties import ListProperty
                  
                  class RootWidget(Widget):pass
                  
                  class myApp(App):
                  
                      def build(self):
                          global rw
                          rw  = RootWidget()
                          return rw
                  
                  if __name__ == '__main__':
                      myApp().run()
                  
                  #:kivy 1.8.0
                  
                  <RootWidget>:
                  
                      BoxLayout:
                          size: root.size
                          orientation: 'horizontal'
                          spacing: 10
                          padding: 10
                  
                          Button:
                              id: abut
                              text: "Custom Button"
                  

                  這按預期工作,我的 Button 基本上占據了整個窗口.但是,當我嘗試用我的自定義按鈕替換 Button 時

                  This works as expected, my Button basically takes up the entire window. However when I try replacing the Button with my custom button

                  import kivy
                  kivy.require('1.8.0')
                  
                  from kivy.app import App
                  from kivy.uix.widget import Widget
                  from kivy.properties import ListProperty
                  
                  class MyWidget(Widget):
                  
                       pressed = ListProperty([0, 0])
                  
                       def on_touch_down(self, touch):
                           if self.collide_point(*touch.pos):
                               self.pressed = touch.pos
                               return True
                           return super(MyWidget, self).on_touch_down(touch)
                  
                       def on_pressed(self, instance, pos):
                           print ('pressed at {pos}'.format(pos=pos))
                  
                  class RootWidget(Widget):pass
                  
                  class someApp(App):
                  
                      def build(self):
                          global rw
                          rw  = RootWidget()
                          return rw
                  
                  if __name__ == '__main__':
                      someApp().run()
                  
                  #:kivy 1.8.0
                  
                  <MyWidget>:
                      BoxLayout:
                          orientation: 'horizontal'
                          spacing: 10
                  
                          Button:
                              id: abut
                              text: "Custom Button"        
                  
                  <RootWidget>:
                  
                      BoxLayout:
                          size: root.size
                          orientation: 'horizontal'
                          spacing: 10
                          padding: 10
                  
                          MyWidget:
                  

                  它只出現在窗口的左下角,不像一個按鈕.我錯過了什么?

                  it only appears in the bottom left-hand corner of the window and doesn't behave like a button. What am I missing?

                  此外,是否有必要以這種方式創建自定義按鈕?kivy 教程使用這種方法來制作他們的自定義按鈕,但我不能只做這樣的事情

                  Furthermore, is it even necessary to create a custom button this way? The kivy tutorials used this sort of method to make their custom button but can't I just do something like this

                  Button:
                      on_press: root.do_action()
                  

                  讓每個按鈕的行為不同?

                  to make each button behave differently?

                  推薦答案

                  你的實際問題是,雖然你的 MyWidget 放在了 kv 文件中的一個 BoxLayout 中,但它的子 BoxLayout 確實 not 將其大小設置為 MyWidget 大小,因此只保持 (100,100) 在屏幕的左下方.

                  Your actual problem is that although your MyWidget is placed in a BoxLayout in the kv file, its child BoxLayout does not have its size set to the MyWidget size, and therefore just maintains the default size and position of (100, 100) in the bottom left of the screen.

                  你可以通過給它額外的 size: root.size 規則來解決這個問題,就像你在 <RootWidget> 規則中所做的那樣,或者實際上通常更容易使用 BoxLayout(即子類 BoxLayout 而不是 Widget)當然可以免費自動調整大小/定位.

                  You can fix this by giving it the extra size: root.size rule as you did within the <RootWidget> rule, or actually normally it's easier to just use a BoxLayout (i.e. subclass BoxLayout instead of Widget) which of course gives you the automatic resizing/positioning for free.

                  另外,正如 Joran 所說,如果您只想在按下按鈕時做某事,您可以使用第二種方法……這就是您想要做的!我不知道你在看什么例子,但你通常不需要像你這樣的復雜安排.

                  Also, as Joran said, if you just want to do something when the button is pressed you can use the second method...that's what you're intended to do! I don't know what example you are looking at, but you wouldn't normally need a complex arrangement like yours.

                  您可能還想知道,在最新版本 (1.8) 中,按鈕行為已被抽象為處理檢測觸摸和調度 on_pressButtonBehavior 類等適當.Behavior 不是小部件,因此您可以將其與任何其他小部件子類化以將任何東西變成按鈕!

                  You might also be interested to know that in the most recent release (1.8) the button behavior has been abstracted to a ButtonBehavior class that handles detecting touches and dispatching on_press etc. appropriately. The Behavior isn't a widget, so you can subclass it with any other widget to make anything into a button!

                  這篇關于使用自定義小部件 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='KXQ0x'></tfoot>

                        <tbody id='KXQ0x'></tbody>

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

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

                          • <small id='KXQ0x'></small><noframes id='KXQ0x'>

                            主站蜘蛛池模板: 少妇黄色 | 午夜久久久 | 一级黄色片在线看 | 凹凸日日摸日日碰夜夜 | 全部免费毛片在线播放网站 | 久久久亚洲精品视频 | 日本久久网站 | 91免费在线 | 日韩一区不卡 | 亚洲图片一区二区三区 | 一区二区中文字幕 | 黄色精品| 中文字幕亚洲区一区二 | 成年人在线观看视频 | 欧美群妇大交群中文字幕 | 色综合天天天天做夜夜夜夜做 | 成人黄色电影在线观看 | 国产精品一级 | 国产精品毛片无码 | 一区二区久久精品 | 免费在线观看一区二区三区 | 国产一级一级毛片 | xxx视频| 午夜精品视频在线观看 | 亚洲欧美成人影院 | 国内精品久久久久 | 日本三级视频 | 99热精品在线观看 | 精品成人免费一区二区在线播放 | 久久久国产精品一区 | 久久久久久免费免费 | 国产精品久久久久久久久图文区 | 精品国产一区二区三区久久影院 | 国产精品日韩欧美一区二区三区 | 亚洲国产精品成人久久久 | 免费在线观看黄色av | 一区二区日韩 | 午夜影院污| 超碰免费在 | 在线看亚洲 | 最新国产精品精品视频 |