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

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

    1. <tfoot id='g5cZ7'></tfoot>

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

      1. 将屏幕与 kivy 中的 GridLayout 类相关联

        时间:2023-10-10
        <legend id='YJEMI'><style id='YJEMI'><dir id='YJEMI'><q id='YJEMI'></q></dir></style></legend>
          <bdo id='YJEMI'></bdo><ul id='YJEMI'></ul>

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

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

                <tbody id='YJEMI'></tbody>
                • 本文介绍了将屏幕与 kivy 中的 GridLayout 类相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我创建了一个 ScreenManager,并为该 ScreenManager 创建了几个 Screen 实例.

                  I've created a ScreenManager, and created several Screen instances for that ScreenManager.

                  我希望每个屏幕都显示一个 GridLayout 类.例如,假设您有:

                  I'd like each Screen to display a GridLayout class. For example, let's say you have:

                  class MainScreen(Screen):
                     ...
                  
                  class MainLayout(GridLayout):
                     ...
                  

                  当 MainScreen 是活动屏幕时,我希望显示 MainLayout.

                  When MainScreen is the active screen, I'd like MainLayout to be shown.

                  有没有办法纯粹在 python 中做到这一点(即没有标记)?谢谢.

                  Is there a way to do this purely in python (i.e. without markup)? Thank you.

                  推荐答案

                  有没有办法纯粹在 python 中做到这一点(即没有标记)?谢谢.

                  Is there a way to do this purely in python (i.e. without markup)? Thank you.

                  您永远不需要使用 kivy 语言(我假设这就是您所说的标记的意思),但强烈建议尽可能使用它,因为它使很多事情变得更容易.

                  You never need to use kivy language (I assume that's what you mean by markup), though it's highly recommended where possible because it makes lots of stuff easier.

                  不过,要真正回答您的问题,您只需将 gridlayout 小部件添加到屏幕小部件,例如

                  Nonetheless, to actually answer your question, all you have to do is add your gridlayout widget to your screen widget, something like

                  mainscreen = MainScreen()
                  mainlayout = MainLayout()
                  mainscreen.add_widget(mainlayout)
                  

                  然后,当您在屏幕管理器中将当前屏幕设置为主屏幕时,您应该会看到 GridLayout.

                  Then when you set the current screen in your screenmanager to be mainscreen, you should see the GridLayout.

                  如果不清楚,这通常是您将小部件添加到其他小部件的方式.当你看到一个 kv 语言的例子时,比如

                  In case it's unclear, this is in general the way you add widgets to other widgets. When you see an example in kv language like

                  <MyScreen>:
                       GridLayout:
                           ...
                  

                  ...最终,它被翻译成与上面的示例代码非常相似的内容 - 创建了一个 MyScreen 实例,并使用 add_widget 向其中添加了一个 GridLayout.

                  ...ultimately that gets translated to something much like the above example code - an instance of MyScreen is created and a GridLayout is added to it with add_widget.

                  这篇关于将屏幕与 kivy 中的 GridLayout 类相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何让kivy复选框传递它的状态 下一篇:Kivy 错误:属性错误:“无类型"对象没有属性“

                  相关文章

                  最新文章

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

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

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

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