# Hello World opens a big window in Sugar. When the user clicks the button,
# the text "Hello World" appears in the Sugar log files.
import logging
from sugar.activity import activity
import sys, os
import gtk
class HelloWorldActivity(activity.Activity):
# hello is the function that writes 'Hello World' into the Sugar log.
def hello(self, widget, data=None):
logging.info('Hello World')
def __init__(self, handle):
activity.Activity.__init__(self, handle)
# Creates a new button with the label "Hello World".
self.button = gtk.Button("Hello World")
# When the button receives the "clicked" signal, it will call the
# function hello() passing it None as its argument. The hello()
# function is defined above.
self.button.connect("clicked", self.hello, None)
# This packs the button into ourselves (a Sugar window).
# self.add(self.button
self.set_canvas(self.button)
# The final step is to display this newly created widget.
self.button.show()
self.set_title('Hello World')