Sugar.graphics.toolbox

From OLPC

Jump to: navigation, search
  Sugar Almanac

Sugar Almanac for Developers

Sugar Almanac Main Page

Package: sugar

sugar.env

sugar.profile

sugar.mime

Package: sugar.activity

sugar.activity.activity

sugar.activity.registry

Package: sugar.graphics

sugar.graphics.alert

sugar.graphics.toolbutton

sugar.graphics.toolbox

Package: sugar.datastore

sugar.datastore.datastore

Logging

sugar.logger

Notes on using Python Standard Logging in Sugar

Internationalization

Internationalization in Sugar

Contents

Class: Toolbox(gtk.VBox)

How do I retrieve the index of the current toolbar in the toolbox?

Toolboxes arrange toolbars in some order and assign each toolbar to an index. Currently, the implementation appends newly added toolbars to the end of a list, so integral indexes for toolbars are incremented by one for each new toolbar. The following code fragment shows how to get the index of a toolbar in your toolbox:

       #retrieve the index of the active toolbar in toolbox
       toolbarNum = toolbox.get_current_toolbar()

How do I add a toolbar to a toolbox?

Toolbars can be added to a toolbox using add_toolbar(). Just provide a name for the toolbar as well as a handle on the toolbar object that has been created.

       # Add the edit toolbar:
       toolbox.add_toolbar(_('Edit'), self._edit_toolbar)

How do I remove a toolbar from a toolbox?

In order to remove a toolbar from a toolbox, you first need to know the index of that toolbar so you can pass it to the remove_toolbar() method. Once you know this, you can run something like:

       #Remove the toolbar with index number 1. 
       toolbox.remove_toolbar(1)

How do I programmatically change the active toolbar in a toolbox?

The "set_current_toolbar()" method in the ToolBox class allows you to programmatically set which toolbar is active.

       #Set the active toolbar using an integer index assigned to each toolbar in your activity. 
       self.toolbox.set_current_toolbar(1);


How do I remove the separator at the bottom of my toolbar?

In your activity subclass, do the following:

self.toolbox = activity.ActivityToolbox(self)
self.set_toolbox(self.toolbox)
self.toolbox.remove(self.toolbox._separator)
Personal tools
  • Log in
  • Login with OpenID
About OLPC
About the laptop
About the tablet
Projects
OLPC wiki
Toolbox