本文整理汇总了Python中sugar3.graphics.toolbutton.ToolButton.set_icon方法的典型用法代码示例。如果您正苦于以下问题:Python ToolButton.set_icon方法的具体用法?Python ToolButton.set_icon怎么用?Python ToolButton.set_icon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.toolbutton.ToolButton
的用法示例。
在下文中一共展示了ToolButton.set_icon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TuningToolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon [as 别名]
#.........这里部分代码省略.........
def _setup_tuning_palette(self, instrument):
self._tuning_palette = self._tuning_button.get_palette()
self.tuning = []
self.tuning.append(_('All notes'))
menu_item = MenuItem(icon_name='', text_label=_('All notes'))
menu_item.connect('activate', self._tuning_selected_cb,
instrument, -1)
self._tuning_palette.menu.append(menu_item)
menu_item.show()
for i, f in enumerate(INSTRUMENT_DICT[instrument]):
self.tuning.append(freq_note(f))
menu_item = MenuItem(icon_name='',
text_label=freq_note(f))
menu_item.connect('activate', self._tuning_selected_cb,
instrument, i)
self._tuning_palette.menu.append(menu_item)
menu_item.show()
self.show_all()
def _tuning_selected_cb(self, widget, instrument, fidx):
''' Update note '''
if not hasattr(self, '_freq_entry'): # Still setting up toolbar?
return
if instrument not in INSTRUMENT_DICT:
return
if fidx == -1: # All notes
self.activity.wave.instrument = instrument
self.activity.wave.tuning_line = 0.0
self._new_tuning_line.set_icon('tuning-tools')
self._new_tuning_line.set_tooltip(_('Show tuning line.'))
self._show_tuning_line = False
else:
freq = INSTRUMENT_DICT[instrument][fidx]
self.activity.wave.instrument = None
self.activity.wave.tuning_line = freq
self._new_tuning_line.set_icon('tuning-tools-off')
self._new_tuning_line.set_tooltip(_('Hide tuning line.'))
self._show_tuning_line = True
self._updating_note = False
def harmonic_cb(self, *args):
''' Callback for harmonics control '''
self.activity.wave.harmonics = not self.activity.wave.harmonics
if self.activity.wave.harmonics:
self._harmonic.set_icon_name('harmonics-off')
self._harmonic.set_tooltip(_('Hide harmonics.'))
if self.activity.wave.instrument is None and \
self.activity.wave.tuning_line == 0.0:
self._load_tuning_line()
else:
self._harmonic.set_icon_name('harmonics')
self._harmonic.set_tooltip(_('Show harmonics.'))
def tuning_line_cb(self, *args):
''' Callback for tuning insert '''
if self._show_tuning_line:
self.activity.wave.tuning_line = 0.0
self._new_tuning_line.set_icon_name('tuning-tools')
self._new_tuning_line.set_tooltip(_('Show tuning line.'))
self._show_tuning_line = False
示例2: ViewToolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon [as 别名]
class ViewToolbar(Gtk.Toolbar):
def __init__(self, activity):
GObject.GObject.__init__(self)
self._browser = None
self._activity = activity
self._activity.tray.connect('unmap', self.__unmap_cb)
self._activity.tray.connect('map', self.__map_cb)
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.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 = ToolButton('tray-hide')
self.traybutton.connect('clicked', self.__tray_clicked_cb)
self.traybutton.props.sensitive = 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)
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_clicked_cb(self, button):
if self._activity.tray.props.visible is False:
self._activity.tray.show()
else:
self._activity.tray.hide()
def __map_cb(self, tray):
if len(self._activity.tray.get_children()) > 0:
self.tray_set_hide()
def __unmap_cb(self, tray):
if len(self._activity.tray.get_children()) > 0:
self.tray_set_show()
def tray_set_show(self):
self.traybutton.set_icon('tray-show')
self.traybutton.set_tooltip(_('Show Tray'))
def tray_set_hide(self):
self.traybutton.set_icon('tray-hide')
self.traybutton.set_tooltip(_('Hide Tray'))
示例3: ErikosActivity
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon [as 别名]
class ErikosActivity(activity.Activity):
def __init__(self, handle):
super(ErikosActivity, self).__init__(handle)
toolbar_box = ToolbarBox()
# Buttons added to the Activity toolbar
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
# Play Button
self.play = ToolButton("media-playback-start")
self.play.set_tooltip(_('Play'))
self.play.props.sensitive = True
self.play.connect('clicked', self._play_cb)
toolbar_box.toolbar.insert(self.play, -1)
self.play.show()
# Sound Toggle Button
self.sound = ToolButton("speaker-muted-100")
self.sound.set_tooltip(_('Mute'))
self.sound.props.sensitive = True
self.sound.connect('clicked', self._sound_cb)
toolbar_box.toolbar.insert(self.sound, -1)
self.sound.show()
separator = Gtk.SeparatorToolItem()
separator.show()
toolbar_box.toolbar.insert(separator, -1)
# Label for showing level
self.level_label = Gtk.Label("%s %d" % (_("Level"),1))
self.level_label.show()
level_toolitem = Gtk.ToolItem()
level_toolitem.add(self.level_label)
toolbar_box.toolbar.insert(level_toolitem,-1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
separator.show()
toolbar_box.toolbar.insert(separator, -1)
# The ever-present Stop Button
stop_button = StopButton(self)
stop_button.props.accelerator = '<Ctrl>Q'
toolbar_box.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
# Initialize the canvas
self.sw = window.new_window(canvas, \
os.path.join(activity.get_bundle_path(), \
'images/'), \
self)
self.sw.activity = self
# Read the level from the Journal
try:
sw.level = int(self.metadata['level'])
except:
pass
def _play_cb(self, button):
window.play_the_game(self.sw)
return True
def _sound_cb(self, button):
if self.sw.sound is True:
self.sound.set_icon("speaker-muted-000")
self.sound.set_tooltip(_('Unmute'))
self.sw.sound = False
else:
self.sound.set_icon("speaker-muted-100")
self.sound.set_tooltip(_('Mute'))
self.sw.sound = True
return True
"""
Write the slider positions to the Journal
"""
def write_file(self, file_path):
_logger.debug("Write level: " + str(self.sw.level))
self.metadata['level'] = self.sw.level