本文整理汇总了Python中sugar3.graphics.toggletoolbutton.ToggleToolButton类的典型用法代码示例。如果您正苦于以下问题:Python ToggleToolButton类的具体用法?Python ToggleToolButton怎么用?Python ToggleToolButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ToggleToolButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ViewToolbar
class ViewToolbar(Gtk.Toolbar):
__gtype_name__ = 'ViewToolbar'
__gsignals__ = {
'go-fullscreen': (GObject.SignalFlags.RUN_FIRST,
None,
([])),
'toggle-playlist': (GObject.SignalFlags.RUN_FIRST,
None,
([]))
}
def __init__(self):
Gtk.Toolbar.__init__(self)
self._show_playlist = ToggleToolButton('view-list')
self._show_playlist.set_active(True) # due to Activity.show_all()
self._show_playlist.set_tooltip(_('Playlist'))
self._show_playlist.set_accelerator('<ctrl>l')
self._show_playlist.connect('toggled', self._playlist_toggled_cb)
self.insert(self._show_playlist, -1)
self._show_playlist.show()
self._fullscreen = ToolButton('view-fullscreen')
self._fullscreen.set_tooltip(_('Fullscreen'))
self._fullscreen.set_accelerator('<ctrl>f')
self._fullscreen.connect('clicked', self._fullscreen_cb)
self.insert(self._fullscreen, -1)
self._fullscreen.show()
def _fullscreen_cb(self, button):
self.emit('go-fullscreen')
def _playlist_toggled_cb(self, button):
self.emit('toggle-playlist')
示例2: _add_clock_controls
def _add_clock_controls(self, display_toolbar):
# First group of radio button to select the type of clock to display
button1 = RadioToolButton(icon_name="simple-clock")
button1.set_tooltip(_('Simple Clock'))
button1.connect("toggled", self._display_mode_changed_cb,
_MODE_SIMPLE_CLOCK)
display_toolbar.insert(button1, -1)
self._display_mode_buttons.append(button1)
button2 = RadioToolButton(icon_name="nice-clock",
group=button1)
button2.set_tooltip(_('Nice Clock'))
button2.connect("toggled", self._display_mode_changed_cb,
_MODE_NICE_CLOCK)
display_toolbar.insert(button2, -1)
self._display_mode_buttons.append(button2)
button3 = RadioToolButton(icon_name="digital-clock",
group=button1)
button3.set_tooltip(_('Digital Clock'))
button3.connect("toggled", self._display_mode_changed_cb,
_MODE_DIGITAL_CLOCK)
display_toolbar.insert(button3, -1)
self._display_mode_buttons.append(button3)
# A separator between the two groups of buttons
separator = Gtk.SeparatorToolItem()
separator.set_draw(True)
display_toolbar.insert(separator, -1)
# Now the options buttons to display other elements: date, day
# of week... A button in the toolbar to write the time in
# full letters
self._write_time_btn = ToggleToolButton("write-time")
self._write_time_btn.set_tooltip(_('Display time in full letters'))
self._write_time_btn.connect("toggled", self._write_time_clicked_cb)
display_toolbar.insert(self._write_time_btn, -1)
# The button to display the weekday and date
self._write_date_btn = ToggleToolButton("write-date")
self._write_date_btn.set_tooltip(_('Display weekday and date'))
self._write_date_btn.connect("toggled", self._write_date_clicked_cb)
display_toolbar.insert(self._write_date_btn, -1)
# Another button to speak aloud the time
self._speak_time_btn = ToggleToolButton("microphone")
self._speak_time_btn.set_tooltip(_('Talking clock'))
self._speak_time_btn.connect("toggled", self._speak_time_clicked_cb)
display_toolbar.insert(self._speak_time_btn, -1)
# A separator between the two groups of buttons
separator = Gtk.SeparatorToolItem()
separator.set_draw(True)
display_toolbar.insert(separator, -1)
# And another button to toggle grabbing the hands
self._grab_button = ToggleToolButton("grab")
self._grab_button.set_tooltip(_('Grab the hands'))
self._grab_button.connect("toggled", self._grab_clicked_cb)
display_toolbar.insert(self._grab_button, -1)
示例3: __init__
def __init__(self, items, cb, desc):
ToggleToolButton.__init__(self)
self.items = items
if 'icon' in items[0] and _icon_exists(items[0]['icon']):
self.props.icon_name = items[0]['icon']
elif 'html' in items[0]:
self.set_label(items[0]['html'])
# self.set_tooltip(items[0][1])
self.set_tooltip(desc)
self.selected = 0
self.connect('clicked', self.toggle_button)
self.callback = cb
示例4: __init__
def __init__(self, page):
self._colorseldlg = None
Gtk.Toolbar.__init__(self)
self._page = page
page._text_toolbar = self
self._bold = ToggleToolButton('format-text-bold')
self._bold.set_tooltip(_('Bold'))
self._bold_id = self._bold.connect('clicked', self._bold_cb)
self.insert(self._bold, -1)
self._italic = ToggleToolButton('format-text-italic')
self._italic.set_tooltip(_('Italic'))
self._italic_id = self._italic.connect('clicked', self._italic_cb)
self.insert(self._italic, -1)
"""
self._underline = ToggleToolButton('format-text-underline')
self._underline.set_tooltip(_('Underline'))
self._underline_id = self._underline.connect('clicked',
self._underline_cb)
self.insert(self._underline, -1)
self._underline.show()
"""
self._text_color = TextButtonColor(page)
self._text_color.set_title(_('Text Color'))
item = Gtk.ToolItem()
item.add(self._text_color)
self.insert(item, -1)
separator = Gtk.SeparatorToolItem()
separator.set_draw(True)
self.insert(separator, -1)
self._font_size_combo = FontSize()
self._font_size_changed_id = self._font_size_combo.connect(
'changed', self._font_size_changed_cb)
self.insert(self._font_size_combo, -1)
# font
self._font_combo = FontComboBox()
self._font_combo.set_font_name(globos.DEFAULT_FONT)
self._fonts_changed_id = self._font_combo.connect(
'changed', self._font_changed_cb)
self.insert(ToolComboBox(self._font_combo), -1)
self.show_all()
示例5: RecordToolbar
class RecordToolbar(Gtk.Toolbar):
def __init__(self, jam):
GObject.GObject.__init__(self)
def _insertSeparator(x=1):
for i in range(x):
self.separator = Gtk.SeparatorToolItem()
self.separator.set_draw(True)
self.insert(self.separator, -1)
self.separator.show()
#self.toolbox = toolbox
self.jam = jam
if Config.FEATURES_MIC:
self.micRec1Button = ToolButton('rec1')
self.micRec1Button.connect('clicked', self.jam.micRec, 'mic1')
self.insert(self.micRec1Button, -1)
self.micRec1Button.show()
self.micRec1Button.set_tooltip(_('Record microphone into slot 1'))
self.micRec2Button = ToolButton('rec2')
self.micRec2Button.connect('clicked', self.jam.micRec, 'mic2')
self.insert(self.micRec2Button, -1)
self.micRec2Button.show()
self.micRec2Button.set_tooltip(_('Record microphone into slot 2'))
self.micRec3Button = ToolButton('rec3')
self.micRec3Button.connect('clicked', self.jam.micRec, 'mic3')
self.insert(self.micRec3Button, -1)
self.micRec3Button.show()
self.micRec3Button.set_tooltip(_('Record microphone into slot 3'))
self.micRec4Button = ToolButton('rec4')
self.micRec4Button.connect('clicked', self.jam.micRec, 'mic4')
self.insert(self.micRec4Button, -1)
self.micRec4Button.show()
self.micRec4Button.set_tooltip(('Record microphone into slot 4'))
_insertSeparator()
if Config.FEATURES_NEWSOUNDS:
self._loopSettingsPalette = LoopSettingsPalette(
_('Add new Sound'), self.jam)
self.loopSetButton = ToggleToolButton('loop')
self.loopSetButton.set_palette(self._loopSettingsPalette)
self.insert(self.loopSetButton, -1)
self.loopSetButton.show()
self.show_all()
示例6: __init__
def __init__(self, activity):
Gtk.Toolbar.__init__(self)
voicebar = Gtk.Toolbar()
self._activity = activity
if not speech.supported:
return
self.load_speech_parameters()
self.sorted_voices = [i for i in speech.voices()]
self.sorted_voices.sort(self.compare_voices)
default = 0
for voice in self.sorted_voices:
if voice[0] == speech.voice[0]:
break
default = default + 1
# Play button
self.play_btn = ToggleToolButton('media-playback-start')
self.play_btn.show()
self.play_btn.connect('toggled', self.play_cb)
self.insert(self.play_btn, -1)
self.play_btn.set_tooltip(_('Play / Pause'))
self.voice_combo = ComboBox()
for voice in self.sorted_voices:
self.voice_combo.append_item(voice, voice[0])
self.voice_combo.set_active(default)
self.voice_combo.connect('changed', self.voice_changed_cb)
combotool = ToolComboBox(self.voice_combo)
self.insert(combotool, -1)
combotool.show()
self.pitchadj = Gtk.Adjustment(0, -100, 100, 1, 10, 0)
pitchbar = Gtk.HScale(self.pitchadj)
pitchbar.set_draw_value(False)
pitchbar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
pitchbar.set_size_request(150, 15)
self.pitchadj.set_value(speech.pitch)
pitchtool = Gtk.ToolItem()
pitchtool.add(pitchbar)
pitchtool.show()
self.insert(pitchtool, -1)
pitchbar.show()
self.rateadj = Gtk.Adjustment(0, -100, 100, 1, 10, 0)
ratebar = Gtk.HScale(self.rateadj)
ratebar.set_draw_value(False)
ratebar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
ratebar.set_size_request(150, 15)
self.rateadj.set_value(speech.rate)
ratetool = Gtk.ToolItem()
ratetool.add(ratebar)
ratetool.show()
self.insert(ratetool, -1)
ratebar.show()
self.pitchadj.connect("value_changed", self.pitch_adjusted_cb)
self.rateadj.connect("value_changed", self.rate_adjusted_cb)
示例7: _add_search_controls
def _add_search_controls(self, toolbar):
book_search_item = Gtk.ToolItem()
toolbar.search_entry = iconentry.IconEntry()
toolbar.search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
'system-search')
toolbar.search_entry.add_clear_button()
toolbar.search_entry.connect('activate',
self.__search_entry_activate_cb)
width = int(Gdk.Screen.width() / 4)
toolbar.search_entry.set_size_request(width, -1)
book_search_item.add(toolbar.search_entry)
toolbar.search_entry.show()
toolbar.insert(book_search_item, -1)
book_search_item.show()
toolbar.source_combo = ComboBox()
toolbar.source_combo.props.sensitive = True
toolbar.source_changed_cb_id = \
toolbar.source_combo.connect('changed', self.__source_changed_cb)
combotool = ToolComboBox(toolbar.source_combo)
toolbar.insert(combotool, -1)
combotool.show()
self.bt_catalogs = ToggleToolButton('books')
self.bt_catalogs.set_tooltip(_('Catalogs'))
toolbar.insert(self.bt_catalogs, -1)
self.bt_catalogs.connect('toggled', self.__toggle_cats_cb)
if len(self.catalogs) > 0:
self.bt_catalogs.show()
if len(self.languages) > 0:
toolbar.config_toolbarbutton = ToolbarButton()
toolbar.config_toolbarbutton.props.icon_name = 'preferences-system'
toolbar.config_toolbarbox = Gtk.Toolbar()
toolbar.config_toolbarbutton.props.page = toolbar.config_toolbarbox
toolbar.language_combo = ComboBox()
toolbar.language_combo.props.sensitive = True
combotool = ToolComboBox(toolbar.language_combo)
toolbar.language_combo.append_item('all', _('Any language'))
for key in self.languages.keys():
toolbar.language_combo.append_item(key, self.languages[key])
toolbar.language_combo.set_active(0)
toolbar.config_toolbarbutton.props.page.insert(combotool, -1)
toolbar.insert(toolbar.config_toolbarbutton, -1)
toolbar.config_toolbarbutton.show()
combotool.show()
toolbar.language_changed_cb_id = \
toolbar.language_combo.connect('changed',
self.__language_changed_cb)
self._device_manager = devicemanager.DeviceManager()
self._refresh_sources(toolbar)
self._device_manager.connect('device-changed',
self.__device_changed_cb)
toolbar.search_entry.grab_focus()
return toolbar
示例8: __init__
def __init__(self, activity):
GObject.GObject.__init__(self)
self._activity = activity
self.properties = self._activity.area.tool
self._text = DrawToolButton('text', activity.tool_group, _('Type'))
self.insert(self._text, -1)
self._text.connect('clicked', self.set_tool, self._ACTION_TEXT_NAME)
separator = Gtk.SeparatorToolItem()
separator.set_draw(True)
self.insert(separator, -1)
self._bold = ToggleToolButton('format-text-bold')
self.insert(self._bold, -1)
self._bold.show()
self._bold.connect('clicked', self.__bold_bt_cb)
self._italic = ToggleToolButton('format-text-italic')
self.insert(self._italic, -1)
self._italic.show()
self._italic.connect('clicked', self.__italic_bt_cb)
separator = Gtk.SeparatorToolItem()
separator.set_draw(True)
self.insert(separator, -1)
self._font_size = FontSize()
self.insert(self._font_size, -1)
self._font_size_changed_id = self._font_size.connect(
'changed', self.__font_size_changed_cb)
self._font_combo = FontComboBox()
self._fonts_changed_id = self._font_combo.connect(
'changed', self.__font_changed_cb)
fd = activity.area.get_font_description()
font_name = fd.get_family()
self._font_combo.set_font_name(font_name)
self._font_size.set_font_size(int(fd.get_size() / Pango.SCALE))
tool_item = ToolComboBox(self._font_combo)
self.insert(tool_item, -1)
self.show_all()
示例9: __init__
def __init__(self, handle):
activity.Activity.__init__(self, handle)
logging.debug('Starting the IRC Activity')
self.set_title(_('IRC Activity'))
self.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK)
self.connect('visibility-notify-event',
self.__visibility_notify_event_cb)
self.is_visible = False
self.client = purk.Client(self)
if handle.object_id is None:
self.default_config()
self.client.show()
widget = self.client.get_widget()
# CANVAS
self.set_canvas(widget)
toolbar_box = ToolbarBox()
self.activity_button = ActivityButton(self)
toolbar_box.toolbar.insert(self.activity_button, 0)
self.activity_button.show()
title_entry = TitleEntry(self)
toolbar_box.toolbar.insert(title_entry, -1)
title_entry.show()
connectionbtn = ToggleToolButton('connect')
connectionbtn.set_active(True)
connectionbtn.set_tooltip(_('Disconnect'))
connectionbtn.connect('toggled', self._connection_cb)
toolbar_box.toolbar.insert(connectionbtn, -1)
connectionbtn.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: __init__
def __init__(self, game, editor_index):
Gtk.EventBox.__init__(self)
self._game = game
self.snd = None
self.editor_index = editor_index
self.temp_folder = None
box = Gtk.Grid()
box.set_column_spacing(style.DEFAULT_SPACING)
box.set_row_spacing(style.DEFAULT_SPACING)
box.props.margin = style.DEFAULT_SPACING
self.card = svgcard.SvgCard(
-1, {'front_text': {'card_text': '',
'text_color': style.Color('#ffffff')}},
None, PAIR_SIZE, '#c0c0c0')
self.card.flip()
card_align = Gtk.Alignment.new(.5, .5, 0, 0)
card_align.add(self.card)
box.attach(card_align, 0, 0, 1, 1)
self.textentry = Gtk.Entry()
self.textentry.connect('changed', self.update_text)
self.textentry.set_valign(Gtk.Align.START)
box.attach(self.textentry, 0, 1, 1, 1)
toolbar = Gtk.VBox()
toolbar.set_valign(Gtk.Align.CENTER)
browsepicture = ToolButton(icon_name='import_picture',
tooltip=_('Insert picture'))
toolbar.add(browsepicture)
browsesound = ToolButton(icon_name='import_sound',
tooltip=_('Insert sound'))
toolbar.add(browsesound)
browsepicture.connect('clicked', self._load_image)
browsesound.connect('clicked', self._load_audio)
if speak.espeak.supported:
self.usespeak = ToggleToolButton(icon_name='speak')
self.usespeak.set_palette(SpeakPalette(self))
toolbar.add(self.usespeak)
self.usespeak.connect('toggled', self._usespeak_cb)
else:
self.usespeak = None
self.fontbutton = FontButton()
toolbar.add(self.fontbutton)
self.id_font_changed = self.fontbutton.connect(
'changed', self.__font_changed_cb)
box.attach(toolbar, 1, 0, 1, 2)
self.add(box)
示例11: __init__
def __init__(self, activity):
GObject.GObject.__init__(self)
self.activity = activity
self.toolbar = self.activity.get_toolbar_box().toolbar
self._equal_pairs = ToggleToolButton('pair-non-equals')
self._equal_pairs.set_tooltip(_('Match different tiles'))
self._equal_pairs.connect('toggled', self._emit_equal_pairs)
self.toolbar.insert(self._equal_pairs, -1)
self._grouped = ToggleToolButton('grouped_game1')
self._grouped.set_tooltip(_('Mixed tiles game'))
self._grouped.connect('toggled', self._grouped_cb)
self.toolbar.insert(self._grouped, -1)
self._clear_button = ToolButton('edit-clear')
self._clear_button.set_tooltip(_('Clear all tiles'))
self._clear_button.connect('clicked', self._clear_game_bt)
self.toolbar.insert(self._clear_button, -1)
self.toolbar.show_all()
示例12: __init__
def __init__(self):
ToolbarBox.__init__(self)
self._mount_point = None
self._filter_type = None
self._what_filter = None
self.search_entry = iconentry.IconEntry()
self.search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
'entry-search')
text = _('Search in %s') % _('Journal')
self.search_entry.set_placeholder_text(text)
self.search_entry.connect('activate', self._search_entry_activated_cb)
self.search_entry.connect('changed', self._search_entry_changed_cb)
self.search_entry.add_clear_button()
self._autosearch_timer = None
self._add_widget(self.search_entry, expand=True)
self._favorite_button = ToggleToolButton('emblem-favorite')
self._favorite_button.set_tooltip(_('Favorite entries'))
self._favorite_button.connect('toggled',
self.__favorite_button_toggled_cb)
self.toolbar.insert(self._favorite_button, -1)
self._favorite_button.show()
self._what_search_combo = ComboBox()
self._what_combo_changed_sid = self._what_search_combo.connect(
'changed', self._combo_changed_cb)
tool_item = ToolComboBox(self._what_search_combo)
self.toolbar.insert(tool_item, -1)
tool_item.show()
self._when_search_combo = self._get_when_search_combo()
tool_item = ToolComboBox(self._when_search_combo)
self.toolbar.insert(tool_item, -1)
tool_item.show()
self._sorting_button = SortingButton()
self.toolbar.insert(self._sorting_button, -1)
self._sorting_button.connect('sort-property-changed',
self.__sort_changed_cb)
self._sorting_button.show()
# TODO: enable it when the DS supports saving the buddies.
# self._with_search_combo = self._get_with_search_combo()
# tool_item = ToolComboBox(self._with_search_combo)
# self.insert(tool_item, -1)
# tool_item.show()
self._query = self._build_query()
self.refresh_filters()
示例13: setup_toolbar
def setup_toolbar(self):
activity_button = ActivityToolbarButton(self)
self.toolbar.insert(activity_button, -1)
self.toolbar.insert(Gtk.SeparatorToolItem(), -1)
edit_toolbar = EditToolbar()
self.toolbar.insert(ToolbarButton(page=edit_toolbar, icon_name="toolbar-edit"), -1)
edit_toolbar.insert(Gtk.SeparatorToolItem(), -1)
self.button_bold = ToggleToolButton("format-text-bold")
self.button_bold.set_tooltip(_("Bold"))
self.button_bold.props.accelerator = "<Ctrl>B"
self.button_bold.connect("toggled", lambda button: self.edit.toggle_bold())
edit_toolbar.insert(self.button_bold, -1)
self.button_italic = ToggleToolButton("format-text-italic")
self.button_italic.set_tooltip(_("Italic"))
self.button_italic.props.accelerator = "<Ctrl>I"
self.button_italic.connect("toggled", lambda button: self.edit.toggle_italic())
edit_toolbar.insert(self.button_italic, -1)
self.button_underline = ToggleToolButton("format-text-underline")
self.button_underline.set_tooltip(_("Underline"))
self.button_underline.props.accelerator = "<Ctrl>B"
self.button_underline.connect("toggled", lambda button: self.edit.toggle_underline())
edit_toolbar.insert(self.button_underline, -1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
self.toolbar.insert(separator, -1)
stop_button = StopButton(self)
self.toolbar.insert(stop_button, -1)
self.toolbarbox.show_all()
edit_toolbar.show_all()
示例14: toggle_factory
def toggle_factory(icon_name, callback, toolbar, tooltip=None):
''' add a toggle button to a toolbar'''
t_button = ToggleToolButton(icon_name)
t_button.connect('toggled', callback)
if tooltip:
t_button.set_tooltip(tooltip)
if hasattr(toolbar, 'insert'): # the main toolbar
toolbar.insert(t_button, -1)
else: # or a secondary toolbar
toolbar.props.page.insert(t_button, -1)
t_button.show()
示例15: __init__
def __init__(self, activity):
GObject.GObject.__init__(self)
self._browser = None
self._activity = activity
self.zoomout = ToolButton('zoom-out')
self.zoomout.set_tooltip(_('Zoom out'))
self.zoomout.connect('clicked', self.__zoomout_clicked_cb)
self.insert(self.zoomout, -1)
self.zoomout.show()
self.zoomin = ToolButton('zoom-in')
self.zoomin.set_tooltip(_('Zoom in'))
self.zoomin.connect('clicked', self.__zoomin_clicked_cb)
self.insert(self.zoomin, -1)
self.zoomin.show()
self.zoom_original = ToolButton('zoom-original')
self.zoom_original.set_tooltip(_('Actual size'))
self.zoom_original.connect('clicked', self.__zoom_original_clicked_cb)
self.insert(self.zoom_original, -1)
self.zoom_original.show()
self.separator = Gtk.SeparatorToolItem()
self.separator.set_draw(True)
self.insert(self.separator, -1)
self.separator.show()
self.fullscreen = ToolButton('view-fullscreen')
self.fullscreen.set_tooltip(_('Fullscreen'))
self.fullscreen.connect('clicked', self.__fullscreen_clicked_cb)
self.insert(self.fullscreen, -1)
self.fullscreen.show()
self.traybutton = ToggleToolButton('tray-show')
self.traybutton.set_icon_name('tray-favourite')
self.traybutton.connect('toggled', self.__tray_toggled_cb)
self.traybutton.props.sensitive = False
self.traybutton.props.active = False
self.insert(self.traybutton, -1)
self.traybutton.show()
tabbed_view = self._activity.get_canvas()
if tabbed_view.get_n_pages():
self._connect_to_browser(tabbed_view.props.current_browser)
tabbed_view.connect_after('switch-page', self.__switch_page_cb)