This tutorial will lead you to learn to create your own widgets (widgets). In the end, the work we finished is a simple artboard program.
When creating an app with Kivy, we need to consider the following 3 questions:
- What data does the app we create need to process?
- How do I visualize this data?
- How do users interact with this data?
Taking the simple artboard of this tutorial as an example, we want users to be able to draw on the touch screen with their fingers, which is how the user interacts with the data. To achieve such an interaction, we need to record the location of the user's finger, which is the data that the application needs to process. Drawing lines between different locations is the way data is presented.
In Kivy applications, the user interface (UI) is made up of a number of widgets. Everything you see on the screen is, in the final analysis, drawn by a widget. Each widget encapsulates data, interaction, and visual presentation of these three elements (that is, the 3 questions that correspond to the previous one). Using a wide range of widgets, we can develop a variety of applications. Although Kivy has built in many parts, such as buttons, sliders, and so on, there are many times when we need to develop custom widgets to meet specific user needs. In this tutorial, Dr. Mi teaches you how to develop custom widgets.
In summary, when developing a custom widget, keep in mind the three elements of the Kivy widget (data, interaction, rendering). At the same time, it is reasonable to plan the function of the window parts, to split the large parts into smaller, reusable parts, that is, to observe the single duty principle (Responsibility Principle).
"Original link"
http://www.ipaomi.com/2017/11/05/kivy-Chinese tutorial-Getting started with an example-simple artboard-simple-paint-app:0-Project Introduction-cheng/
Kivy Chinese Tutorial Example Primer (Simple Paint App): 0. Project Introduction & Results show