November 2018
Beginner
304 pages
7h 35m
English
Now that we have the logic for how the GUI is supposed to function, we can actually write the code to place the widgets where we want on the diagram. You could do this within the Python file that we just created, but best practice is to separate code logic from presentation. For example, the following code from the official Kivy tutorial shows how a Python file could both accept a touch from a finger and create a small dot on the screen of a tablet:
def on_touch_down(self, touch): with self.canvas: Color(1, 1, 0) d = 30. Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
For our purposes, we will write a special .kv file to hold the layout-specific information and keep the Python logic in hmilayout.py:
# hmi.kv ...Read now
Unlock full access