本文整理汇总了Python中sugar3.graphics.toolbutton.ToolButton类的典型用法代码示例。如果您正苦于以下问题:Python ToolButton类的具体用法?Python ToolButton怎么用?Python ToolButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ToolButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TitleBox
class TitleBox(VolumesToolbar):
__gtype_name__ = 'TitleBox'
def __init__(self):
VolumesToolbar.__init__(self)
label = Gtk.Label()
label.set_markup('<b>%s</b>' % _('Choose an object'))
label.set_alignment(0, 0.5)
self._add_widget(label, expand=True)
self.close_button = ToolButton(icon_name='dialog-cancel')
self.close_button.set_tooltip(_('Close'))
self.insert(self.close_button, -1)
self.close_button.show()
def _add_widget(self, widget, expand=False):
tool_item = Gtk.ToolItem()
tool_item.set_expand(expand)
tool_item.add(widget)
widget.show()
self.insert(tool_item, -1)
tool_item.show()
示例2: __init__
def __init__(self):
Gtk.Toolbar.__init__(self)
book_search_item = Gtk.ToolItem()
self.search_entry = Gtk.Entry()
self.search_entry.connect('activate', self.search_entry_activate_cb)
self.search_entry.connect("key_press_event", self.keypress_cb)
width = int(Gdk.Screen.width() / 2)
self.search_entry.set_size_request(width, -1)
book_search_item.add(self.search_entry)
self.search_entry.show()
self.search_entry.grab_focus()
self.insert(book_search_item, -1)
book_search_item.show()
self.download = ToolButton('go-down')
self.download.set_tooltip(_('Get Book'))
self.download.props.sensitive = False
self.download.connect('clicked', self.get_book_cb)
self.insert(self.download, -1)
self.download.show()
self.hide_results = ToolButton('dialog-cancel')
self.hide_results.set_tooltip(_('Remove Results List'))
self.hide_results.props.sensitive = False
self.hide_results.connect('clicked', self.hide_results_cb)
self.insert(self.hide_results, -1)
self.hide_results.show()
示例3: __init__
def __init__(self):
ToolButton.__init__(self)
self._property = 'timestamp'
self._order = Gtk.SortType.ASCENDING
self.props.tooltip = _('Sort view')
self.props.icon_name = 'view-lastedit'
self.props.hide_tooltip_on_click = False
self.palette_invoker.props.toggle_palette = True
menu_box = PaletteMenuBox()
self.props.palette.set_content(menu_box)
menu_box.show()
sort_options = [
('timestamp', 'view-lastedit', _('Sort by date modified')),
('creation_time', 'view-created', _('Sort by date created')),
('filesize', 'view-size', _('Sort by size')),
]
for property_, icon, label in sort_options:
button = PaletteMenuItem(label)
button_icon = Icon(pixel_size=style.SMALL_ICON_SIZE,
icon_name=icon)
button.set_image(button_icon)
button_icon.show()
button.connect('activate',
self.__sort_type_changed_cb,
property_,
icon)
button.show()
menu_box.append_item(button)
示例4: __init__
def __init__(self):
Gtk.Toolbar.__init__(self)
self._zoom_out = ToolButton('zoom-out')
self._zoom_out.set_tooltip(_('Zoom out'))
self._zoom_out.connect('clicked', self._zoom_out_cb)
self.insert(self._zoom_out, -1)
self._zoom_out.props.sensitive = False
self._zoom_out.show()
self._zoom_in = ToolButton('zoom-in')
self._zoom_in.set_tooltip(_('Zoom in'))
self._zoom_in.connect('clicked', self._zoom_in_cb)
self.insert(self._zoom_in, -1)
self._zoom_in.props.sensitive = True
self._zoom_in.show()
spacer = Gtk.SeparatorToolItem()
spacer.props.draw = False
self.insert(spacer, -1)
spacer.show()
self._fullscreen = ToolButton('view-fullscreen')
self._fullscreen.set_tooltip(_('Fullscreen'))
self._fullscreen.connect('clicked', self._fullscreen_cb)
self.insert(self._fullscreen, -1)
self._fullscreen.show()
示例5: BasicToolbar
class BasicToolbar(Gtk.Toolbar):
def __init__(self, title):
GObject.GObject.__init__(self)
self.modify_bg(Gtk.StateType.NORMAL,
style.COLOR_BLACK.get_gdk_color())
label = Gtk.Label()
label.set_markup('<b>%s</b>' % title)
label.set_halign(Gtk.Align.START)
tool_item = Gtk.ToolItem()
tool_item.set_expand(True)
tool_item.add(label)
tool_item.show_all()
tool_item.props.margin_left = style.GRID_CELL_SIZE / 2
self.insert(tool_item, -1)
self.separator = Gtk.SeparatorToolItem()
self.separator.props.draw = False
self.separator.set_expand(True)
self.insert(self.separator, -1)
self.stop = ToolButton(icon_name='dialog-cancel')
self.stop.set_tooltip(_('Cancel'))
self.insert(self.stop, -1)
self.stop.show()
示例6: make_toolbar
def make_toolbar(self):
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
self._go_home = ToolButton('go-home')
self._go_home.set_tooltip(_('Home page'))
self._go_home.connect('clicked', self._go_home_cb)
toolbar_box.toolbar.insert(self._go_home, -1)
self._go_home.show()
self._browse = ToolButton('browse')
self._browse.set_tooltip(_('Open in Browse'))
self._browse.connect('clicked', self._do_browse_clicked_cb)
toolbar_box.toolbar.insert(self._browse, -1)
self._browse.show()
separator=Gtk.SeparatorToolItem(draw=False)
separator.set_expand(True)
toolbar_box.toolbar.insert(separator,-1)
separator.show()
stop_button = StopButton(self)
toolbar_box.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
示例7: __init__
def __init__(self, child, label, path, tabs):
GObject.GObject.__init__(self)
self.child = child
self.label_text = label
self._path = path # Hide the path in the label
self.tabs = tabs
self.label_box = Gtk.EventBox()
self._label = Gtk.Label(label=self.label_text)
self._label.set_alignment(0, 0.5)
self._label.show()
self.label_box.add(self._label)
self.label_box.connect('button-press-event', self._label_clicked)
self.label_box.show_all()
self.pack_start(self.label_box, True, True, 5)
self.label_entry = Gtk.Entry()
self.label_entry.connect('activate', self._label_entry_cb)
self.label_entry.connect('focus-out-event', self._label_entry_cb)
self.pack_start(self.label_entry, True, True, 0)
button = ToolButton('close-tab')
button.connect('clicked', self.__button_clicked_cb)
self.pack_start(button, False, True, 0)
button.show()
self._close_button = button
tab_object.append(self)
示例8: add_button
def add_button(icon_name, tooltip, func):
def callback(source):
func()
button = ToolButton(icon_name)
toolbar.add(button)
button.connect('clicked', callback)
button.set_tooltip(tooltip)
示例9: __init__
def __init__(self, activity, **kwargs):
ToolButton.__init__(self, 'edit-description', **kwargs)
self.set_tooltip(_('Description'))
self.palette_invoker.props.toggle_palette = True
self.palette_invoker.props.lock_palette = True
self.props.hide_tooltip_on_click = False
self._palette = self.get_palette()
description_box = PaletteMenuBox()
sw = Gtk.ScrolledWindow()
sw.set_size_request(int(Gdk.Screen.width() / 2),
2 * style.GRID_CELL_SIZE)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self._text_view = Gtk.TextView()
self._text_view.set_left_margin(style.DEFAULT_PADDING)
self._text_view.set_right_margin(style.DEFAULT_PADDING)
self._text_view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
text_buffer = Gtk.TextBuffer()
if 'description' in activity.metadata:
text_buffer.set_text(activity.metadata['description'])
self._text_view.set_buffer(text_buffer)
self._text_view.connect('focus-out-event',
self.__description_changed_cb, activity)
sw.add(self._text_view)
description_box.append_item(sw, vertical_padding=0)
self._palette.set_content(description_box)
description_box.show_all()
activity.metadata.connect('updated', self.__jobject_updated_cb)
示例10: build_toolbar
def build_toolbar(self):
toolbar_box = ToolbarBox()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, -1)
activity_button.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(False)
toolbar_box.toolbar.insert(separator, -1)
separator.show()
button = ToolButton('speaker-muted-100')
button.set_tooltip(_('Sound'))
button.connect('clicked', self.sound_control)
toolbar_box.toolbar.insert(button, -1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
separator.show()
stop_button = StopButton(self)
toolbar_box.toolbar.insert(stop_button, -1)
stop_button.show()
self.show_all()
示例11: __init__
def __init__(self, _activity):
GObject.GObject.__init__(self)
self._activity = _activity
self.theme_state = "light"
self.font_size = DEFAULT_FONT_SIZE
self.theme_toggler = ToolButton('dark-theme')
self.theme_toggler.connect('clicked', self._toggled_theme)
self.theme_toggler.set_tooltip('Switch to Dark Theme')
self.insert(self.theme_toggler, -1)
self.theme_toggler.show()
sep = Gtk.SeparatorToolItem()
self.insert(sep, -1)
sep.show()
self.font_plus = ToolButton('zoom-in')
self.font_plus.connect('clicked', self._font_size_increase)
self.font_plus.set_tooltip('Zoom out')
self.insert(self.font_plus, -1)
self.font_plus.show()
self.font_minus = ToolButton('zoom-out')
self.font_minus.connect('clicked', self._font_size_decrease)
self.font_minus.set_tooltip('Zoom in')
self.insert(self.font_minus, -1)
self.font_minus.show()
self.show()
示例12: __init__
def __init__(self, web_view):
GObject.GObject.__init__(self)
self._web_view = web_view
self._back = ToolButton('go-previous-paired')
self._back.set_tooltip(_('Back'))
self._back.props.sensitive = False
self._back.connect('clicked', self._go_back_cb)
self.insert(self._back, -1)
self._back.show()
self._forward = ToolButton('go-next-paired')
self._forward.set_tooltip(_('Forward'))
self._forward.props.sensitive = False
self._forward.connect('clicked', self._go_forward_cb)
self.insert(self._forward, -1)
self._forward.show()
self._home = ToolButton('go-home')
self._home.set_tooltip(_('Home'))
self._home.connect('clicked', self._go_home_cb)
self.insert(self._home, -1)
self._home.show()
self._web_view.connect('notify::uri', self._uri_changed_cb)
示例13: __init__
def __init__(self):
ToolButton.__init__(self)
self._property = 'timestamp'
self._order = Gtk.SortType.ASCENDING
self.props.tooltip = _('Sort view')
self.props.icon_name = 'view-lastedit'
self.props.hide_tooltip_on_click = False
self.palette_invoker.props.toggle_palette = True
menu_box = PaletteMenuBox()
self.props.palette.set_content(menu_box)
menu_box.show()
for property_, icon, label in self._SORT_OPTIONS:
button = PaletteMenuItem(label)
button_icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name=icon)
button.set_image(button_icon)
button_icon.show()
button.connect('activate',
self.__sort_type_changed_cb,
property_,
icon)
button.show()
menu_box.append_item(button)
示例14: __init__
def __init__(self, name):
ToolButton.__init__(self)
self._name = name
self._icon = None
self.set_palette_invoker(FrameWidgetInvoker(self))
self.palette_invoker.cache_palette = False
self.connect('clicked', self.__clicked_cb)
示例15: _create_export_button
def _create_export_button(self):
# Add expoprt button
export_data = ToolButton('save-as-data')
export_data.props.tooltip = _('Export data')
export_data.props.hide_tooltip_on_click = False
export_data.palette_invoker.props.toggle_palette = True
export_data.show()
menu_box = PaletteMenuBox()
export_data.props.palette.set_content(menu_box)
menu_item = PaletteMenuItem(text_label=_('Export credits by day'))
menu_item.connect('activate', self.__export_data_to_chart_cb,
'credit', DAY)
menu_box.append_item(menu_item)
menu_item = PaletteMenuItem(text_label=_('Export debits by day'))
menu_item.connect('activate', self.__export_data_to_chart_cb,
'debit', DAY)
menu_box.append_item(menu_item)
menu_item = PaletteMenuItem(text_label=_('Export credits by month'))
menu_item.connect('activate', self.__export_data_to_chart_cb,
'credit', MONTH)
menu_box.append_item(menu_item)
menu_item = PaletteMenuItem(text_label=_('Export debits by month'))
menu_item.connect('activate', self.__export_data_to_chart_cb,
'debit', MONTH)
menu_box.append_item(menu_item)
menu_box.show_all()
return export_data