Kivy tutorial 005: A drawing app – Kivy Blog
Central themes: Canvas instructions
中心主题: canvas 结构
The next couple of tutorials will move to a new application in order to showcase some more of Kivy’s core components. In this tutorial we’ll cover canvas instructions, Kivy’s low level drawing API which is always available. In the next two, we’ll add touch/mouse interaction to let you click to draw stuff, and then introduce kv language, and show how it interacts with Python code to easily produce guis without so much Python boilerplate.
下一个导师课将移动到一个新的应用程序为了展现一些kivy的核心部件。在这节导师课中我们将覆盖canvas结构,kivy的低层画画API, 这ZPI总是适合的。在下两节中,我们将添加 触摸/鼠标 互动来让你点击来画点什么玩意儿,并且然后介绍kv语言, 并且展现它是如何和python语言代码互动的来简单地生产gui,而不是如此多的python引用。
To showcase Kivy’s drawing API, our next app will be a simple drawing application. We’ll be making a widget gui to select a few different options (colour, size etc.), and handling the mouse/touch interaction manually to draw the result of user input.
为了展现kivy的画画API, 我们下一个app将是一个简单地画画应用程序。 我们将使一个组件gui选择一些不同的选择(颜色, 大小等等),并且手动地操控 鼠标/触摸 互动来绘画用户的输入结果。
We’ll need to start with a new basic app template, as introduced in the first couple of tutorials:
我们将需要来同一个基础的app模板开始,就像第一节导师课的介绍的一样:
from kivy.app import App
class DrawingApp(App):
def build(self):
return None
DrawingApp().run()
Before anything else, let’s start by getting some basic drawing working, with no other gui components. There isn’t a Widget for drawing already (there’s no nice way to abstract all the options you might want), so instead Kivy makes it easy to build your own Widget class:
在开始其他的事之前,让我们开始获得一些基础的绘画工作, 没有其它gui组件。 这不是一个组件来绘画(这不是一个好的方式来提取所有你想的选择), 因此替代kivy使它简单来创建你自己的组件类。
from kivy.uix.widget import Width
class DrawingWidget(Widget):
pass
class Dra
Kivy Canvas 教程

最低0.47元/天 解锁文章
392

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



