This post describes how to use gtk.Notebook widget within a Sugar Activity.
In this blog you can find how to use gtk.Notebook widget to create PyGTK application native to GNOME. Now we will consider how sugar shell understands this Notebook widget and renders it for Sugar Desktop Environment.
Consider we have sugar activity DevelopWeb with following directory structure:
Here we have created weblib.py to include class WebToolBox that renders a toolbox on left hand side pane and tabbed container, i.e. Notebook on right side pane. Note that we are using HBox to hold this WebToolbox and Notebook widgets. Since there are only two widgets added to HBox we are using terms left side pane and right side pane.
weblib.py looks like this:
Now we add the pages to this notebook instance using a custom method "addPage"(Refer to image below). You can see in the definition that a page is a container HBox as immediate child of Notebook within a page. Each page requires a Label widget as page label:
The basic activity file looks like :
Now when you create symbolic link for this activity using : python setup.py dev the Sugar Desktop Environment can use this activity.
When you start Sugar session you can see DevelopWeb activity:
When you launch this activity you can see elementBox on left side and Notebook on right side with two tabs or pages in it:
This example shows how you can use Notebook, the tabbed container in your sugar activity. I hope this post helps you.
Stay tuned for more Sugar Action !