Kivy – Basics

To create a Kivy application you:

  • create a file called main.py as your entry point
  • subclass from kivy.app.App
  • include a build() method
  • make sure the build method returns a widget (in this case a Label)
  • instantiate an instance of the subclass
  • invoke the run() method of that instance

Example, from the kivy site:

import kivy
kivy.require('1.0.6') # replace with your current kivy version !

from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):

    def build(self):
        return Label(text='Hello world')

if __name__ == '__main__':
    MyApp().run()

Then run python main.py…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: