diff options
Diffstat (limited to 'toolbar_utils.py')
-rw-r--r-- | toolbar_utils.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/toolbar_utils.py b/toolbar_utils.py index 563147e..788817d 100644 --- a/toolbar_utils.py +++ b/toolbar_utils.py @@ -11,12 +11,12 @@ # Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA -import gtk +from gi.repository import Gtk -from sugar.graphics.radiotoolbutton import RadioToolButton -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.combobox import ComboBox -from sugar.graphics.toolcombobox import ToolComboBox +from sugar3.graphics.radiotoolbutton import RadioToolButton +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.combobox import ComboBox +from sugar3.graphics.toolcombobox import ToolComboBox def combo_factory(combo_array, toolbar, callback, cb_arg=None, @@ -32,7 +32,7 @@ def combo_factory(combo_array, toolbar, callback, cb_arg=None, for i, selection in enumerate(combo_array): combo.append_item(i, selection, None) combo.show() - toolitem = gtk.ToolItem() + toolitem = Gtk.ToolItem() toolitem.add(combo) if hasattr(toolbar, 'insert'): # the main toolbar toolbar.insert(toolitem, -1) @@ -46,13 +46,13 @@ def combo_factory(combo_array, toolbar, callback, cb_arg=None, def entry_factory(default_string, toolbar, tooltip=None, max=3): ''' Factory for adding a text box to a toolbar ''' - entry = gtk.Entry() + entry = Gtk.Entry() entry.set_text(default_string) if tooltip is not None and hasattr(entry, 'set_tooltip_text'): entry.set_tooltip_text(tooltip) entry.set_width_chars(max) entry.show() - toolitem = gtk.ToolItem() + toolitem = Gtk.ToolItem() toolitem.add(entry) if hasattr(toolbar, 'insert'): # the main toolbar toolbar.insert(toolitem, -1) @@ -105,12 +105,12 @@ def radio_factory(button_name, toolbar, callback, cb_arg=None, tooltip=None, def label_factory(toolbar, label_text, width=None): ''' Factory for adding a label to a toolbar ''' - label = gtk.Label(label_text) + label = Gtk.Label(label=label_text) label.set_line_wrap(True) if width is not None: label.set_size_request(width, -1) # doesn't work on XOs label.show() - toolitem = gtk.ToolItem() + toolitem = Gtk.ToolItem() toolitem.add(label) if hasattr(toolbar, 'insert'): # the main toolbar toolbar.insert(toolitem, -1) @@ -122,7 +122,7 @@ def label_factory(toolbar, label_text, width=None): def separator_factory(toolbar, expand=False, visible=True): ''' add a separator to a toolbar ''' - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() separator.props.draw = visible separator.set_expand(expand) if hasattr(toolbar, 'insert'): # the main toolbar @@ -134,9 +134,9 @@ def separator_factory(toolbar, expand=False, visible=True): def image_factory(image, toolbar, tooltip=None): ''' Add an image to the toolbar ''' - img = gtk.Image() + img = Gtk.Image() img.set_from_pixbuf(image) - img_tool = gtk.ToolItem() + img_tool = Gtk.ToolItem() img_tool.add(img) if tooltip is not None: img.set_tooltip_text(tooltip) @@ -149,12 +149,12 @@ def image_factory(image, toolbar, tooltip=None): def spin_factory(default, min, max, callback, toolbar): - spin_adj = gtk.Adjustment(default, min, max, 1, 32, 0) - spin = gtk.SpinButton(spin_adj, 0, 0) + spin_adj = Gtk.Adjustment(default, min, max, 1, 32, 0) + spin = Gtk.SpinButton(spin_adj, 0, 0) spin_id = spin.connect('value-changed', callback) spin.set_numeric(True) spin.show() - toolitem = gtk.ToolItem() + toolitem = Gtk.ToolItem() toolitem.add(spin) if hasattr(toolbar, 'insert'): # the main toolbar toolbar.insert(toolitem, -1) |