本文整理汇总了Python中sugar3.graphics.toggletoolbutton.ToggleToolButton.connect方法的典型用法代码示例。如果您正苦于以下问题:Python ToggleToolButton.connect方法的具体用法?Python ToggleToolButton.connect怎么用?Python ToggleToolButton.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.toggletoolbutton.ToggleToolButton
的用法示例。
在下文中一共展示了ToggleToolButton.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ViewToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
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: __init__
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
def __init__(self, conf):
Gtk.Toolbar.__init__(self)
self.button = ToolbarButton(page=self, icon_name="toolbar-view")
combo_font = FontComboBox(conf["font"])
combo_font.connect("changed", self.__font_changed_cb)
self.insert(combo_font, -1)
item_font_size = FontSize()
item_font_size.set_font_size(conf["font-size"])
item_font_size.connect("changed", self.__font_size_changed_cb)
self.insert(item_font_size, -1)
self.insert(utils.make_separator(False), -1)
button_numbers = ToggleToolButton("show-numbers")
button_numbers.props.accelerator = "<Ctrl><Mayus>N"
button_numbers.set_tooltip(_("Show line numbers"))
button_numbers.set_active(conf["show-line-numbers"])
button_numbers.connect("toggled", self.__show_line_numbers_changed_cb)
self.insert(button_numbers, -1)
button_right_line = ToggleToolButton("show-right-line")
button_right_line.props.accelerator = "<Ctrl>L"
button_right_line.set_tooltip(_("Show a line in a specific position"))
button_right_line.set_active(conf["show-right-line"])
button_right_line.connect("toggled", self.__show_right_line_changed_cb)
self.insert(button_right_line, -1)
adjustement = Gtk.Adjustment(
value=conf["right-line-pos"],
lower=1,
upper=150,
step_increment=1,
page_increment=5,
page_size=0,
)
toolItem1 = Gtk.ToolItem()
self.spinner_right_line = Gtk.SpinButton()
self.spinner_right_line.set_margin_left(5)
self.spinner_right_line.set_adjustment(adjustement)
# Ensuring that the value is displayed when starting:
self.spinner_right_line.set_value(conf["right-line-pos"])
self.spinner_right_line.connect('notify::value',
self.__right_line_pos_changed_cb)
toolItem1.add(self.spinner_right_line)
self.insert(toolItem1, -1)
self.insert(utils.make_separator(False), -1)
combo_styles = ComboStyles(conf["theme"])
combo_styles.connect("theme-changed", self.__theme_changed_cb)
self.insert(combo_styles, -1)
self.show_all()
示例3: toggle_factory
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
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()
示例4: __init__
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
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()
示例5: CollabEditActivity
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
class CollabEditActivity(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.toolbarbox = ToolbarBox()
self.toolbar = self.toolbarbox.toolbar
self.set_toolbar_box(self.toolbarbox)
self.edit = collabedit.CollabEdit(self)
self.edit.connect("cursor-position-changed", self._cursor_positon_changed_cb)
self.set_canvas(self.edit)
self.setup_toolbar()
self.show_all()
def _cursor_positon_changed_cb(self, edit, pos):
self.button_bold.props.active = self.edit.check_tag_at_offset("bold", pos)
self.button_italic.props.active = self.edit.check_tag_at_offset("italic", pos)
self.button_underline.props.active = self.edit.check_tag_at_offset("underline", pos)
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()
示例6: SimplePianoActivity
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
class SimplePianoActivity(activity.Activity):
"""SimplePianoActivity class as specified in activity.info"""
def __init__(self, handle):
activity.Activity.__init__(self, handle)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.close)
Gst.init(None)
self._what_list = []
self.play_recording_thread = None
self.playing_recording = False
self.firstTime = False
self.playing = False
self.regularity = 0.7
self._drums_store = []
self.recording = False
self.recorded_keys = []
self.is_valid_recording = False
# we do not have collaboration features
# make the share option insensitive
self.max_participants = 1
self.csnd = new_csound_client()
self.rythmInstrument = 'drum1kick'
# toolbar with the new toolbar redesign
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
toolbar_box.toolbar.set_style(Gtk.ToolbarStyle.BOTH_HORIZ)
self.play_index = 0
self.play_recording_button = ToolButton(
icon_name='media-playback-start')
self.play_recording_button.set_property('can-default', True)
self.play_recording_button.show()
self.record_button = ToggleToolButton(icon_name='media-record')
self.record_button.set_property('can-default', True)
self.record_button.show()
self.play_recording_button.set_sensitive(False)
self.record_button.connect('clicked', self.__record_button_click_cb)
self.play_recording_button.connect('clicked',
self.handlePlayRecordingButton)
toolbar_box.toolbar.set_style(Gtk.ToolbarStyle.BOTH_HORIZ)
# TODO: disabe until is implemented with csnd6
# self.createPercussionToolbar(toolbar_box)
toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
keybord_labels = RadioToolButton()
keybord_labels.props.icon_name = 'q_key'
keybord_labels.props.group = keybord_labels
keybord_labels.connect('clicked', self.set_keyboard_labels_cb)
toolbar_box.toolbar.insert(keybord_labels, -1)
notes_labels = RadioToolButton()
notes_labels.props.icon_name = 'do_key'
notes_labels.props.group = keybord_labels
notes_labels.connect('clicked', self.set_notes_labels_cb)
toolbar_box.toolbar.insert(notes_labels, -1)
ti_notes_labels = RadioToolButton()
ti_notes_labels.props.icon_name = 'ti_key'
ti_notes_labels.props.group = keybord_labels
ti_notes_labels.connect('clicked', self.set_ti_notes_labels_cb)
toolbar_box.toolbar.insert(ti_notes_labels, -1)
german_labels = RadioToolButton()
german_labels.props.icon_name = 'c_key'
german_labels.props.group = keybord_labels
german_labels.connect('clicked', self.set_german_labels_cb)
toolbar_box.toolbar.insert(german_labels, -1)
no_labels = RadioToolButton()
no_labels.props.icon_name = 'edit-clear'
no_labels.props.group = keybord_labels
no_labels.connect('clicked', self.set_keyboard_no_labels_cb)
toolbar_box.toolbar.insert(no_labels, -1)
self._what_widget = Gtk.ToolItem()
self._what_search_button = FilterToolItem(_('Select Instrument'),
'view-type',
_('Piano'),
self._what_widget)
self._what_widget.show()
toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
toolbar_box.toolbar.insert(self._what_search_button, -1)
self._what_search_button.show()
self._what_search_button.set_is_important(True)
self._what_widget_contents = None
self._what_drum_widget_contents = None
separator = Gtk.SeparatorToolItem()
toolbar_box.toolbar.insert(separator, -1)
#.........这里部分代码省略.........
示例7: MemorizeActivity
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
class MemorizeActivity(Activity):
def __init__(self, handle):
Activity.__init__(self, handle)
self.play_mode = None
toolbar_box = ToolbarBox()
self.set_toolbar_box(toolbar_box)
self.activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(self.activity_button, -1)
self._memorizeToolbarBuilder = \
memorizetoolbar.MemorizeToolbarBuilder(self)
toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
self._edit_button = ToggleToolButton('view-source')
self._edit_button.set_tooltip(_('Edit game'))
self._edit_button.set_active(False)
toolbar_box.toolbar.insert(self._edit_button, -1)
self._createToolbarBuilder = \
createtoolbar.CreateToolbarBuilder(self)
separator = Gtk.SeparatorToolItem()
separator.set_expand(True)
separator.set_draw(False)
separator.set_size_request(0, -1)
toolbar_box.toolbar.insert(separator, -1)
toolbar_box.toolbar.insert(StopButton(self), -1)
self.game = game.MemorizeGame()
# Play game mode
self.table = cardtable.CardTable()
self.scoreboard = scoreboard.Scoreboard()
self.cardlist = cardlist.CardList()
self.createcardpanel = createcardpanel.CreateCardPanel(self.game)
self.cardlist.connect('pair-selected',
self.createcardpanel.pair_selected)
self.cardlist.connect(
'update-create-toolbar',
self._createToolbarBuilder.update_create_toolbar)
self.createcardpanel.connect('add-pair',
self.cardlist.add_pair)
self.createcardpanel.connect('update-pair',
self.cardlist.update_selected)
self.createcardpanel.connect('change-font',
self.cardlist.change_font)
self.createcardpanel.connect('pair-closed',
self.cardlist.rem_current_pair)
self._createToolbarBuilder.connect('create_new_game',
self.cardlist.clean_list)
self._createToolbarBuilder.connect('create_new_game',
self.createcardpanel.clean)
self._createToolbarBuilder.connect(
'create_new_game',
self._memorizeToolbarBuilder.reset)
self._createToolbarBuilder.connect('create_equal_pairs',
self.change_equal_pairs)
self._edit_button.connect('toggled', self._change_mode_bt)
self.connect('key-press-event', self.table.key_press_event)
self.table.connect('card-flipped', self.game.card_flipped)
self.table.connect('card-highlighted', self.game.card_highlighted)
self.game.connect('set-border', self.table.set_border)
self.game.connect('flop-card', self.table.flop_card)
self.game.connect('flip-card', self.table.flip_card)
self.game.connect('cement-card', self.table.cement_card)
self.game.connect('highlight-card', self.table.highlight_card)
self.game.connect('load_mode', self.table.load_msg)
self.game.connect('msg_buddy', self.scoreboard.set_buddy_message)
self.game.connect('add_buddy', self.scoreboard.add_buddy)
self.game.connect('rem_buddy', self.scoreboard.rem_buddy)
self.game.connect('increase-score', self.scoreboard.increase_score)
self.game.connect('wait_mode_buddy', self.scoreboard.set_wait_mode)
self.game.connect('change-turn', self.scoreboard.set_selected)
self.game.connect('change_game', self.scoreboard.change_game)
self.game.connect('reset_scoreboard', self.scoreboard.reset)
self.game.connect('reset_table', self.table.reset)
self.game.connect('load_game', self.table.load_game)
self.game.connect('change_game', self.table.change_game)
self.game.connect('load_game',
self._memorizeToolbarBuilder.update_toolbar)
self.game.connect('change_game',
self._memorizeToolbarBuilder.update_toolbar)
self.game.connect('change_game',
self.createcardpanel.update_font_combos)
self._memorizeToolbarBuilder.connect('game_changed',
self.change_game)
#.........这里部分代码省略.........
示例8: GetIABooksActivity
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
#.........这里部分代码省略.........
for section in config.sections():
if section.startswith('Catalogs'):
catalog_source = section.split('_')[1]
if not catalog_source in _SOURCES_CONFIG:
logging.error('There are not a source for the catalog ' +
'section %s', section)
break
source_config = _SOURCES_CONFIG[catalog_source]
opds_cover = source_config['opds_cover']
for catalog in config.options(section):
catalog_config = {}
catalog_config['query_uri'] = config.get(section, catalog)
catalog_config['opds_cover'] = opds_cover
catalog_config['source'] = catalog_source
catalog_config['name'] = catalog
catalog_config['summary_field'] = \
source_config['summary_field']
self.catalogs_configuration[catalog] = catalog_config
self.source = _SOURCES_CONFIG.keys()[0]
self.filter_catalogs_by_source()
logging.error('languages %s', pformat(self.languages))
logging.error('catalogs %s', pformat(self.catalogs))
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'))
示例9: MainToolbox
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
class MainToolbox(ToolbarBox):
query_changed_signal = GObject.Signal('query-changed',
arg_types=([object]))
def __init__(self, default_what_filter=None, default_filter_type=None):
ToolbarBox.__init__(self)
self._mount_point = None
self._filter_type = default_filter_type
self._what_filter = default_what_filter
self._when_filter = None
self._default_what_filter = default_what_filter
self._default_filter_type = default_filter_type
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._proj_list_button = ToggleToolButton('project-box')
self._proj_list_button.set_tooltip(_('Projects'))
self._proj_list_button.connect('toggled',
self._proj_list_button_clicked_cb)
self.toolbar.insert(self._proj_list_button, -1)
self._proj_list_button.show()
if not self._proj_list_button.props.active:
self._what_widget_contents = None
self._what_widget = Gtk.ToolItem()
self._what_search_button = FilterToolItem(
'view-type', _('Anything'), self._what_widget)
self._what_widget.show()
self.toolbar.insert(self._what_search_button, -1)
self._what_search_button.show()
self._when_search_button = FilterToolItem(
'view-created', _('Anytime'), self._get_when_search_items())
self.toolbar.insert(self._when_search_button, -1)
self._when_search_button.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_widget = Gtk.ToolItem()
self._with_search_button = FilterToolItem(
'view-who', _('Anyone'), self._with_widget)
self._with_widget.show()
self.toolbar.insert(self._with_search_button, -1)
self._with_search_button.show()
self._get_with_search_items()
'''
self._query = self._build_query()
self.refresh_filters()
self.connect('size_allocate', self.__size_allocate_cb)
def __size_allocate_cb(self, widget, allocation):
GObject.idle_add(self._update_buttons, allocation.width)
def _update_buttons(self, toolbar_width):
# Show the label next to the button icon if there is room on
# the toolbar.
important = toolbar_width > 13 * style.GRID_CELL_SIZE
if not important:
self.search_entry.set_size_request(
toolbar_width - style.GRID_CELL_SIZE * 7, 0)
self._what_search_button.set_is_important(important)
self._when_search_button.set_is_important(important)
# self._with_search_button.set_is_important(important)
return False
def _get_when_search_items(self):
when_list = []
when_list.append({'label': _('Anytime'),
'callback': self._when_palette_cb,
'id': _ACTION_ANYTIME})
#.........这里部分代码省略.........
示例10: ReadToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
class ReadToolbar(Gtk.Toolbar):
__gtype_name__ = 'ReadToolbar'
def __init__(self):
Gtk.Toolbar.__init__(self)
self.back = ToolButton('go-previous')
self.back.set_tooltip(_('Back'))
self.back.props.sensitive = False
palette = self.back.get_palette()
self.prev_page = MenuItem(text_label= _("Previous page"))
palette.menu.append(self.prev_page)
self.prev_page.show_all()
self.prev_bookmark = MenuItem(text_label= _("Previous bookmark"))
palette.menu.append(self.prev_bookmark)
self.prev_bookmark.show_all()
self.back.connect('clicked', self.go_back_cb)
self.prev_page.connect('activate', self.go_back_cb)
self.prev_bookmark.connect('activate', self.prev_bookmark_activate_cb)
self.insert(self.back, -1)
self.back.show()
self.forward = ToolButton('go-next')
self.forward.set_tooltip(_('Forward'))
self.forward.props.sensitive = False
palette = self.forward.get_palette()
self.next_page = MenuItem(text_label= _("Next page"))
palette.menu.append(self.next_page)
self.next_page.show_all()
self.next_bookmark = MenuItem(text_label= _("Next bookmark"))
palette.menu.append(self.next_bookmark)
self.next_bookmark.show_all()
self.forward.connect('clicked', self.go_forward_cb)
self.next_page.connect('activate', self.go_forward_cb)
self.next_bookmark.connect('activate', self.next_bookmark_activate_cb)
self.insert(self.forward, -1)
self.forward.show()
num_page_item = Gtk.ToolItem()
self.num_page_entry = Gtk.Entry()
self.num_page_entry.set_text('0')
self.num_page_entry.set_alignment(1)
self.num_page_entry.connect('insert-text',
self.num_page_entry_insert_text_cb)
self.num_page_entry.connect('activate',
self.num_page_entry_activate_cb)
self.num_page_entry.set_width_chars(4)
num_page_item.add(self.num_page_entry)
self.num_page_entry.show()
self.insert(num_page_item, -1)
num_page_item.show()
total_page_item = Gtk.ToolItem()
self.total_page_label = Gtk.Label()
self.total_page_label.set_markup("<span size='14000' foreground='black'>")
self.total_page_label.set_text(' / 0')
total_page_item.add(self.total_page_label)
self.total_page_label.show()
self.insert(total_page_item, -1)
total_page_item.show()
spacer = Gtk.SeparatorToolItem()
self.insert(spacer, -1)
spacer.show()
bookmarkitem = Gtk.ToolItem()
self.bookmarker = ToggleToolButton('emblem-favorite')
self.bookmarker.set_tooltip(_('Toggle Bookmark'))
self.bookmarker_handler_id = self.bookmarker.connect('clicked',
self.bookmarker_clicked_cb)
bookmarkitem.add(self.bookmarker)
self.insert(bookmarkitem, -1)
bookmarkitem.show_all()
underline_item = Gtk.ToolItem()
self.underline = ToggleToolButton('format-text-underline')
self.underline.set_tooltip(_('Underline'))
self.underline.props.sensitive = False
self.underline_id = self.underline.connect('clicked', self.underline_cb)
underline_item.add(self.underline)
self.insert(underline_item, -1)
underline_item.show_all()
def num_page_entry_insert_text_cb(self, entry, text, length, position):
if not re.match('[0-9]', text):
entry.emit_stop_by_name('insert-text')
return True
return False
def num_page_entry_activate_cb(self, entry):
if entry.props.text:
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
def __init__(self, abiword_canvas):
GObject.GObject.__init__(self)
self.font_name_combo = FontComboBox()
self.font_name_combo.set_font_name('Sans')
self._fonts_changed_id = self.font_name_combo.connect(
'changed', self._font_changed_cb, abiword_canvas)
self._abi_handler = abiword_canvas.connect('font-family',
self._font_family_cb)
self.insert(ToolComboBox(self.font_name_combo), -1)
self.font_size = FontSize()
self._abi_handler = abiword_canvas.connect('font-size',
self._font_size_cb)
self._changed_id = self.font_size.connect(
'changed', self._font_size_changed_cb, abiword_canvas)
self.insert(self.font_size, -1)
bold = ToggleToolButton('format-text-bold')
bold.set_tooltip(_('Bold'))
bold.props.accelerator = '<Ctrl>B'
bold_id = bold.connect('clicked', lambda sender:
abiword_canvas.toggle_bold())
abiword_canvas.connect('bold', lambda abi, b:
self._setToggleButtonState(bold, b, bold_id))
self.insert(bold, -1)
italic = ToggleToolButton('format-text-italic')
italic.set_tooltip(_('Italic'))
italic.props.accelerator = '<Ctrl>I'
italic_id = italic.connect('clicked', lambda sender:
abiword_canvas.toggle_italic())
abiword_canvas.connect('italic', lambda abi, b:
self._setToggleButtonState(italic, b,
italic_id))
self.insert(italic, -1)
underline = ToggleToolButton('format-text-underline')
underline.set_tooltip(_('Underline'))
underline.props.accelerator = '<Ctrl>U'
underline_id = underline.connect('clicked', lambda sender:
abiword_canvas.toggle_underline())
abiword_canvas.connect('underline', lambda abi, b:
self._setToggleButtonState(underline, b,
underline_id))
self.insert(underline, -1)
# for super/subscript, we're using the same keyboard shorcuts as
# abiword: <C-^> and <C-_>
super_btn = ToggleToolButton('format-text-super')
super_btn.set_tooltip(_('Superscript'))
# found with gtk.accelerator_name
super_btn.props.accelerator = '<Ctrl>asciicircum'
super_id = super_btn.connect('clicked', lambda sender:
abiword_canvas.toggle_super())
# no, this isn't a mistake. The method is called `toggle_super()', but
# the *signal* is called `superscript'. Same goes for sub{script,}.
abiword_canvas.connect('superscript', lambda abi, b:
self._setToggleButtonState(super_btn, b,
super_id))
self.insert(super_btn, -1)
sub = ToggleToolButton('format-text-sub')
sub.set_tooltip(_('Subscript'))
sub.props.accelerator = '<Ctrl>underscore'
sub_id = sub.connect('clicked', lambda sender:
abiword_canvas.toggle_sub())
abiword_canvas.connect('subscript', lambda abi, b:
self._setToggleButtonState(sub, b, sub_id))
self.insert(sub, -1)
color = ColorToolButton()
color.connect('notify::color', self._text_color_cb,
abiword_canvas)
tool_item = Gtk.ToolItem()
tool_item.add(color)
self.insert(tool_item, -1)
abiword_canvas.connect(
'color', lambda abi, r, g, b:
color.set_color(Gdk.Color(r * 256, g * 256, b * 256)))
# MAGIC NUMBER WARNING: Secondary toolbars are not a standard height?
self.set_size_request(-1, style.GRID_CELL_SIZE)
def append_align(icon_name, tooltip, do_abi_cb, style_name, button,
menu_box):
menu_item = AbiMenuItem(abiword_canvas, style_name, do_abi_cb,
icon_name, tooltip, button)
menu_box.append_item(menu_item)
menu_item.show()
self._aligment_btn = ToolButton(icon_name='format-justify-left')
self._aligment_btn.props.tooltip = _('Choose alignment')
self._aligment_btn.props.hide_tooltip_on_click = False
self._aligment_btn.palette_invoker.props.toggle_palette = True
menu_box = PaletteMenuBox()
self._aligment_btn.props.palette.set_content(menu_box)
menu_box.show()
#.........这里部分代码省略.........
示例12: WriteBooksActivity
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
class WriteBooksActivity(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self._book_model = BookModel()
self._actual_page = 1
# we do not have collaboration features
# make the share option insensitive
self.max_participants = 1
# get the language configured by the user
# will be used to translate the names of the media files
locale = os.environ.get('LANG', '')
language_location = locale.split('.', 1)[0].lower()
self._language = language_location.split('_')[0]
if self._language == 'en':
# we don't need translate the file names if langauage is 'en'
self._language = None
self._translations = None
if self._language is not None:
# read the translations file if available
dict_path = os.path.join(activity.get_bundle_path(), 'data',
"%s_dict.csv" % self._language)
logging.debug('Looking for media translation dictionary %s',
dict_path)
if os.path.exists(dict_path):
logging.debug('Loading translations')
self._translations = {}
with open(dict_path) as dict_file:
for line in dict_file:
words = line.split(',')
self._translations[words[0]] = words[1].strip()
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
self._edit_toolbar = EditToolbar()
edit_toolbar_button = ToolbarButton(
page=self._edit_toolbar, icon_name='toolbar-edit')
toolbar_box.toolbar.insert(edit_toolbar_button, 1)
set_background_button = ToolButton('set-background')
set_background_button.set_tooltip(_('Set the background'))
set_background_button.connect('clicked',
self.__set_background_clicked_cb)
toolbar_box.toolbar.insert(set_background_button, -1)
insert_picture_button = ToolButton('insert-picture')
insert_picture_button.set_tooltip(_('Add a picture'))
insert_picture_button.connect('clicked',
self.__add_image_clicked_cb)
toolbar_box.toolbar.insert(insert_picture_button, -1)
toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
self._duplicate_page_button = ToolButton()
icon = Icon(icon_name='edit-duplicate', xo_color=profile.get_color())
self._duplicate_page_button.set_icon_widget(icon)
self._duplicate_page_button.set_tooltip(_('Duplicate page'))
self._duplicate_page_button.connect(
'clicked', self.__duplicate_page_clicked_cb)
toolbar_box.toolbar.insert(self._duplicate_page_button, -1)
self._add_page_button = ToolButton('list-add')
self._add_page_button.set_tooltip(_('Add a page'))
self._add_page_button.connect('clicked', self.__add_page_clicked_cb)
toolbar_box.toolbar.insert(self._add_page_button, -1)
self._remove_button = ToolButton('edit-delete')
self._remove_button.set_tooltip(_('Remove an image or page'))
self._remove_button.connect('clicked', self.__remove_clicked_cb)
toolbar_box.toolbar.insert(self._remove_button, -1)
self._prev_page_button = ToolButton('go-previous-paired')
self._prev_page_button.set_tooltip(_('Previous page'))
self._prev_page_button.connect('clicked', self.__prev_page_clicked_cb)
toolbar_box.toolbar.insert(self._prev_page_button, -1)
self._next_page_button = ToolButton('go-next-paired')
self._next_page_button.set_tooltip(_('Next page'))
self._next_page_button.connect('clicked', self.__next_page_clicked_cb)
toolbar_box.toolbar.insert(self._next_page_button, -1)
self._view_list_button = ToggleToolButton('view-list')
self._view_list_button.set_tooltip(_('View pages'))
self._view_list_button.connect('toggled', self.__view_list_toggled_cb)
toolbar_box.toolbar.insert(self._view_list_button, -1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
stop_button = StopButton(self)
toolbar_box.toolbar.insert(stop_button, -1)
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.set_title('FotoToon')
self._max_participants = 1
self.page = None
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
activity_toolbar = activity_button.page
toolbar_box.toolbar.insert(activity_button, 0)
edit_toolbar_btn = ToolbarButton()
edit_toolbar = Gtk.Toolbar()
edit_toolbar_btn.props.page = edit_toolbar
edit_toolbar_btn.props.icon_name = 'toolbar-edit'
edit_toolbar_btn.label = _('Edit')
toolbar_box.toolbar.insert(edit_toolbar_btn, -1)
view_toolbar_btn = ToolbarButton()
view_toolbar = Gtk.Toolbar()
view_toolbar_btn.props.page = view_toolbar
view_toolbar_btn.props.icon_name = 'toolbar-view'
view_toolbar_btn.label = _('View')
toolbar_box.toolbar.insert(view_toolbar_btn, -1)
slideview_btn = ToggleToolButton('slideshow')
slideview_btn.set_tooltip(_('Slideshow'))
slideview_btn.set_active(False)
slideview_btn.connect('clicked', self._switch_view_mode, False)
view_toolbar.insert(slideview_btn, -1)
slideview_btn.show()
slideview_timings_btn = ToggleToolButton('slideshow-stopwatch')
slideview_timings_btn.set_tooltip(_('Slideshow with Timings'))
slideview_timings_btn.set_active(False)
slideview_timings_btn.connect('clicked', self._switch_view_mode, True)
view_toolbar.insert(slideview_timings_btn, -1)
slideview_timings_btn.show()
time_button = ToolButton('stopwatch')
time_button.set_tooltip(_('Set Image Duration in Slideshow (Seconds)'))
view_toolbar.insert(time_button, -1)
time_button.show()
self._time_spin = Gtk.SpinButton.new_with_range(MIN_TIME, MAX_TIME, 1)
self._time_spin.connect('value-changed', self.__time_spin_changed_cb)
self._time_spin.props.value = DEFAULT_TIME
self._time_spin.props.update_policy = \
Gtk.SpinButtonUpdatePolicy.IF_VALID
palette = time_button.get_palette()
palette.connect('popup', self.__time_button_popup_cb)
time_button.connect(
'clicked', lambda *args:
palette.popup(immediate=True, state=Palette.SECONDARY))
alignment = Gtk.Alignment()
alignment.set_padding(style.DEFAULT_PADDING, style.DEFAULT_PADDING,
style.DEFAULT_PADDING, style.DEFAULT_PADDING)
alignment.add(self._time_spin)
self._time_spin.show()
palette.set_content(alignment)
alignment.show()
fullscreen_btn = ToolButton('view-fullscreen')
fullscreen_btn.set_tooltip(_('Fullscreen'))
fullscreen_btn.props.accelerator = '<Alt>Return'
fullscreen_btn.connect('clicked', lambda w: self.fullscreen())
view_toolbar.insert(fullscreen_btn, -1)
fullscreen_btn.show()
self.set_toolbar_box(toolbar_box)
toolbar = toolbar_box.toolbar
self.page = Page()
self.globes_manager = GlobesManager(toolbar, edit_toolbar, self)
# fonts
self._text_button = ToolbarButton()
self._text_button.props.page = TextToolbar(self.page)
self._text_button.props.icon_name = 'format-text-size'
self._text_button.props.label = _('Text')
self._toolbar_box.toolbar.insert(self._text_button, -1)
reorder_img_btn = ToolButton('thumbs-view')
reorder_img_btn.set_icon_name('thumbs-view')
reorder_img_btn.set_tooltip(_('Change image order'))
reorder_img_btn.connect('clicked', self.__image_order_cb)
edit_toolbar.insert(reorder_img_btn, -1)
reorder_img_btn.show()
bgchange = ToolButton(icon_name='contract-coordinates')
bgchange.set_tooltip(_('Edit background image'))
bgchange.connect('clicked', self.__bgchange_clicked_cb)
edit_toolbar.insert(bgchange, -1)
bgchange.show()
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.set_title('FotoToon')
self._max_participants = 1
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
activity_toolbar = activity_button.page
toolbar_box.toolbar.insert(activity_button, 0)
edit_toolbar_btn = ToolbarButton()
edit_toolbar = Gtk.Toolbar()
edit_toolbar_btn.props.page = edit_toolbar
edit_toolbar_btn.props.icon_name = 'toolbar-edit'
edit_toolbar_btn.label = _('Edit')
toolbar_box.toolbar.insert(edit_toolbar_btn, -1)
view_toolbar_btn = ToolbarButton()
view_toolbar = Gtk.Toolbar()
view_toolbar_btn.props.page = view_toolbar
view_toolbar_btn.props.icon_name = 'toolbar-view'
view_toolbar_btn.label = _('View')
toolbar_box.toolbar.insert(view_toolbar_btn, -1)
slideview_btn = ToggleToolButton('slideshow')
slideview_btn.set_tooltip(_('Slideshow'))
slideview_btn.set_active(False)
view_toolbar.insert(slideview_btn, -1)
slideview_btn.show()
fullscreen_btn = ToolButton('view-fullscreen')
fullscreen_btn.set_tooltip(_('Fullscreen'))
fullscreen_btn.props.accelerator = '<Alt>Return'
fullscreen_btn.connect('clicked', lambda w: self.fullscreen())
view_toolbar.insert(fullscreen_btn, -1)
fullscreen_btn.show()
self.set_toolbar_box(toolbar_box)
toolbar = toolbar_box.toolbar
self.page = Page()
self.globes_manager = GlobesManager(toolbar, edit_toolbar, self)
# fonts
text_button = ToolbarButton()
text_button.props.page = TextToolbar(self.page)
text_button.props.icon_name = 'format-text-size'
text_button.props.label = _('Text')
slideview_btn.connect('clicked', self._switch_view_mode, text_button)
toolbar_box.toolbar.insert(text_button, -1)
reorder_img_btn = ToolButton('thumbs-view')
reorder_img_btn.set_icon_name('thumbs-view')
reorder_img_btn.set_tooltip(_('Change image order'))
reorder_img_btn.connect('clicked', self.__image_order_cb)
edit_toolbar.insert(reorder_img_btn, -1)
reorder_img_btn.show()
bgchange = ToolButton(icon_name='contract-coordinates')
bgchange.set_tooltip(_('Edit background image'))
bgchange.connect('clicked', self.__bgchange_clicked_cb)
edit_toolbar.insert(bgchange, -1)
bgchange.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
stop = StopButton(self)
toolbar_box.toolbar.insert(stop, -1)
toolbar_box.show_all()
# add export button
separator_2 = Gtk.SeparatorToolItem()
separator_2.show()
activity_toolbar.insert(separator_2, -1)
self.bt_save_as_image = ToolButton()
self.bt_save_as_image.props.icon_name = 'save-as-image'
self.bt_save_as_image.connect('clicked', self.write_image)
self.bt_save_as_image.set_tooltip(_('Save as Image'))
activity_toolbar.insert(self.bt_save_as_image, -1)
self.bt_save_as_image.show()
save_as_pdf = ToolButton()
save_as_pdf.props.icon_name = 'save-as-pdf'
save_as_pdf.connect('clicked', self._save_as_pdf)
save_as_pdf.set_tooltip(_('Save as a Book (PDF)'))
activity_toolbar.insert(save_as_pdf, -1)
save_as_pdf.show()
activity_button.page.title.connect("focus-in-event", self.on_title)
#.........这里部分代码省略.........
示例15: CardEditor
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import connect [as 别名]
class CardEditor(Gtk.EventBox):
__gsignals__ = {
'has-text': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'has-picture': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'has-sound': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'change-font': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
}
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 = Card(
-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)
self.usespeak = ToggleToolButton(icon_name='speak')
self.usespeak.set_palette(SpeakPalette(self))
toolbar.add(self.usespeak)
self.usespeak.connect('toggled', self._usespeak_cb)
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)
def __font_changed_cb(self, widget):
font = widget.get_font_name()
if font:
self.card.change_font(font)
self.emit('change-font', font)
def set_font_name(self, font_name):
self.fontbutton.handler_block(self.id_font_changed)
self.fontbutton.set_font_name(font_name)
self.fontbutton.handler_unblock(self.id_font_changed)
def update_text(self, entry):
self.card.change_text(entry.get_text())
if len(entry.get_text()) == 0:
self.emit('has-text', False)
else:
self.emit('has-text', True)
def get_text(self):
return self.textentry.get_text()
def set_text(self, newtext):
if newtext is None:
newtext = ''
self.textentry.set_text(newtext)
def get_speak(self):
if self.usespeak is None:
return None
if self.usespeak.props.active:
return self.usespeak.palette.face.status.voice.language
def set_speak(self, value):
if self.usespeak is None:
#.........这里部分代码省略.........