Hello World for the Icon

Our first introduction for programming for the Icon will be Hello World. It will launch an application and connect to the Icon Shell and contain one menu item.

To run this on the Icon, first copy the code below into a file and save it as hello.py
Copy the file over to the Icon
Either log into the console through ssh or go into the console through the utils menu
Go to the directory where you put hello.py and run the following command:
python hello.py

If your Icon said Hello World, then Congratulations you have begun developing for the Icon.


#!/usr/bin/env python

from levelstar.sbtk import *

class HelloApp(app.App):
  def __init__(self):
    app.App.__init__(self,title='Hello World',id='hello')
    self.__initMenus__()

  def onActivate(self):
    self.app.say("Hello World")

  def __initMenus__(self):
    self.setAppMenuTitle('Hello World Menu')
    self.appendAppMenuItem('Hello Item',self.MenuItem)

  def MenuItem(self):
    self.app.say('Hello Hello Hello')

if __name__ == "__main__":
  HelloApp().start('Hello World')