KVLang Series – 1 – Hello World Label Widget

KVLang Series – 1

← Previous              Next →

Hello World Label Widget

Content:
– .kv file
– .py file
– screenshot of output

0001_helloWorld.kv

Here is the .kv == KVLang file for our hello world. It generates a GIGANTIC window containing a Kivy Builtin Label that says, “Hello, world.”

Label:
    text: 'Hello, world.'

0001_helloWorld.py

Here is a SIMPLE and what I believe is the MINIMAL, MOST GENERIC, python file to show our KVLang window. Hopefully this is a starting point template for KVLang projects.

This is adapted from:

''' 0001_helloWorld.py 
A simple, general starting point Python template for KVLang projects.
'''
import kivy
kivy.require('1.8.0') # replace with your current kivy version !

from kivy.app import App
from kivy.lang import Builder

class MyApp(App):

    def build(self):
        self.root = Builder.load_file('0001_helloWorld.kv')
        return self.root

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

0001_helloWorld ScreenShot

Here is what this looks like run on Windows XP. In Pixels, it has:
– width: 808
– height: 634

Alt 0001_helloWorld.png

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