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

  • <legend id='XRYTN'><style id='XRYTN'><dir id='XRYTN'><q id='XRYTN'></q></dir></style></legend>

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

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

        <tfoot id='XRYTN'></tfoot>

        kivy自定义小部件绑定错误

        时间:2023-10-09

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

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

                <tbody id='RUCYS'></tbody>
                • <i id='RUCYS'><tr id='RUCYS'><dt id='RUCYS'><q id='RUCYS'><span id='RUCYS'><b id='RUCYS'><form id='RUCYS'><ins id='RUCYS'></ins><ul id='RUCYS'></ul><sub id='RUCYS'></sub></form><legend id='RUCYS'></legend><bdo id='RUCYS'><pre id='RUCYS'><center id='RUCYS'></center></pre></bdo></b><th id='RUCYS'></th></span></q></dt></tr></i><div id='RUCYS'><tfoot id='RUCYS'></tfoot><dl id='RUCYS'><fieldset id='RUCYS'></fieldset></dl></div>

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

                  本文介绍了kivy自定义小部件绑定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试制作一个小型俄罗斯方块游戏,用于使用 kivy 学习 python.我正在尝试创建一个大小为 20,20 的自定义小部件.当我将它添加到浮动布局并运行以下代码时,我收到以下错误:

                  I am trying to make a small tetris game for learning python with kivy. I am trying to create a custom widget with size 20,20. When I add it to the float layout and run the below code I receive the following error:

                  错误:

                  File "D:OS FilesworkspaceTetrisholder.py", line 10, in __init__ self.add_widget(c)
                  File "C:Kivy180kivykivyuixfloatlayout.py", line 115, in add_widget pos_hint=self._trigger_layout)
                  TypeError: descriptor 'bind' of 'kivy._event.EventDispatcher' object needs an argument
                  

                  代码:holder.py 文件:

                  Code: holder.py File:

                  from items import Cell
                  
                  class Holder(FloatLayout):
                      def __init__(self, **kwargs):
                          super(Holder,self).__init__(**kwargs)
                          self.size=(300,300)
                          c=Cell
                          #c.pos= (20,20)
                          self.add_widget(c)
                          #self.add_widget(c)
                  

                  items.py 文件:

                  items.py File:

                  from kivy.uix.widget import Widget
                  from kivy.graphics import *
                  
                  class Cell(Widget):
                      def __init__(self, **kwargs):
                          super(Cell,self).__init__(**kwargs)
                          with self.canvas:
                              Color(1, 0, 0)
                              Rectangle(pos=(0, 0), size=(50, 50))
                  
                          self.height=50
                          self.width=50
                  

                  main.py 文件:

                  main.py File:

                  from kivy.app import App
                  from holder import Holder
                  
                  class start(App):
                      def build(self):
                          return Holder()
                  
                  if __name__ == '__main__':
                      start().run()
                  

                  您能否解释一下我哪里出错了,我被困在起点本身.关于错误,我也没有写任何事件,它只是一个小部件类.能否请您解释一下我在理解 kivy 方面出了什么问题.

                  Could you please explain where I went wrong, I am stuck at the starting point itself. Regarding the error, I haven't written any events also, and it is just a widget class. Could you please explain where I went wrong in understanding kivy.

                  推荐答案

                  c=Cell
                  

                  我打赌你希望 c 成为 Cell 类的一个实例.如果你想这样做,你需要这样做:

                  I bet you want c to be an instance of the Cell class. If you want to do that, you need to do:

                  c=Cell()
                  

                  这篇关于kivy自定义小部件绑定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:`with canvas:` (Python `with something() as x:`) 如何在 Ki 下一篇:在 Kivy 画布上显示 PIL 图像

                  相关文章

                  最新文章

                  1. <i id='iNbJv'><tr id='iNbJv'><dt id='iNbJv'><q id='iNbJv'><span id='iNbJv'><b id='iNbJv'><form id='iNbJv'><ins id='iNbJv'></ins><ul id='iNbJv'></ul><sub id='iNbJv'></sub></form><legend id='iNbJv'></legend><bdo id='iNbJv'><pre id='iNbJv'><center id='iNbJv'></center></pre></bdo></b><th id='iNbJv'></th></span></q></dt></tr></i><div id='iNbJv'><tfoot id='iNbJv'></tfoot><dl id='iNbJv'><fieldset id='iNbJv'></fieldset></dl></div>

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

                    <tfoot id='iNbJv'></tfoot>

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