Kivy tutorial 003: Building a full GUI – Kivy Blog
Central themes: Adding Widgets to one another
中心主题: 添加组件到另一个组件中
The tutorals so far have covered the very basics of a Kivy application; getting everything running, adding a Widget (the Label), and doing some customisation.
到目前为止,导师课已经涵盖了Kivy应用程序非常基本的元素;让所有的一切跑起来, 增加一个组件(label 标签),和做了一些个性化。
Let’s now combine some widgets to make a larger GUI. This tutorial will solely cover joining the widgets together, not making them do anything; this is covered in later tutorials.
现在让我们结合一些组件来制作一个更大GUI。 这节导师将单独地覆盖连接组件们到一起,不让它们干任何事, 以后的导师课会有涉及干其他的事。
Note
This tutorial will construct the GUI using entirely Python code. You can always do this with Python as described here, but normally we recommend using the easier, clearer and more concise kv language to construct widget trees. This will be covered fully in later tutorials.
这节导师课将构建GUI 通过整个使用Python代码。 你总是可以像python描述的这样干,但是常见的是我们使用更简单、清晰和更简洁的KV语言来重新命令构建组件树。这在以后的导师课中会被覆盖。
Our new task will be to build a simple calculator app; we’ll need Buttons for each of the numbers and mathematical operations, and a Label to display the result.
我们新的任务是构建一个简单地计算机app;我们将需要Buttons按钮给每个数字,并且自动地业务操作,和一个标签来展示结果。
Let’s start with a new basic app structure:让我们开始一个简单的app结构:
from kivy.app import App
class YourApp(App):
def build(self):
return None
YourApp().run()
Right now, you can run the code but the window will be empty because we didn’t add any widgets. Let’s do that now, but we no longer want just a Label; our app will be made of multiple Widgets next to one another. For this, we use Layout classes; let’s start with the following:
现在,你可以运行代码,但是窗口将是空的因为我们没有添加

最低0.47元/天 解锁文章
1944

被折叠的 条评论
为什么被折叠?



