User Tools

Site Tools


doc:appunti:prog:kivy

This is an old revision of the document!


Appunti Kivy

This is the kivyexample.py file:

#!/usr/bin/env python
 
from kivy.app import App
#kivy.require("1.8.0")
from kivy.uix.floatlayout import FloatLayout
 
class MyLayout(FloatLayout):
    pass
 
class KivyExampleApp(App):
    def build(self):
        return MyLayout()
 
if __name__ == "__main__":
    KivyExampleApp().run()

This is the kivyexample.kv file:

<MyButton@Button>:
    font_size: 40
    color: 0,1,0,1
    size_hint: 0.3, 0.2

<MyLayout>:
    MyButton:
        text: "Pos 0, 0"
        pos_hint: {'x': 0, 'y': 0}
    MyButton:
        text: "Center x-y"
        pos_hint: {'center_x': 0.5, 'center_y': 0.5}
    MyButton:
        text: "Center right-top"
        pos_hint: {'right': 0.9, 'top': 0.3}
    MyButton:
        text: "Pos 0.5, 1.0"
        pos_hint: {'right': 0.5, 'top': 1.0}
doc/appunti/prog/kivy.1551089497.txt.gz · Last modified: 2019/02/25 11:11 by niccolo