-
Book Overview & Buying
-
Table Of Contents
Kivy: Interactive Applications in Python
By :
Before we start, let me introduce the Python code that we will use in most of this chapter's examples:
1. # File name: drawing.py 2. from kivy.app import App 3. from kivy.uix.relativelayout import RelativeLayout 4. 5. class DrawingSpace(RelativeLayout): 6. pass 7. 8. class DrawingApp(App): 9. def build(self): 10. return DrawingSpace() 11. 12. if __name__=="__main__": 13. DrawingApp().run()
We have created the subclass
DrawingSpace from
RelativeLayout. We could have chosen any Widget but we are going to integrate some of these ideas into our comic creator project later on, it is best to use RelativeLayout which the comic creator uses as drawing space.
There are two types of instructions that we can add to a Canvas instance. These instructions are represented by two base classes:
VertexInstructions and ContextInstructions.
The
VertexInstruction subclasses allows us to draw vector shapes in the coordinate space. The
ContexInstruction classes let us apply changes...
Change the font size
Change margin width
Change background colour