当前位置: 首页>>代码示例>>Python>>正文


Python ToolButton.set_icon_name方法代码示例

本文整理汇总了Python中sugar3.graphics.toolbutton.ToolButton.set_icon_name方法的典型用法代码示例。如果您正苦于以下问题:Python ToolButton.set_icon_name方法的具体用法?Python ToolButton.set_icon_name怎么用?Python ToolButton.set_icon_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugar3.graphics.toolbutton.ToolButton的用法示例。


在下文中一共展示了ToolButton.set_icon_name方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_toolbar

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]
    def setup_toolbar(self):
        toolbar_box = ToolbarBox()
        activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        # Test Button
        video_toggle_button = ToolButton()
        video_toggle_button.connect("clicked", self.test_toggle)
        video_toggle_button.set_icon_name('activity-start')
        video_toggle_button.set_tooltip_text('Toggle Video Size')
        toolbar_box.toolbar.insert(video_toggle_button, 1)
        video_toggle_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()
        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()
开发者ID:HFOSS-OVC,项目名称:Open-Video-chat,代码行数:26,代码来源:activity.py

示例2: PhysicsActivity

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]

#.........这里部分代码省略.........

        load_project = ToolButton('load-project')
        load_project.set_tooltip(_('Load project from journal'))
        load_project.connect('clicked', self._load_project)
        activity_button.props.page.insert(load_project, -1)
        load_project.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show_all()
        create_toolbar.set_expanded(True)
        return toolbar_box

    def can_close(self):
        self.preview = self.get_preview()
        self.game.loop = False
        return True

    def _insert_stop_play_button(self, toolbar):

        self.stop_play_toolbar = ToolbarButton()
        st_toolbar = self.stop_play_toolbar
        st_toolbar.props.page = Gtk.Toolbar()
        st_toolbar.props.icon_name = 'media-playback-stop'

        self.stop_play_state = True
        self.stop_play = ToolButton('media-playback-stop')
        self.stop_play.set_tooltip(_('Stop'))
        self.stop_play.set_accelerator(_('<ctrl>space'))
        self.stop_play.connect('clicked', self.stop_play_cb)
        self._insert_item(st_toolbar, self.stop_play)
        self.stop_play.show()

        slowest_button = RadioToolButton(group=None)
        slowest_button.set_icon_name('slow-walk-milton-raposo')
        slowest_button.set_tooltip(_('Run slower'))
        slowest_button.connect('clicked', self._set_fps_cb, SLOWEST_FPS)
        self._insert_item(st_toolbar, slowest_button)
        slowest_button.show()

        slow_button = RadioToolButton(group=slowest_button)
        slow_button.set_icon_name('walking')
        slow_button.set_tooltip(_('Run slow'))
        slow_button.connect('clicked', self._set_fps_cb, SLOW_FPS)
        self._insert_item(st_toolbar, slow_button)
        slow_button.show()

        fast_button = RadioToolButton(group=slowest_button)
        fast_button.set_icon_name('running')
        fast_button.set_tooltip('Run fast')
        fast_button.connect('clicked', self._set_fps_cb, FAST_FPS)
        self._insert_item(st_toolbar, fast_button)
        fast_button.show()
        fast_button.set_active(True)

        toolbar.insert(self.stop_play_toolbar, -1)
        self.stop_play_toolbar.show_all()

    def _set_fps_cb(self, button, value):
        self.game.set_game_fps(value)

    def _insert_clear_all_button(self, toolbar):
        self.clear_all = ToolButton('clear_all')
        self.clear_all.set_tooltip(_('Erase All'))
        self.clear_all.set_accelerator(_('<ctrl>a'))
        self.clear_all.connect('clicked', self.clear_all_cb)
        toolbar.insert(self.clear_all, -1)
开发者ID:godiard,项目名称:physics,代码行数:70,代码来源:activity.py

示例3: __init__

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [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()

#.........这里部分代码省略.........
开发者ID:quozl,项目名称:fototoon-activity,代码行数:103,代码来源:historietaactivity.py

示例4: SideToolbar

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]

#.........这里部分代码省略.........
        self.box1.pack_start(self._invert, False, True, 0)
        self.box1.pack_start(self.button_up, False, True, 0)
        self.box1.pack_start(self.yscrollbar, True, True, 0)
        self.box1.pack_start(self.button_down, False, True, 0)

        self.set_show_hide(False)

    def _yscrollbar_cb(self, adjy, data=None):
        ''' Callback for scrollbar '''
        if self.mode == 'sound':
            self.activity.wave.set_mag_params(1.0, adjy.get_value(),
                                              channel=self._channel)
            self.activity.wave.set_bias_param(0,
                                              channel=self._channel)
        elif self.mode == 'sensor':
            self.activity.wave.set_bias_param(int(
                300 * (adjy.get_value() - (UPPER - LOWER) / 2.)),
                channel=self._channel)
        self.mode_values[self.mode] = adjy.get_value()
        return True

    def _button_up_cb(self, data=None):
        '''Moves slider up'''
        new_value = self.yscrollbar.get_value() + (UPPER - LOWER) \
            / 100.
        if new_value <= UPPER:
            self.yscrollbar.set_value(new_value)
        else:
            self.yscrollbar.set_value(UPPER)
        return True

    def _button_down_cb(self, data=None):
        '''Moves slider down'''
        new_value = self.yscrollbar.get_value() - (UPPER - LOWER) \
            / 100.
        if new_value >= LOWER:
            self.yscrollbar.set_value(new_value)
        else:
            self.yscrollbar.set_value(LOWER)
        return True

    def set_show_hide(self, show=True, mode='sound'):
        ''' Show or hide the toolbar '''
        self.show_toolbar = show
        self.set_side_mode(mode)

    def set_side_mode(self, mode='sound'):
        ''' Set the toolbar to either 'sound' or 'sensor' '''
        self.mode = mode
        if self.mode == 'sound':
            self.button_up.set_icon_name('amp-high')
            self.button_up.set_tooltip(_('Increase amplitude'))
            self.button_down.set_icon_name('amp-low')
            self.button_down.set_tooltip(_('Decrease amplitude'))
        elif self.mode == 'sensor':
            self.button_up.set_icon_name('bias-high')
            self.button_up.set_tooltip(_('Increase bias'))
            self.button_down.set_icon_name('bias-low')
            self.button_down.set_tooltip(_('Decrease bias'))
            self._invert.show()
        self.yscrollbar.set_value(self.mode_values[self.mode])
        return

    def toggle_cb(self, data=None):
        self.activity.wave.set_visibility(self._toggle.get_active(),
                                          channel=self._channel)
        return True

    def invert_control_cb(self, data=None):
        ''' Callback for Invert Button '''
        if self.activity.wave.get_invert_state(channel=self._channel):
            self.activity.wave.set_invert_state(False, self._channel)
            self._invert.set_icon_name('invert')
            self._invert.show()
        elif not self.activity.wave.get_fft_mode():
            self.activity.wave.set_invert_state(True, self._channel)
            self._invert.set_icon_name('invert2')
            self._invert.show()
        self.activity.sensor_toolbar.update_string_for_textbox()
        return False

    def _color_wave(self, color):
        ''' Generate a wave graphic in color to label each side toolbar '''
        svg = '<?xml version="1.0" ?>\n\
<!DOCTYPE svg  PUBLIC "-//W3C//DTD SVG 1.1//EN"\n\
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n\
<svg enable-background="new 0 0 55.125 55" height="55px" version="1.1"\n\
viewBox="0 0 55.125 55" width="55.125px" x="0px" xml:space="preserve"\n\
xmlns="http://www.w3.org/2000/svg"\n\
xmlns:xlink="http://www.w3.org/1999/xlink" y="0px">\n\
<path d="M9.066,27.5 c2.32-6.917,4.666-13.834,9.255-13.834\n\
c9.179,0,9.179,27.668,18.358,27.668c4.59,0,6.986-6.917,9.332-13.834"\n\
fill="none" stroke="%s" stroke-linecap="round" stroke-width="3.5"/>\n\
</svg>' % (color)
        pixbuf = svg_str_to_pixbuf(svg)
        img = Gtk.Image()
        img.set_from_pixbuf(pixbuf)
        img_tool = Gtk.ToolItem()
        img_tool.add(img)
        return img_tool
开发者ID:sugarlabs,项目名称:Measure,代码行数:104,代码来源:toolbar_side.py

示例5: DevelopViewToolbar

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]
class DevelopViewToolbar(Gtk.Toolbar):
    __gsignals__ = {
        'theme-changed': (GObject.SIGNAL_RUN_FIRST, None,
                         (str,)),
        'font-size-changed': (GObject.SIGNAL_RUN_FIRST, None,
                             (int,)),
    }

    def __init__(self, _activity):
        GObject.GObject.__init__(self)

        self._activity = _activity
        self.theme_state = "light"
        self.font_size = DEFAULT_FONT_SIZE

        self.theme_toggler = ToolButton('dark-theme')
        self.theme_toggler.connect('clicked', self._toggled_theme)
        self.theme_toggler.set_tooltip('Switch to Dark Theme')
        self.insert(self.theme_toggler, -1)
        self.theme_toggler.show()

        sep = Gtk.SeparatorToolItem()
        self.insert(sep, -1)
        sep.show()

        self.font_plus = ToolButton('zoom-in')
        self.font_plus.connect('clicked', self._font_size_increase)
        self.font_plus.set_tooltip('Zoom out')
        self.insert(self.font_plus, -1)
        self.font_plus.show()

        self.font_minus = ToolButton('zoom-out')
        self.font_minus.connect('clicked', self._font_size_decrease)
        self.font_minus.set_tooltip('Zoom in')
        self.insert(self.font_minus, -1)
        self.font_minus.show()

        self.show()

    def set_theme(self, theme_name):
        self.theme_state = theme_name

        if self.theme_state == "light":
            self.theme_toggler.set_icon_name('dark-theme')
            self.theme_toggler.set_tooltip('Switch to Dark Theme')
        elif self.theme_state == "dark":
            self.theme_toggler.set_icon_name('light-theme')
            self.theme_toggler.set_tooltip('Switch to Light Theme')

        self.emit('theme-changed', self.theme_state)

    def set_font_size(self, font_size):
        self.font_size = font_size
        self.emit('font-size-changed', self.font_size)

    def _font_size_increase(self, button):
        self.font_size += FONT_CHANGE_STEP
        self.emit('font-size-changed', self.font_size)

    def _font_size_decrease(self, button):
        self.font_size -= FONT_CHANGE_STEP
        self.emit('font-size-changed', self.font_size)

    def _toggled_theme(self, button):
        if self.theme_state == "dark":
            self.theme_state = "light"
            self.theme_toggler.set_icon_name('dark-theme')
            self.theme_toggler.set_tooltip('Switch to Dark Theme')
        elif self.theme_state == "light":
            self.theme_state = "dark"
            self.theme_toggler.set_icon_name('light-theme')
            self.theme_toggler.set_tooltip('Switch to Light Theme')

        self.emit('theme-changed', self.theme_state)
开发者ID:samdroid-apps,项目名称:develop-activity,代码行数:76,代码来源:toolbars.py

示例6: FavoritePage

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]
class FavoritePage(Gtk.Toolbar):
    def __init__(self, button, toolbar, view_icon, favorite_icon, label):
        Gtk.Toolbar.__init__(self)

        self.toolbar = toolbar
        self.button = button
        self.view_icon = view_icon
        self.favorite_icon = favorite_icon

        self.set_view_icon = ToolButton(view_icon)
        self.set_view_icon.set_tooltip(_('Set toolbar icon'))
        self.set_view_icon.connect('clicked', self.set_icon, False)

        self.set_favorite_icon = ToolButton(favorite_icon)
        self.set_favorite_icon.set_tooltip(_('Set the icon of favorites list'))
        self.set_favorite_icon.connect('clicked', self.set_icon, True)

        entry_toolitem = Gtk.ToolItem()

        self.favorite_name_entry = Gtk.Entry()
        self.favorite_name_entry.set_text(label)
        self.favorite_name_entry.connect("activate", self.edited_view_name)
        entry_toolitem.add(self.favorite_name_entry)

        self.remove_btn = ToolButton('list-remove')
        self.remove_btn.set_tooltip(_('Remove favorite view'))
        self.remove_btn.connect('clicked', self.remove_view)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)

        self.insert(self.set_view_icon, -1)
        self.insert(self.set_favorite_icon, -1)
        if self.toolbar.favorite_names_enabled:
            self.insert(entry_toolitem, -1)
        self.insert(separator, -1)
        self.insert(self.remove_btn, -1)
        self.show_all()

    def set_icon(self, widget, favorite=False, window=None):
        if not window:
            dialog = IconDialog()
            dialog.show_all()
            dialog.connect('destroy', self.set_icon, favorite, dialog)

        if window:
            response = window.get_icon()
            if not response:
                return
            if favorite:
                self.set_favorite_icon.set_icon_name(response)
                self.toolbar._favorite_icons[self.button] = response
            else:
                self.set_view_icon.set_icon_name(response)
                self.toolbar._view_icons[self.button] = response
                self.button.set_icon_name(response)

            self.toolbar.save_to_gconf(True)

    def remove_view(self, widget):
        self.button.set_expanded(False)
        self.toolbar.remove_item(self.button)

    def edited_view_name(self, entry):
        label = entry.get_text()
        self.toolbar._favorite_names[self.button] = label

        self.toolbar.save_to_gconf(False, True)
开发者ID:svineet,项目名称:manage-homeviews,代码行数:71,代码来源:homeviews.py

示例7: TuningToolbar

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]

#.........这里部分代码省略.........
            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
        else:
            self._load_tuning_line()

    def _load_tuning_line(self):
        ''' Read the freq entry and use value to set tuning line '''
        freq = self._freq_entry.get_text()
        try:
            self.activity.wave.tuning_line = float(freq)
            if freq < 0:
                freq = -freq
            self._new_tuning_line.set_icon_name('tuning-tools-off')
            self._new_tuning_line.set_tooltip(_('Hide tuning line.'))
            self._show_tuning_line = True
        except ValueError:
            self.activity.wave.tuning_line = 0.0
            self._freq_entry.set_text('0')
        # If we are not already in freq. base, switch.
开发者ID:sugarlabs,项目名称:Measure,代码行数:70,代码来源:tuning_toolbar.py

示例8: FavoritePage

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]
class FavoritePage(Gtk.Toolbar):

    def __init__(self, button, toolbar, view_icon, favorite_icon, label):
        Gtk.Toolbar.__init__(self)

        self.toolbar = toolbar
        self.button = button
        self.view_icon = view_icon
        self.favorite_icon = favorite_icon

        self.set_view_icon = ToolButton(view_icon)
        self.set_view_icon.set_tooltip(_('Set toolbar icon'))
        self.set_view_icon.connect('clicked', self.set_icon, False)

        self.set_favorite_icon = ToolButton(favorite_icon)
        self.set_favorite_icon.set_tooltip(_('Set the icon of favorites list'))
        self.set_favorite_icon.connect('clicked', self.set_icon, True)

        entry_toolitem = Gtk.ToolItem()

        self.favorite_name_entry = Gtk.Entry()
        self.favorite_name_entry.set_placeholder_text(_('Favorite view name'))
        width = Gdk.Screen.width() - (style.STANDARD_ICON_SIZE * 12)
        entry_toolitem.set_size_request(width, 55)
        self.favorite_name_entry.set_text(label)
        self.favorite_name_entry.connect("activate", self.edited_view_name)
        entry_toolitem.add(self.favorite_name_entry)

        label = Gtk.Label(_('Name of favorite view') + '\t')
        label.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse('white'))
        tool_label = Gtk.ToolItem()
        tool_label.add(label)

        self.remove_btn = ToolButton('list-remove')
        self.remove_btn.set_tooltip(_('Remove favorite view'))
        self.remove_btn.connect('clicked', self.remove_view)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)

        self.insert(self.set_view_icon, -1)
        self.insert(self.set_favorite_icon, -1)
        self.insert(tool_label, -1)
        self.insert(entry_toolitem, -1)
        self.insert(separator, -1)
        self.insert(self.remove_btn, -1)
        self.show_all()

    def set_icon(self, widget, favorite=False, window=None):
        if not window:
            dialog = IconDialog()
            dialog.show_all()
            dialog.connect('destroy', self.set_icon, favorite, dialog)

        if window:
            response = window.get_icon()
            if not response:
                return
            if favorite:
                self.set_favorite_icon.set_icon_name(response)
                self.toolbar._favorite_icons[self.button] = response
            else:
                self.set_view_icon.set_icon_name(response)
                self.toolbar._view_icons[self.button] = response
                self.button.set_icon_name(response)

            self.toolbar.save_to_gsettings(True)

    def remove_view(self, widget):
        self.button.set_expanded(False)
        self.toolbar.remove_item(self.button)

    def edited_view_name(self, entry):
        label = entry.get_text()
        self.toolbar._favorite_names[self.button] = label

        self.toolbar.save_to_gsettings(False, True)
开发者ID:i5o,项目名称:manage-homeviews,代码行数:80,代码来源:homeviews.py

示例9: __init__

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [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)

#.........这里部分代码省略.........
开发者ID:samdroid-apps,项目名称:fototoon-activity,代码行数:103,代码来源:historietaactivity.py

示例10: ErikosActivity

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]
class ErikosActivity(activity.Activity):

    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.max_participants = 1

        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(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_name("speaker-muted-000")
            self.sound.set_tooltip(_('Unmute'))
            self.sw.sound = False
        else:
            self.sound.set_icon_name("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
开发者ID:sugarlabs,项目名称:activity-erikos,代码行数:99,代码来源:ErikosActivity.py

示例11: TrainingActivity

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]

#.........这里部分代码省略.........
        self._toolbox.toolbar.insert(toolitem, -1)
        toolitem.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self._toolbox.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        self._toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()

    def _build_progress_toolbar(self):
        self._progress_buttons = []
        progress = self._task_master.get_completed_sections()

        for section_index in range(self._task_master.get_number_of_sections()):
            icon = self._task_master.get_section_icon(section_index)
            if section_index in progress:
                icon = icon + '-white'
            else:
                icon = icon + '-grey'

            name = self._task_master.get_section_name(section_index)

            if section_index == 0:
                group = None
            else:
                group = self._progress_buttons[0]

            self._progress_buttons.append(RadioToolButton(group=group))
            self._progress_buttons[-1].set_icon_name(icon)
            self._progress_buttons[-1].set_tooltip(name)
            self._progress_toolbar.insert(self._progress_buttons[-1], -1)
            self._progress_buttons[-1].show()
            self._progress_buttons[-1].connect(
                'clicked', self._jump_to_section_cb, section_index)

        self._radio_buttons_live = False
        section_index, task_index = \
            self._task_master.get_section_and_task_index()
        self._progress_buttons[section_index].set_active(True)
        self._radio_buttons_live = True

    def _check_connected_task_status(self):
        ''' We only want to turn on notifications if we expect connectivity '''
        task = self._task_master.uid_to_task(GET_CONNECTED_TASK)
        self.set_notify_transfer_status(task.is_completed())

    def _update_completed_sections(self):
        progress = self._task_master.get_completed_sections()

        for section in range(self._task_master.get_number_of_sections()):
            icon = self._task_master.get_section_icon(section)
            if section in progress:
                icon = icon + '-white'
            else:
                icon = icon + '-grey'
            self._progress_buttons[section].set_icon_name(icon)

        self._radio_buttons_live = False
        section_index, task_index = \
            self._task_master.get_section_and_task_index()
        self._progress_buttons[section_index].set_active(True)
开发者ID:nirajnakrani,项目名称:training,代码行数:70,代码来源:activity.py

示例12: PhysicsActivity

# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_icon_name [as 别名]

#.........这里部分代码省略.........
        color = widget.get_color()
        red = (color.red / 65535.0) * 255
        green = (color.green / 65535.0) * 255
        blue = (color.blue / 65535.0) * 255
        objectColor = ((red), (green), (blue))
        self.randomColor.set_active(False)

        self.game.world.add.setColor(objectColor)

    def resetColors(self, button):
        self.game.world.add.resetColor()

    def can_close(self):
        self.preview = self.get_preview()
        self.game.loop = False
        return True

    def _insert_stop_play_button(self, toolbar):

        self.stop_play_toolbar = ToolbarButton()
        st_toolbar = self.stop_play_toolbar
        st_toolbar.props.page = Gtk.Toolbar()
        st_toolbar.props.icon_name = "media-playback-stop"

        self.stop_play_state = True
        self.stop_play = ToolButton("media-playback-stop")
        self.stop_play.set_tooltip(_("Stop"))
        self.stop_play.set_accelerator(_("<ctrl>space"))
        self.stop_play.connect("clicked", self.stop_play_cb)
        self._insert_item(st_toolbar, self.stop_play)
        self.stop_play.show()

        slowest_button = RadioToolButton(group=None)
        slowest_button.set_icon_name("slow-walk-milton-raposo")
        slowest_button.set_tooltip(_("Run slower"))
        slowest_button.connect("clicked", self._set_fps_cb, SLOWEST_FPS)
        self._insert_item(st_toolbar, slowest_button)
        slowest_button.show()

        slow_button = RadioToolButton(group=slowest_button)
        slow_button.set_icon_name("walking")
        slow_button.set_tooltip(_("Run slow"))
        slow_button.connect("clicked", self._set_fps_cb, SLOW_FPS)
        self._insert_item(st_toolbar, slow_button)
        slow_button.show()

        fast_button = RadioToolButton(group=slowest_button)
        fast_button.set_icon_name("running")
        fast_button.set_tooltip("Run fast")
        fast_button.connect("clicked", self._set_fps_cb, FAST_FPS)
        self._insert_item(st_toolbar, fast_button)
        fast_button.show()
        fast_button.set_active(True)

        toolbar.insert(self.stop_play_toolbar, -1)
        self.stop_play_toolbar.show_all()

    def _set_fps_cb(self, button, value):
        self.game.set_game_fps(value)

    def _insert_clear_all_button(self, toolbar):
        self.clear_all = ToolButton("clear_all")
        self.clear_all.set_tooltip(_("Erase All"))
        self.clear_all.set_accelerator(_("<ctrl>a"))
        self.clear_all.connect("clicked", self.clear_all_cb)
        toolbar.insert(self.clear_all, -1)
开发者ID:sugarlabs,项目名称:physics,代码行数:70,代码来源:activity.py


注:本文中的sugar3.graphics.toolbutton.ToolButton.set_icon_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。