Line 1: |
Line 1: |
| {{OLPC}} | | {{OLPC}} |
| {{Translations}} | | {{Translations}} |
| + | |
| + | == WebView == |
| + | Use the WebView in a widget. |
| + | import os |
| + | import hulahop |
| + | from sugar import env |
| + | hulahop.startup(os.path.join(env.get_profile_path(), 'gecko')) |
| + | |
| + | from hulahop.webview import WebView |
| + | |
| + | import gtk |
| + | |
| + | win = gtk.Window(gtk.WINDOW_TOPLEVEL) |
| + | win.set_size_request(800,600) |
| + | win.connect('destroy', gtk.main_quit) |
| + | wv = WebView() |
| + | wv.load_uri('http://wiki.laptop.org/go/Guido_van_Robot') |
| + | wv.show() |
| + | |
| + | win.add(wv) |
| + | |
| + | win.show() |
| + | gtk.main() |
| + | |
| + | === Notes === |
| + | * I'm not sure what the purpose is of the call to hulahop.startup as the documentation is rather sparse. I only knows it's needed to get it to work [[User:Stas_z|Stas Zytkiewicz]] 2 Dec 2007 |
| + | |
| == Toolbar == | | == Toolbar == |
| | | |
| === Toolbar icons === | | === Toolbar icons === |
| | | |
− | button = sugar.graphics.toolbutton.ToolButton("some-icon-name") | + | Setting a standard Sugar toolbar. |
− | button.show()
| + | from sugar.activity import activity |
− | toolbar.insert(button,-1)
| + | ... |
| + | class MyActivity(activity.Activity): |
| + | ... |
| + | toolbox = activity.ActivityToolbox(self) |
| + | self.set_toolbox(toolbox) |
| + | toolbox.show() |
| + | |
| + | Adding a custom toolbar and icons. |
| + | from sugar.graphics.toolbutton import ToolButton |
| + | from sugar.activity import activity |
| + | ... |
| + | class MyActivity(activity.Activity): |
| + | ... |
| + | mytoolbox = gtk.Toolbar(self) |
| + | helpbut = ToolButton('help')#Stock help icon |
| + | helpbut.set_tooltip(_("Get help")) |
| + | helpbut.connect('clicked', self.help_button_pressed) |
| + | mytoolbox.insert(helpbut, -1) |
| + | helpbut.show() |
| + | mytoolbox.show() |
| + | |
| + | toolbox = activity.ActivityToolbox(self) |
| + | toolbox.add_toolbar("mytoolbar",mytoolbox) |
| + | self.set_toolbox(toolbox) |
| + | toolbox.show() |
| | | |
| In addition to the standard icons in /usr/share/icons/sugar/scalable/ (eg, "go-next"), you can create additional icons by putting an svg in your activity's icons/ directory. Eg, | | In addition to the standard icons in /usr/share/icons/sugar/scalable/ (eg, "go-next"), you can create additional icons by putting an svg in your activity's icons/ directory. Eg, |
| icons/my-icon.svg | | icons/my-icon.svg |
− | | + | And the then use it. |
− | === Other notes === | + | mybut = ToolButton('my-icon')# without extension |
− | *Do ''not'' use sugar.graphics.toolbar and its Toolbar. It is old broken left-over code, now deleted. [[User:MitchellNCharity|MitchellNCharity]] 17:06, 21 June 2007 (EDT)
| |
| | | |
| == Files == | | == Files == |