Changes
Jump to navigation
Jump to search
Line 7:
Line 7:
− +
Line 18:
Line 18:
−
Development Team/Almanac/sugar.graphics.toolbutton (view source)
Revision as of 22:10, 1 October 2008
, 22:10, 1 October 2008→How do I create my own custom tool button?
There are several steps you need to follow in order to create a tool button:
There are several steps you need to follow in order to create a tool button:
# Import the ToolButton class from the sugar.graphics.toolbutton package.
# Import the ToolButton class from the sugar.graphics.toolbutton package.
# If you intend to have an icon for your tool button, then create an "icons" directory in your activity directory and put the icon (which is a .svg file) in to that directory. For example, the code below uses an icon called "edit-custom" that accesses an edit-custom.svg file saved in the icons directory for the activity. Here is a link with information on how to create the svg files you will need: [Making_Sugar_Icons]
# If you intend to have an icon for your tool button, then create an "icons" directory in your activity directory and put the icon (which is a .svg file) in to that directory. For example, the code below uses an icon called "edit-custom" that accesses an edit-custom.svg file saved in the icons directory for the activity. Here is a link with information on how to create the svg files you will need: [[Making_Sugar_Icons]]
# Use the code below to guide you on how to then create your button programmatically and add it to a tool bar (we add it to an EditToolbar object that was presumably created already in our code).
# Use the code below to guide you on how to then create your button programmatically and add it to a tool bar (we add it to an EditToolbar object that was presumably created already in our code).
self._edit_toolbar.insert(customButton, -1)
self._edit_toolbar.insert(customButton, -1)
customButton.show()
customButton.show()
=== How do I connect my tool button to a callback? ===
=== How do I connect my tool button to a callback? ===