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

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

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

      <tfoot id='YQtXh'></tfoot>
      <i id='YQtXh'><tr id='YQtXh'><dt id='YQtXh'><q id='YQtXh'><span id='YQtXh'><b id='YQtXh'><form id='YQtXh'><ins id='YQtXh'></ins><ul id='YQtXh'></ul><sub id='YQtXh'></sub></form><legend id='YQtXh'></legend><bdo id='YQtXh'><pre id='YQtXh'><center id='YQtXh'></center></pre></bdo></b><th id='YQtXh'></th></span></q></dt></tr></i><div id='YQtXh'><tfoot id='YQtXh'></tfoot><dl id='YQtXh'><fieldset id='YQtXh'></fieldset></dl></div>
      1. 如何从 Python 代码文件中设置 kivy 小部件 id

        时间:2023-10-09
      2. <i id='mPzvZ'><tr id='mPzvZ'><dt id='mPzvZ'><q id='mPzvZ'><span id='mPzvZ'><b id='mPzvZ'><form id='mPzvZ'><ins id='mPzvZ'></ins><ul id='mPzvZ'></ul><sub id='mPzvZ'></sub></form><legend id='mPzvZ'></legend><bdo id='mPzvZ'><pre id='mPzvZ'><center id='mPzvZ'></center></pre></bdo></b><th id='mPzvZ'></th></span></q></dt></tr></i><div id='mPzvZ'><tfoot id='mPzvZ'></tfoot><dl id='mPzvZ'><fieldset id='mPzvZ'></fieldset></dl></div>

        <legend id='mPzvZ'><style id='mPzvZ'><dir id='mPzvZ'><q id='mPzvZ'></q></dir></style></legend>

              <tbody id='mPzvZ'></tbody>
            • <bdo id='mPzvZ'></bdo><ul id='mPzvZ'></ul>

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

                <tfoot id='mPzvZ'></tfoot>
                  本文介绍了如何从 Python 代码文件中设置 kivy 小部件 id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要帮助将 id 分配给从 python 函数创建的新 kivy 小部件

                  I need help assigning ids to new kivy widgets that are created from a python function

                  我试过了:

                  old = Label(id = 'old')
                  

                  和:

                  old = Label()
                  old.id = 'old'
                  

                  但它似乎不起作用,因为每当我尝试引用小部件时,它都会给我一个错误

                  but it doesn't seem to work because, whenever i try referencing the widgets, it gives me an error

                  推荐答案

                  您在 Python 代码中创建 id 的方式是正确的.

                  The ways that you have creating id in Python code are correct.

                  但是您不能使用 self.ids.oldself.ids['old'] 来引用它们,因为它们在 self.ids 中不存在.self.ids 字典类型属性仅包含所有带有在 kv 文件中定义的 id 标记的小部件.

                  But you cannot reference them using self.ids.old or self.ids['old'] because they don't exist in self.ids. The self.ids dictionary type property contains only all widgets tagged with ids defined inside kv file.

                  要引用 Python 代码中定义的 id,在本例中使用 self.old.

                  To reference id defined in Python code, in this example use self.old.

                  在你的 python 代码中访问 Kv lang 中定义的小部件

                  当您的 kv 文件被解析时,kivy 会收集所有标记为的小部件id 并将它们放在这个 self.ids 字典类型属性中.那意味着您还可以遍历这些小部件并访问它们字典样式.

                  When your kv file is parsed, kivy collects all the widgets tagged with id’s and places them in this self.ids dictionary type property. That means you can also iterate over these widgets and access them dictionary style.

                  这篇关于如何从 Python 代码文件中设置 kivy 小部件 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

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