Sugar.graphics.icon

From OLPC
Revision as of 12:04, 10 July 2008 by 155.212.201.242 (talk) (Class: Icon)
Jump to: navigation, search

Class: Icon

How do I create a button with a specific icon image?

You must first create the appropriately sized Icon object, as shown below. Then you will use the set_image() method to assign the icon to the button.

import pygtk
pygtk.require('2.0')
import gtk
from sugar.graphics.icon import Icon
...
        #previous page button
        prev_page_button = gtk.Button()
        prev_page_icon = Icon(icon_name='prev-page', icon_size=gtk.ICON_SIZE_BUTTON)
        prev_page_button.set_image(prev_page_icon)

Class: CanvasIcon