本文整理汇总了Python中sugar3.graphics.toggletoolbutton.ToggleToolButton.show方法的典型用法代码示例。如果您正苦于以下问题:Python ToggleToolButton.show方法的具体用法?Python ToggleToolButton.show怎么用?Python ToggleToolButton.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.toggletoolbutton.ToggleToolButton
的用法示例。
在下文中一共展示了ToggleToolButton.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ViewToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [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: toggle_factory
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [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()
示例3: RecordToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
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()
示例4: __init__
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [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: SimplePianoActivity
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [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)
#.........这里部分代码省略.........
示例6: GetIABooksActivity
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
class GetIABooksActivity(activity.Activity):
def __init__(self, handle):
"The entry point to the Activity"
activity.Activity.__init__(self, handle, False)
self.max_participants = 1
self._sequence = 0
self.selected_book = None
self.queryresults = None
self._getter = None
self.show_images = True
self.languages = {}
self._lang_code_handler = languagenames.LanguageNames()
self.catalogs_configuration = {}
self.catalog_history = []
if os.path.exists('/etc/get-books.cfg'):
self._read_configuration('/etc/get-books.cfg')
else:
self._read_configuration()
toolbar_box = ToolbarBox()
activity_button = ToolButton()
color = profile.get_color()
bundle = ActivityBundle(activity.get_bundle_path())
icon = Icon(file=bundle.get_icon(), xo_color=color)
activity_button.set_icon_widget(icon)
activity_button.show()
toolbar_box.toolbar.insert(activity_button, 0)
self._add_search_controls(toolbar_box.toolbar)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
toolbar_box.toolbar.insert(StopButton(self), -1)
self.set_toolbar_box(toolbar_box)
toolbar_box.show_all()
self._books_toolbar = toolbar_box.toolbar
self._create_controls()
self.using_powerd = os.access(POWERD_INHIBIT_DIR, os.W_OK)
self.__book_downloader = self.__image_downloader = None
def get_path(self):
self._sequence += 1
return os.path.join(self.get_activity_root(),
'instance', '%03d.tmp' % self._sequence)
def _inhibit_suspend(self):
if self.using_powerd:
fd = open(POWERD_INHIBIT_DIR + "/%u" % os.getpid(), 'w')
logging.error("inhibit_suspend file is %s", (POWERD_INHIBIT_DIR \
+ "/%u" % os.getpid()))
fd.close()
return True
return False
def _allow_suspend(self):
if self.using_powerd:
if os.path.exists(POWERD_INHIBIT_DIR + "/%u" % os.getpid()):
os.unlink(POWERD_INHIBIT_DIR + "/%u" % os.getpid())
logging.error("allow_suspend unlinking %s", (POWERD_INHIBIT_DIR \
+ "/%u" % os.getpid()))
return True
return False
def _read_configuration(self, file_name='get-books.cfg'):
logging.error('Reading configuration from file %s', file_name)
config = ConfigParser.ConfigParser()
config.readfp(open(file_name))
if config.has_option('GetBooks', 'show_images'):
self.show_images = config.getboolean('GetBooks', 'show_images')
self.languages = {}
if config.has_option('GetBooks', 'languages'):
languages_param = config.get('GetBooks', 'languages')
for language in languages_param.split(','):
lang_code = language.strip()
if len(lang_code) > 0:
self.languages[lang_code] = \
self._lang_code_handler.get_full_language_name(lang_code)
for section in config.sections():
if section != 'GetBooks' and not section.startswith('Catalogs'):
name = config.get(section, 'name')
_SOURCES[section] = name
repo_config = {}
repo_config['query_uri'] = config.get(section, 'query_uri')
repo_config['opds_cover'] = config.get(section, 'opds_cover')
if config.has_option(section, 'summary_field'):
repo_config['summary_field'] = \
config.get(section, 'summary_field')
#.........这里部分代码省略.........
示例7: TextToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
class TextToolbar(Gtk.Toolbar):
_ACTION_TEXT_NAME = 'text'
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()
def __bold_bt_cb(self, button):
fd = self._activity.area.get_font_description()
if button.get_active():
fd.set_weight(Pango.Weight.BOLD)
else:
fd.set_weight(Pango.Weight.NORMAL)
self._activity.area.set_font_description(fd)
def __italic_bt_cb(self, button):
fd = self._activity.area.get_font_description()
if button.get_active():
fd.set_style(Pango.Style.ITALIC)
else:
fd.set_style(Pango.Style.NORMAL)
self._activity.area.set_font_description(fd)
def __font_size_changed_cb(self, widget):
fd = self._activity.area.get_font_description()
value = widget.get_font_size()
fd.set_size(int(value) * Pango.SCALE)
self._activity.area.set_font_description(fd)
def __font_changed_cb(self, combo):
fd = self._activity.area.get_font_description()
font_name = combo.get_font_name()
fd.set_family(font_name)
self._activity.area.set_font_description(fd)
def get_active_text(self, combobox):
model = combobox.get_model()
active = combobox.get_active()
if active < 0:
return None
return model[active][0]
def set_tool(self, widget, tool_name):
self.properties['name'] = tool_name
self._activity.area.set_tool(self.properties)
示例8: SpeechToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
class SpeechToolbar(Gtk.Toolbar):
def __init__(self):
Gtk.Toolbar.__init__(self)
self.activity = None
self._speech = SpeechManager()
self._voices = self._speech.get_all_voices() # a dictionary
locale = os.environ.get('LANG', '')
language_location = locale.split('.', 1)[0].lower()
language = language_location.split('_')[0]
# if the language is es but not es_es default to es_la (latin voice)
if language == 'es' and language_location != 'es_es':
language_location = 'es_la'
self._voice = 'en_us'
if language_location in self._voices:
self._voice = language_location
elif language in self._voices:
self._voice = language
voice_names = []
for language, name in self._voices.iteritems():
voice_names.append((language, name))
voice_names.sort(self._compare_voices)
# Play button Image
play_img = Gtk.Image()
play_img.show()
play_img.set_from_icon_name('media-playback-start',
Gtk.IconSize.LARGE_TOOLBAR)
# Pause button Image
pause_img = Gtk.Image()
pause_img.show()
pause_img.set_from_icon_name('media-playback-pause',
Gtk.IconSize.LARGE_TOOLBAR)
# Play button
self.play_button = ToggleToolButton('media-playback-start')
self.play_button.show()
self.play_button.connect('toggled', self._play_toggled_cb, [play_img, pause_img])
self.insert(self.play_button, -1)
self.play_button.set_tooltip(_('Play / Pause'))
combo = ComboBox()
which = 0
for pair in voice_names:
language, name = pair
combo.append_item(language, name)
if language == self._voice:
combo.set_active(which)
which += 1
combo.connect('changed', self._voice_changed_cb)
combotool = ToolComboBox(combo)
self.insert(combotool, -1)
combotool.show()
self.pitchadj = Gtk.Adjustment(0, -100, 100, 1, 10, 0)
pitchbar = Gtk.HScale()
pitchbar.set_adjustment(self.pitchadj)
pitchbar.set_draw_value(False)
# pitchbar.set_update_policy(Gtk.UpdatePolicy.ALWAYS)
pitchbar.set_size_request(150,15)
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()
ratebar.set_adjustment(self.rateadj)
ratebar.set_draw_value(False)
#ratebar.set_update_policy(Gtk.UpdatePolicy.ALWAYS)
ratebar.set_size_request(150,15)
ratetool = Gtk.ToolItem()
ratetool.add(ratebar)
ratetool.show()
self.insert(ratetool, -1)
ratebar.show()
def _compare_voices(self, a, b):
if a[1].lower() == b[1].lower():
return 0
if a[1].lower() < b[1].lower():
return -1
if a[1].lower() > b[1].lower():
return 1
def _voice_changed_cb(self, combo):
self._voice = combo.props.value
self._speech.say_text(self._voices[self._voice])
def pitch_adjusted_cb(self, get):
self._speech.set_pitch(int(get.get_value()))
self._speech.say_text(_("pitch adjusted"))
f = open(os.path.join(self.activity.get_activity_root(), 'instance', 'pitch.txt'), 'w')
try:
f.write(str(self._speech.get_pitch()))
#.........这里部分代码省略.........
示例9: _build_toolbox
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
def _build_toolbox(self):
toolbar_box = ToolbarBox()
self.max_participants = 1
activity_button = ActivityToolbarButton(self)
activity_toolbar = activity_button.page
self._toolbar = toolbar_box.toolbar
self._toolbar.insert(activity_button, -1)
self._secondary_toolbar = Gtk.Toolbar()
self._secondary_toolbar_button = ToolbarButton(
page=self._secondary_toolbar,
icon_name='system-search')
self._secondary_toolbar.show()
self._toolbar.insert(self._secondary_toolbar_button, -1)
self._secondary_toolbar_button.hide()
show_list = ToggleToolButton('view-list')
show_list.set_active(True)
show_list.set_tooltip(_('Show list of files'))
show_list.connect('toggled', self._list_toggled_cb)
self._toolbar.insert(show_list, -1)
show_list.show()
copy = CopyButton()
copy.connect('clicked', self.__copy_clicked_cb)
self._toolbar.insert(copy, -1)
wrap_btn = ToggleToolButton("format-wrap")
wrap_btn.set_tooltip(_('Word Wrap'))
wrap_btn.connect('clicked', self._wrap_cb)
self._toolbar.insert(wrap_btn, -1)
self.search_entry = iconentry.IconEntry()
self.search_entry.set_size_request(Gdk.Screen.width() / 3, -1)
self.search_entry.set_icon_from_name(
iconentry.ICON_ENTRY_PRIMARY, 'entry-search')
self.search_entry.add_clear_button()
self.search_entry.connect('activate', self._search_entry_activate_cb)
self.search_entry.connect('changed', self._search_entry_changed_cb)
self._search_item = Gtk.ToolItem()
self._search_item.add(self.search_entry)
self._toolbar.insert(self._search_item, -1)
self._search_prev = ToolButton('go-previous-paired')
self._search_prev.set_tooltip(_('Previous'))
self._search_prev.connect('clicked', self._search_prev_cb)
self._toolbar.insert(self._search_prev, -1)
self._search_next = ToolButton('go-next-paired')
self._search_next.set_tooltip(_('Next'))
self._search_next.connect('clicked', self._search_next_cb)
self._toolbar.insert(self._search_next, -1)
self._update_search_buttons()
self.collector_palette = CollectorPalette(self)
collector_btn = ToolButton('log-export')
collector_btn.set_palette(self.collector_palette)
collector_btn.connect('clicked', self._logviewer_cb)
collector_btn.show()
activity_toolbar.insert(collector_btn, -1)
self._delete_btn = ToolButton('list-remove')
self._delete_btn.set_tooltip(_('Delete Log File'))
self._delete_btn.connect('clicked', self._delete_log_cb)
self._toolbar.insert(self._delete_btn, -1)
self._separator = Gtk.SeparatorToolItem()
self._separator.set_expand(True)
self._separator.set_draw(False)
self._toolbar.insert(self._separator, -1)
self._stop_btn = StopButton(self)
self._toolbar.insert(self._stop_btn, -1)
toolbar_box.show_all()
self.set_toolbar_box(toolbar_box)
示例10: __init__
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [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()
#.........这里部分代码省略.........
示例11: ToolbarBox
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
vbox.show()
toolbar_box = ToolbarBox()
vbox.pack_start(toolbar_box, False, False, 0)
toolbar_box.show()
radial_button = RadioToolButton(icon_name='view-radial')
toolbar_box.toolbar.insert(radial_button, -1)
radial_button.show()
list_button = RadioToolButton(icon_name='view-list')
list_button.props.group = radial_button
toolbar_box.toolbar.insert(list_button, -1)
list_button.show()
separator = Gtk.SeparatorToolItem()
toolbar_box.toolbar.insert(separator, -1)
separator.show()
color_button = ColorToolButton()
toolbar_box.toolbar.insert(color_button, -1)
color_button.show()
favorite_button = ToggleToolButton('emblem-favorite')
toolbar_box.toolbar.insert(favorite_button, -1)
favorite_button.show()
if __name__ == '__main__':
common.main(test)
示例12: SpeechToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
class SpeechToolbar(Gtk.Toolbar):
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)
def compare_voices(self, a, b):
if a[0].lower() == b[0].lower():
return 0
if a[0] .lower() < b[0].lower():
return -1
if a[0] .lower() > b[0].lower():
return 1
def voice_changed_cb(self, combo):
speech.voice = combo.props.value
speech.say(speech.voice[0])
self.save_speech_parameters()
def pitch_adjusted_cb(self, get):
speech.pitch = int(get.value)
speech.say(_("pitch adjusted"))
self.save_speech_parameters()
def rate_adjusted_cb(self, get):
speech.rate = int(get.value)
speech.say(_("rate adjusted"))
self.save_speech_parameters()
def load_speech_parameters(self):
speech_parameters = {}
data_path = os.path.join(self._activity.get_activity_root(), 'data')
data_file_name = os.path.join(data_path, 'speech_params.json')
if os.path.exists(data_file_name):
f = open(data_file_name, 'r')
try:
speech_parameters = simplejson.load(f)
speech.pitch = speech_parameters['pitch']
speech.rate = speech_parameters['rate']
speech.voice = speech_parameters['voice']
finally:
f.close()
def save_speech_parameters(self):
#.........这里部分代码省略.........
示例13: PrimaryToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
class PrimaryToolbar(ToolbarBase):
__gtype_name__ = 'PrimaryToolbar'
__gsignals__ = {
'add-link': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'remove-link': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'go-home': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'set-home': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'reset-home': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'go-library': (GObject.SignalFlags.RUN_FIRST, None, ([])),
}
def __init__(self, tabbed_view, act):
ToolbarBase.__init__(self)
self._url_toolbar = UrlToolbar()
self._activity = act
self.model = act.model
self.model.link_removed_signal.connect(self.__link_removed_cb)
self._tabbed_view = self._canvas = tabbed_view
self._loading = False
self._download_running_hid = None
toolbar = self.toolbar
activity_button = ActivityToolbarButton(self._activity)
toolbar.insert(activity_button, 0)
separator = Gtk.SeparatorToolItem()
'''
Disabled since the python gi bindings don't expose the critical
WebKit2.PrintOperation.print function
save_as_pdf = ToolButton('save-as-pdf')
save_as_pdf.set_tooltip(_('Save page as pdf'))
save_as_pdf.connect('clicked', self.save_as_pdf)
activity_button.props.page.insert(separator, -1)
activity_button.props.page.insert(save_as_pdf, -1)
separator.show()
save_as_pdf.show()
'''
inspect_view = ToolButton('emblem-view-source')
inspect_view.set_tooltip(_('Show Web Inspector'))
inspect_view.connect('clicked', self.inspect_view)
activity_button.props.page.insert(separator, -1)
activity_button.props.page.insert(inspect_view, -1)
separator.show()
inspect_view.show()
self._go_home = ToolButton('go-home')
self._go_home.set_tooltip(_('Home page'))
self._go_home.connect('clicked', self._go_home_cb)
# add a menu to save the home page
menu_box = PaletteMenuBox()
self._go_home.props.palette.set_content(menu_box)
menu_item = PaletteMenuItem()
menu_item.set_label(_('Select as initial page'))
menu_item.connect('activate', self._set_home_cb)
menu_box.append_item(menu_item)
self._reset_home_menu = PaletteMenuItem()
self._reset_home_menu.set_label(_('Reset initial page'))
self._reset_home_menu.connect('activate', self._reset_home_cb)
menu_box.append_item(self._reset_home_menu)
if os.path.isfile(LIBRARY_PATH):
library_menu = PaletteMenuItem()
library_menu.set_label(_('Library'))
library_menu.connect('activate', self._go_library_cb)
menu_box.append_item(library_menu)
menu_box.show_all()
# verify if the home page is configured
client = GConf.Client.get_default()
self._reset_home_menu.set_visible(
client.get_string(HOME_PAGE_GCONF_KEY) is not None)
toolbar.insert(self._go_home, -1)
self._go_home.show()
self.entry = WebEntry()
self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
'entry-stop')
self.entry.connect('icon-press', self._stop_and_reload_cb)
self.entry.connect('activate', self._entry_activate_cb)
self.entry.connect('focus-in-event', self.__focus_in_event_cb)
self.entry.connect('focus-out-event', self.__focus_out_event_cb)
self.entry.connect('key-press-event', self.__key_press_event_cb)
self.entry.connect('changed', self.__changed_cb)
# In an event box so that it can render the background
entry_box = Gtk.EventBox()
entry_box.add(self.entry)
entry_box.show()
#.........这里部分代码省略.........
示例14: ViewToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
class ViewToolbar(Gtk.Toolbar):
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)
def __switch_page_cb(self, tabbed_view, page, page_num):
self._connect_to_browser(tabbed_view.props.current_browser)
def _connect_to_browser(self, browser):
self._browser = browser
self._update_zoom_buttons()
def _update_zoom_buttons(self):
is_webkit_browser = isinstance(self._browser, Browser)
self.zoomin.set_sensitive(is_webkit_browser)
self.zoomout.set_sensitive(is_webkit_browser)
self.zoom_original.set_sensitive(is_webkit_browser)
def __zoom_original_clicked_cb(self, button):
tabbed_view = self._activity.get_canvas()
tabbed_view.props.current_browser.set_zoom_level(ZOOM_ORIGINAL)
def __zoomin_clicked_cb(self, button):
tabbed_view = self._activity.get_canvas()
tabbed_view.props.current_browser.zoom_in()
def __zoomout_clicked_cb(self, button):
tabbed_view = self._activity.get_canvas()
tabbed_view.props.current_browser.zoom_out()
def __fullscreen_clicked_cb(self, button):
self._activity.fullscreen()
def __tray_toggled_cb(self, button):
if button.props.active:
self._activity.tray.show()
else:
self._activity.tray.hide()
self.update_traybutton_tooltip()
def update_traybutton_tooltip(self):
if not self.traybutton.props.active:
self.traybutton.set_tooltip(_('Show Tray'))
else:
self.traybutton.set_tooltip(_('Hide Tray'))
示例15: SpeechToolbar
# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import show [as 别名]
class SpeechToolbar(Gtk.Toolbar):
def __init__(self):
Gtk.Toolbar.__init__(self)
voicebar = Gtk.Toolbar()
self.activity = None
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] == 'default':
break
default = default + 1
# Play button Image
play_img = Gtk.Image()
play_img.show()
play_img.set_from_icon_name('media-playback-start',
Gtk.IconSize.LARGE_TOOLBAR)
# Pause button Image
pause_img = Gtk.Image()
pause_img.show()
pause_img.set_from_icon_name('media-playback-pause',
Gtk.IconSize.LARGE_TOOLBAR)
# Play button
self.play_btn = ToggleToolButton('media-playback-start')
self.play_btn.show()
self.play_btn.connect('toggled', self.play_cb, [play_img, pause_img])
self.insert(self.play_btn, -1)
self.play_btn.set_tooltip(_('Play / Pause'))
self.voice_combo = ComboBox()
self.voice_combo.connect('changed', self.voice_changed_cb)
for voice in self.sorted_voices:
self.voice_combo.append_item(voice, voice[0])
self.voice_combo.set_active(default)
combotool = ToolComboBox(self.voice_combo)
self.insert(combotool, -1)
combotool.show()
self.pitchadj = Gtk.Adjustment(0, -100, 100, 1, 10, 0)
pitchbar = Gtk.HScale()
pitchbar.set_adjustment(self.pitchadj)
pitchbar.set_draw_value(False)
# pitchbar.set_update_policy(Gtk.UpdatePolicy.ALWAYS)
pitchbar.set_size_request(150,15)
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()
ratebar.set_adjustment(self.rateadj)
ratebar.set_draw_value(False)
#ratebar.set_update_policy(Gtk.UpdatePolicy.ALWAYS)
ratebar.set_size_request(150,15)
ratetool = Gtk.ToolItem()
ratetool.add(ratebar)
ratetool.show()
self.insert(ratetool, -1)
ratebar.show()
def compare_voices(self, a, b):
if a[0].lower() == b[0].lower():
return 0
if a[0].lower() < b[0].lower():
return -1
if a[0].lower() > b[0].lower():
return 1
def voice_changed_cb(self, combo):
speech.voice = combo.props.value
if self.activity != None:
speech.say(speech.voice[0])
def pitch_adjusted_cb(self, get):
speech.pitch = int(get.get_value())
speech.say(_("pitch adjusted"))
f = open(os.path.join(self.activity.get_activity_root(), 'instance', 'pitch.txt'), 'w')
try:
f.write(str(speech.pitch))
finally:
f.close()
def rate_adjusted_cb(self, get):
speech.rate = int(get.get_value())
speech.say(_("rate adjusted"))
f = open(os.path.join(self.activity.get_activity_root(), 'instance', 'rate.txt'), 'w')
try:
f.write(str(speech.rate))
finally:
f.close()
def set_activity(self, activity):
self.activity = activity
if os.path.exists(os.path.join(activity.get_activity_root(), 'instance', 'pitch.txt')):
f = open(os.path.join(activity.get_activity_root(), 'instance', 'pitch.txt'), 'r')
#.........这里部分代码省略.........