本文整理汇总了Python中sugar3.graphics.toolbarbox.ToolbarButton类的典型用法代码示例。如果您正苦于以下问题:Python ToolbarButton类的具体用法?Python ToolbarButton怎么用?Python ToolbarButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ToolbarButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_view
def add_view(self, widget):
if len(self._view_icons) >= 5:
for x in self.activity._alerts:
self.activity.remove_alert(x)
alert = NotifyAlert(10)
alert.props.title = _('Limit reached')
alert.props.msg = _('You have reached the maximum limit of '
'favorites views, please delete some before '
'continuing.')
self.activity.add_alert(alert)
alert.connect('response',
lambda x, y: self.activity.remove_alert(x))
return
current = len(self._view_buttons) + 1
label = _('Favorites view %d') % current
button = ToolbarButton(label=label, icon_name='view-radial')
page = FavoritePage(button, self, 'view-radial', 'emblem-favorite',
label)
button.set_page(page)
self._view_icons[button] = 'view-radial'
self._favorite_icons[button] = 'emblem-favorite'
self._view_buttons[button] = button
if self.favorite_names_enabled:
self._favorite_names[button] = label
self.insert(button, -1)
self.save_to_gconf()
self.show_all()
示例2: build_toolbar
def build_toolbar(self):
toolbar_box = ToolbarBox()
view_toolbar = ViewToolbar()
view_toolbar.connect('go-fullscreen',
self.view_toolbar_go_fullscreen_cb)
view_toolbar.show()
view_toolbar_button = ToolbarButton(
page=view_toolbar,
icon_name='toolbar-view')
toolbar_box.toolbar.insert(view_toolbar_button, -1)
view_toolbar_button.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
separator.show()
stop_button = StopButton(self)
stop_button.props.accelerator = '<Ctrl><Shift>Q'
toolbar_box.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
示例3: __init__
def __init__(self, activity, **kwargs):
toolbar = ActivityToolbar(activity, orientation_left=True)
ToolbarButton.__init__(self, page=toolbar, **kwargs)
icon = _create_activity_icon(activity.metadata)
self.set_icon_widget(icon)
icon.show()
示例4: __init__
def __init__(self, activity, **kwargs):
toolbar = ActivityToolbar(activity, orientation_left=True)
toolbar.connect('enter-key-press', lambda widget: self.emit('clicked'))
ToolbarButton.__init__(self, page=toolbar, **kwargs)
icon = _create_activity_icon(activity.metadata)
self.set_icon_widget(icon)
icon.show()
示例5: createPercussionToolbar
def createPercussionToolbar(self, toolbar_box):
self.beats_pm_button = IntensitySelector(range(2, 13),
4,
imagefile('beat3.svg'))
self.tempo_button = \
IntensitySelector(range(PLAYER_TEMPO_LOWER,
PLAYER_TEMPO_UPPER + 1, PLAYER_TEMPO_STEP),
PLAYER_TEMPO, imagefile('tempo5.png'))
self.complexity_button = IntensitySelector(xfrange(0, 1, 0.1),
self.regularity,
imagefile('complex6.svg'))
self._play_percussion_btn = ToolButton(
icon_name='media-playback-start')
self._play_percussion_btn.set_property('can-default', True)
self._play_percussion_btn.show()
self._play_percussion_btn.connect('clicked', self.handlePlayButton)
beats_toolbar = ToolbarBox()
beats_toolbar.toolbar.insert(self._play_percussion_btn, -1)
self._what_drum_widget = Gtk.ToolItem()
self._what_drum_search_button = FilterToolItem(
_('Select Drum'), 'view-type', _('Jazz / Rock Kit'),
self._what_drum_widget)
self._what_drum_search_button.set_widget_icon(
file_name=imagefile("drum1kit.svg"))
self._what_drum_widget.show()
beats_toolbar.toolbar.insert(self._what_drum_search_button, -1)
self._what_drum_search_button.show()
self._what_drum_search_button.set_is_important(True)
beats_toolbar.toolbar.insert(Gtk.SeparatorToolItem(), -1)
beats_toolbar.toolbar.insert(self.complexity_button, -1)
beats_toolbar.toolbar.insert(self.beats_pm_button, -1)
beats_toolbar.toolbar.insert(self.tempo_button, -1)
beats_toolbar_button = ToolbarButton(icon_name='toolbar-drums',
page=beats_toolbar)
beats_toolbar_button.show()
toolbar_box.toolbar.insert(beats_toolbar_button, 1)
self.beats_pm_button.set_tooltip(_("Beats per bar"))
self.beats_pm_button.show()
self.beats_pm_button.connect('changed', self.beatSliderChange, True)
self.tempo_button.connect('changed', self.tempoSliderChange, True)
self.complexity_button.connect('changed',
self.handleComplexityChange,
True)
self.complexity_button.set_tooltip(_("Beat complexity"))
self.tempo_button.show()
self.tempo_button.set_tooltip(_('Tempo'))
self.complexity_button.show()
示例6: make_toolbar
def make_toolbar(self):
# toolbar with the new toolbar redesign
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
toolbarview = Gtk.Toolbar()
langtoolbar_button = ToolbarButton(
label=_('View'),
page=toolbarview,
icon_name='settings')
langtoolbar_button.show()
toolbar_box.toolbar.insert(langtoolbar_button, -1)
tool = ToolButton('en')
tool.set_tooltip(_('English'))
tool.connect('clicked', self.language_en)
tool.show()
toolbarview.insert(tool, -1)
tool = ToolButton('es')
tool.set_tooltip(_('Spanish'))
tool.connect('clicked', self.language_es)
tool.show()
toolbarview.insert(tool, -1)
tool = ToolButton('fr')
tool.set_tooltip(_('French'))
tool.connect('clicked', self.language_fr)
tool.show()
toolbarview.insert(tool, -1)
tool = ToolButton('remote')
tool.set_tooltip(_('Server settings'))
tool.connect('clicked', self.settings)
tool.show()
toolbarview.insert(tool, -1)
toolbarview.show()
favorite_button = ToolButton(self.favorite_status)
favorite_button.set_tooltip('Filter on favorite')
favorite_button.connect('clicked', self.favorite)
toolbar_box.toolbar.insert(favorite_button, -1)
favorite_button.show()
self.favorite_button = favorite_button
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.set_toolbar_box(toolbar_box)
toolbar_box.show()
示例7: build_today_toolbar
def build_today_toolbar(self, toolbox):
today_bar = Gtk.Toolbar()
item1 = Gtk.ToolItem()
self.label_today = Gtk.Label()
self.label_today.set_text(_('Today:') + ' ' + _('Day') + ' ')
item1.add(self.label_today)
today_bar.insert(item1, -1)
item2 = Gtk.ToolItem()
self.day_today_spin = Gtk.SpinButton()
self.day_today_spin.set_range(1, 31)
self.day_today_spin.set_increments(1, 5)
self.day_today_spin.props.value = self._today[0]
self.day_today_spin.connect('notify::value', self.day_today_change)
item2.add(self.day_today_spin)
today_bar.insert(item2, -1)
item3 = Gtk.ToolItem()
self.label_today_month = Gtk.Label()
self.label_today_month.set_text(' ' + _('Month') + ' ')
item3.add(self.label_today_month)
today_bar.insert(item3, -1)
item4 = Gtk.ToolItem()
self.month_today_spin = Gtk.SpinButton()
self.month_today_spin.set_range(1, 12)
self.month_today_spin.set_increments(1, 4)
self.month_today_spin.props.value = self._today[1]
self.month_today_spin.connect('notify::value', self.month_today_change)
item4.add(self.month_today_spin)
today_bar.insert(item4, -1)
item5 = Gtk.ToolItem()
self.label_today_year = Gtk.Label()
self.label_today_year.set_text(' ' + _('Year') + ' ')
item5.add(self.label_today_year)
today_bar.insert(item5, -1)
item6 = Gtk.ToolItem()
self.year_today_spin = Gtk.SpinButton()
self.year_today_spin.set_range(1900, self._now.year + 1)
self.year_today_spin.set_increments(1, 10)
self.year_today_spin.props.value = self._today[2]
self.year_today_spin.connect('notify::value', self.year_today_change)
item6.add(self.year_today_spin)
today_bar.insert(item6, -1)
today_bar.show_all()
today_button = ToolbarButton(label=_('Today'),
page=today_bar,
icon_name='write-time')
toolbox.toolbar.insert(today_button, -1)
today_button.show()
示例8: __init__
def __init__(self, activity, shared=False, **kwargs):
toolbar = ActivityToolbar(activity, orientation_left=True)
if not shared:
toolbar.share.props.visible = False
ToolbarButton.__init__(self, page=toolbar, **kwargs)
icon = _create_activity_icon(activity.metadata)
self.set_icon_widget(icon)
icon.show()
示例9: make_toolbar
def make_toolbar(self):
# toolbar with the new toolbar redesign
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
self.toolbarview = Gtk.Toolbar()
langtoolbar_button = ToolbarButton(
label=_('Filter'),
page=self.toolbarview,
icon_name='filter')
langtoolbar_button.show()
toolbar_box.toolbar.insert(langtoolbar_button, -1)
self.toolbarview.show()
box_search_item = Gtk.ToolItem()
self.search_entry = Gtk.Entry()
self.search_entry.connect('changed', self.text_filter)
self.search_entry.set_size_request(300, -1)
box_search_item.add(self.search_entry)
self.search_entry.show()
box_search_item.show()
toolbar_box.toolbar.insert(box_search_item, -1)
favorite_button = ToolButton(self.favorite_status)
favorite_button.set_tooltip('Filter on favorite')
favorite_button.connect('clicked', self.favorite)
toolbar_box.toolbar.insert(favorite_button, -1)
favorite_button.show()
self.favorite_button = favorite_button
library_button = ToolButton('library')
library_button.set_tooltip('Show libraries')
library_button.connect('clicked', self.library_clicked)
toolbar_box.toolbar.insert(library_button, -1)
library_button.show()
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.set_toolbar_box(toolbar_box)
toolbar_box.show()
示例10: _setup_toolbars
def _setup_toolbars(self):
custom_toolbar = Gtk.Toolbar()
toolbox = ToolbarBox()
self._toolbar = toolbox.toolbar
self._activity_button = ActivityToolbarButton(self)
self._activity_button.connect('clicked', self._update_graphics)
self._toolbar.insert(self._activity_button, 0)
self._activity_button.show()
self._custom_toolbar_button = ToolbarButton(
label=_('Custom'),
page=custom_toolbar,
icon_name='view-source')
self._custom_toolbar_button.connect('clicked', self._update_graphics)
custom_toolbar.show()
self._toolbar.insert(self._custom_toolbar_button, -1)
self._custom_toolbar_button.show()
self._load_standard_buttons(self._toolbar)
self._separator = Gtk.SeparatorToolItem()
self._separator.props.draw = False
self._separator.set_expand(True)
self._toolbar.insert(self._separator, -1)
self._separator.show()
stop_button = StopButton(self)
stop_button.props.accelerator = _('<Ctrl>Q')
self._toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbox)
toolbox.show()
self._load_custom_buttons(custom_toolbar)
示例11: _setup_toolbars
def _setup_toolbars(self):
''' Setup the toolbars.. '''
tools_toolbar = Gtk.Toolbar()
numbers_toolbar = Gtk.Toolbar()
toolbox = ToolbarBox()
self.activity_toolbar_button = ActivityToolbarButton(self)
toolbox.toolbar.insert(self.activity_toolbar_button, 0)
self.activity_toolbar_button.show()
self.numbers_toolbar_button = ToolbarButton(
page=numbers_toolbar,
icon_name='number-tools')
if MODE == 'number':
numbers_toolbar.show()
toolbox.toolbar.insert(self.numbers_toolbar_button, -1)
self.numbers_toolbar_button.show()
self.tools_toolbar_button = ToolbarButton(
page=tools_toolbar,
icon_name='view-source')
self.button_pattern = button_factory(
'new-pattern-game', toolbox.toolbar, self._select_game_cb,
cb_arg='pattern', tooltip=_('New game'))
self._set_extras(toolbox.toolbar)
self._sep.append(separator_factory(toolbox.toolbar, True, False))
stop_button = StopButton(self)
stop_button.props.accelerator = '<Ctrl>q'
toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
button_factory('score-copy', self.activity_toolbar_button,
self._write_scores_to_clipboard,
tooltip=_('Export scores to clipboard'))
self.set_toolbar_box(toolbox)
toolbox.show()
if MODE == 'word':
self.words_tool_button = button_factory(
'word-tools', tools_toolbar, self._edit_words_cb,
tooltip=_('Edit word lists.'))
self.import_button = button_factory(
'image-tools', tools_toolbar, self.image_import_cb,
tooltip=_('Import custom cards'))
self.button_custom = button_factory(
'new-custom-game', tools_toolbar, self._select_game_cb,
cb_arg='custom', tooltip=_('New custom game'))
self.button_custom.set_sensitive(False)
if MODE == 'number':
self._setup_number_buttons(numbers_toolbar)
示例12: __init__
def __init__(self, handle):
if not hasattr(self, 'confvars'):
self.confvars = read_conf_from_info(get_bundle_path())
logging.error("Starting server database: %s port: %s" %
(self.confvars['path'], self.confvars['port']))
os.chdir(os.environ['SUGAR_BUNDLE_PATH'])
self.confvars['ip'] = '0.0.0.0'
server.run_server(self.confvars)
handle.uri = 'http://%s:%s%s' % (
self.confvars['ip'], self.confvars['port'],
self.confvars['home_page'])
webactivity.WebActivity.__init__(self, handle)
if USE_GTK2:
# Use xpcom to set a RAM cache limit. (Trac #7081.)
from xpcom import components
from xpcom.components import interfaces
cls = components.classes['@mozilla.org/preferences-service;1']
pref_service = cls.getService(interfaces.nsIPrefService)
branch = pref_service.getBranch("browser.cache.memory.")
branch.setIntPref("capacity", "5000")
# Use xpcom to turn off "offline mode" detection, which disables
# access to localhost for no good reason. (Trac #6250.)
ios_class = components.classes["@mozilla.org/network/io-service;1"]
io_service = ios_class.getService(interfaces.nsIIOService2)
io_service.manageOfflineStatus = False
self.searchtoolbar = SearchToolbar(self)
search_toolbar_button = ToolbarButton()
search_toolbar_button.set_page(self.searchtoolbar)
search_toolbar_button.props.icon_name = 'search-wiki'
search_toolbar_button.props.label = _('Search')
self.get_toolbar_box().toolbar.insert(search_toolbar_button, 1)
search_toolbar_button.show()
# Hide add-tabs button
if hasattr(self._primary_toolbar, '_add_tab'):
self._primary_toolbar._add_tab.hide()
self.searchtoolbar.show()
示例13: _set_toolbar
def _set_toolbar(self):
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
stop = StopButton(self)
# Buttons #
self._photo = RadioToolButton()
self._photo.props.icon_name = 'media-photo'
self._photo.props.label = _('Photo')
self._video = RadioToolButton()
self._video.props.group = self._photo
self._video.props.icon_name = 'media-video'
self._video.props.label = _('Video')
self._audio = RadioToolButton()
self._audio.props.group = self._photo
self._audio.props.icon_name = 'media-audio'
self._audio.props.label = _('Audio')
# End of Buttons #
self._timer = TimerCombo()
self._timer_2 = DurationCombo()
#self._timer_2.combo.set_sensitive(False)
self._preferencias = ToolbarButton()
toolbar = Gtk.Toolbar()
combo = QualityCombo()
#combo.set_sensitive(False)
self.calidad = ToolComboBox(combo=combo, label_text=_('Quality:'))
self.calidad.show_all()
toolbar.insert(self.calidad, -1)
toolbar.show_all()
self._preferencias.set_page(toolbar)
self._preferencias.props.icon_name = 'preferences-system'
self._preferencias.props.label = _('Preferences')
self.toolbar.insert(self.activitybutton, -1)
self.toolbar.insert(self._photo, -1)
self.toolbar.insert(self._video, -1)
self.toolbar.insert(self._audio, -1)
self.toolbar.insert(Gtk.SeparatorToolItem(), -1)
self.toolbar.insert(self._timer, -1)
self.toolbar.insert(self._timer_2, -1)
self.toolbar.insert(self._preferencias, -1)
self.toolbar.insert(separator, -1)
self.toolbar.insert(stop, -1)
self.set_toolbar_box(self.toolbox)
示例14: add_page
def add_page(self, ebook_reader_tab_instance):
# Add the "content" for the section.
tab_name = ebook_reader_tab_instance.get_tab_label()
tab_widget = ebook_reader_tab_instance.get_widget_to_attach_notebook_tab()
tab_toolbar = ebook_reader_tab_instance.get_tab_toolbar()
if tab_toolbar is not None:
tab_widget.pack_start(tab_toolbar, False, False, 0)
tab_widget.reorder_child(tab_toolbar, 0)
self._tab_toolbars_list.append(tab_toolbar)
self.notebook.add_page(tab_name, tab_widget)
# Add the "(secondary) toolbar" for the section.
icon_name = \
ebook_reader_tab_instance.get_tab_toolbar_icon_name()
toolbar_button = ToolbarButton(page=None,
icon_name=icon_name + '-select')
self._toolbar_buttons_list.append(toolbar_button)
toolbar_button.connect('clicked',
self.load_corresponding_page,
ebook_reader_tab_instance.get_pagenum())
ebook_reader_tab_instance.show()
toolbar_button.set_tooltip(tab_name)
self._toolbar_box._toolbar.insert(toolbar_button, -1)
toolbar_button.show()
self._toolbar_box.show_all()
示例15: build_size_toolbar
def build_size_toolbar(self, toolbox):
size_bar = Gtk.Toolbar()
#Horizontal
item1 = Gtk.ToolItem()
label1 = Gtk.Label()
label1.set_text(' %s ' % _('H'))
item1.add(label1)
size_bar.insert(item1, -1)
item2 = Gtk.ToolItem()
self.h_spin = Gtk.SpinButton()
self.h_spin.set_range(2, 30)
self.h_spin.set_increments(1, 2)
self.h_spin.props.value = self.game_size[0]
self.h_spin.connect('notify::value', self.h_spin_change)
item2.add(self.h_spin)
size_bar.insert(item2, -1)
#Vertical
item3 = Gtk.ToolItem()
label2 = Gtk.Label()
label2.set_text(' %s ' % _('V'))
item3.add(label2)
size_bar.insert(item3, -1)
item4 = Gtk.ToolItem()
self.v_spin = Gtk.SpinButton()
self.v_spin.set_range(2, 20)
self.v_spin.set_increments(1, 2)
self.v_spin.props.value = self.game_size[1]
self.v_spin.connect('notify::value', self.v_spin_change)
item4.add(self.v_spin)
size_bar.insert(item4, -1)
size_bar.show_all()
size_button = ToolbarButton(label=_('Board size'),
page=size_bar,
icon_name='preferences-system')
toolbox.toolbar.insert(size_button, -1)
size_button.show()