Sugar Code Snippets: Difference between revisions
Jump to navigation
Jump to search
(Added toolbar example.) |
m (categorization) |
||
Line 30: | Line 30: | ||
button2.connect("activated", self._button2_activated_cb) |
button2.connect("activated", self._button2_activated_cb) |
||
self.append(button2) |
self.append(button2) |
||
[[Category:HowTo]] |
Revision as of 21:47, 7 February 2007
Toolbar
This snippet shows how an activity would have a toolbar with two buttons:
import hippo from sugar.activity.Activity import Activity from sugar.graphics.toolbar import Toolbar from sugar.graphics.button import Button class FooActivity(Activity): def __init__(self): Activity.__init__(self) canvas = hippo.Canvas() self.add(canvas) canvas.show() vbox = hippo.CanvasBox() canvas.set_root(vbox) toolbar = Toolbar() vbox.append(toolbar) button1 = Button('button1_icon') button1.connect("activated", self._button1_activated_cb) self.append(button1) button2 = Button('button2_icon') button2.connect("activated", self._button2_activated_cb) self.append(button2)