问题描述
我正在尝试通过实现
问:如何配置 drawingspace.kv
以使每个按下的按钮具有不同的布局和不同的小部件?
一个巧妙的方法是使用屏幕.
由于我已经从您之前的问题中获得了此应用程序的示例,因此很容易实现屏幕,并稍微重写类.
当按下按钮时,您将屏幕管理器的当前设置为您想要的屏幕名称.
然后您只需在每个屏幕、kv 文件或 python 文件中根据需要编辑布局.
我选择在这里用 kv 语言制作大部分布局内容.因为我发现以我想要的方式开发布局更容易.以后如果我愿意,我可以将它重写为 python.
所以我的 python 文件现在看起来像这样:
而 kv.kv 文件看起来像这样:
I am trying create a GUI by implementing the template of the ComicCreator GUI sample as a template for my own project. The code is easy to follow, but I would like to be able to reconfigure the drawingspace.kv
, each time a button is pushed, say for example something like this:
Q: How could I configure the drawingspace.kv
to have a different layout with different widgets for each button that is pressed?
A neat way to do this is to use screen.
Since I allready have an example of this app from you earlier question, it was easy to implement the screens, and rewrite the classes a bit.
When a button is pressed, you set the screenmanager's current to whatever the name you named the screen you want.
Then you just edit the layouts as you want inside of each screen, in the kv file, or python file.
I choose to make most of the layout stuff in kv language here. Because I find it easier to develop a layout the way I want it this way. Later I could rewrite it to python if I want that.
So my python file looks like this now:
And kv.kv file looks like this:
这篇关于用kivy按下按钮时如何更改空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!