本文整理汇总了Python中sugar3.graphics.radiotoolbutton.RadioToolButton.set_icon_name方法的典型用法代码示例。如果您正苦于以下问题:Python RadioToolButton.set_icon_name方法的具体用法?Python RadioToolButton.set_icon_name怎么用?Python RadioToolButton.set_icon_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.radiotoolbutton.RadioToolButton
的用法示例。
在下文中一共展示了RadioToolButton.set_icon_name方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def __init__(self, owner):
GObject.GObject.__init__(self)
self.owner = owner
self._insert_separator(True)
self.desktop = []
btn = RadioToolButton(group=None)
btn.set_icon_name('jam-preset1')
btn.connect('toggled', self.setDesktop, 0)
btn.set_tooltip(_('Desktop 1'))
self.insert(btn, -1)
self.desktop.append(btn)
for i in range(2, 11):
btn = RadioToolButton(group=self.desktop[0])
btn.set_icon_name('jam-preset%d' % i)
btn.connect('toggled', self.setDesktop, i - 1)
btn.set_tooltip(_('Desktop %d' % i))
self.insert(btn, -1)
self.desktop.append(btn)
self._insert_separator(True)
self.show_all()
示例2: _build_palette
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def _build_palette(self, tool):
if tool.palette_enabled:
if tool.palette_mode == tools.PALETTE_MODE_ICONS:
grid = Gtk.Grid()
for s, settings in enumerate(tool.palette_settings):
self.game.toolList[tool.name].buttons.append([])
for i, icon_value in enumerate(settings['icon_values']):
if i == 0:
button = RadioToolButton(group=None)
firstbutton = button
else:
button = RadioToolButton(group=firstbutton)
button.set_icon_name(settings['icons'][i])
button.connect('clicked',
self._palette_icon_clicked,
tool.name,
s,
settings['name'],
icon_value)
grid.attach(button, i, s, 1, 1)
self.game.toolList[tool.name].buttons[s].append(button)
button.show()
if settings['active'] == settings['icons'][i]:
button.set_icon_name(settings['icons'][i] +
'-selected')
button.set_active(True)
return grid
else:
return None
示例3: radio_factory
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def radio_factory(icon_name, toolbar, callback, cb_arg=None,
tooltip=None, group=None):
''' Add a radio button to a toolbar '''
button = RadioToolButton(group=group)
button.set_icon_name(icon_name)
if tooltip is not None:
button.set_tooltip(tooltip)
if cb_arg is None:
button.connect('clicked', callback)
else:
button.connect('clicked', callback, cb_arg)
if hasattr(toolbar, 'insert'): # the main toolbar
toolbar.insert(button, -1)
else: # or a secondary toolbar
toolbar.props.page.insert(button, -1)
button.show()
return button
示例4: radio_factory
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def radio_factory(button_name, toolbar, callback, cb_arg=None, tooltip=None, group=None):
""" Add a radio button to a toolbar """
button = RadioToolButton(group=group)
button.set_icon_name(button_name)
if callback is not None:
if cb_arg is None:
button.connect("clicked", callback)
else:
button.connect("clicked", callback, cb_arg)
if hasattr(toolbar, "insert"): # Add button to the main toolbar...
toolbar.insert(button, -1)
else: # ...or a secondary toolbar.
toolbar.props.page.insert(button, -1)
button.show()
if tooltip is not None:
button.set_tooltip(tooltip)
return button
示例5: _insert_create_tools
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def _insert_create_tools(self, create_toolbar):
# Make + add the component buttons
self.radioList = {}
for i, c in enumerate(tools.allTools):
if i == 0:
button = RadioToolButton(group=None)
firstbutton = button
else:
button = RadioToolButton(group=firstbutton)
button.set_icon_name(c.icon)
button.set_tooltip(c.toolTip)
button.set_accelerator(c.toolAccelerator)
button.connect("clicked", self.radioClicked)
palette = self._build_palette(c)
if palette is not None:
palette.show()
button.get_palette().set_content(palette)
self._insert_item(create_toolbar, button, -1)
button.show()
self.radioList[button] = c.name
if hasattr(c, "constructor"):
self._constructors[c.name] = self.game.toolList[c.name].constructor
示例6: _load_standard_buttons
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def _load_standard_buttons(self, toolbar):
fraction_button = RadioToolButton(group=None)
fraction_button.set_icon_name('fraction')
fraction_button.set_tooltip(_('fractions'))
fraction_button.connect('clicked', self._fraction_cb)
toolbar.insert(fraction_button, -1)
fraction_button.show()
sector_button = RadioToolButton(group=fraction_button)
sector_button.set_icon_name('sector')
sector_button.set_tooltip(_('sectors'))
sector_button.connect('clicked', self._sector_cb)
toolbar.insert(sector_button, -1)
sector_button.show()
percent_button = RadioToolButton(group=fraction_button)
percent_button.set_icon_name('percent')
percent_button.set_tooltip(_('percents'))
percent_button.connect('clicked', self._percent_cb)
toolbar.insert(percent_button, -1)
percent_button.show()
self._player = Gtk.Image()
self._player.set_from_pixbuf(svg_str_to_pixbuf(
generate_xo_svg(scale=0.8, colors=['#282828', '#282828'])))
self._player.set_tooltip_text(self.nick)
toolitem = Gtk.ToolItem()
toolitem.add(self._player)
self._player.show()
toolbar.insert(toolitem, -1)
toolitem.show()
self._label = Gtk.Label(_("Click the ball to start."))
self._label.set_line_wrap(True)
if Gdk.Screen.width() < 1024:
self._label.set_size_request(275, -1)
else:
self._label.set_size_request(500, -1)
self.toolitem = Gtk.ToolItem()
self.toolitem.add(self._label)
self._label.show()
toolbar.insert(self.toolitem, -1)
self.toolitem.show()
示例7: _insert_stop_play_button
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
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()
示例8: create_palette
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def create_palette(self):
self._palette = self.get_child().create_palette()
color_palette_hbox = self._palette._picker_hbox
self.custom_box = Gtk.VBox()
self.vbox_brush_options = Gtk.VBox()
# This is where we set restrictions for size:
# Initial value, minimum value, maximum value, step
adj = Gtk.Adjustment(self.properties['line size'], 1.0, 100.0, 1.0)
self.size_scale = Gtk.HScale()
self.size_scale.set_adjustment(adj)
self.size_scale.set_draw_value(False)
self.size_scale.set_size_request(style.zoom(200), -1)
self.size_label = Gtk.Label(label=_('Size'))
self.size_label.props.halign = Gtk.Align.START
self.vbox_brush_options.pack_start(self.size_label, True, True, 0)
self.vbox_brush_options.pack_start(self.size_scale, True, True, 0)
self.size_scale.connect('value-changed', self._on_value_changed)
# Control alpha
alpha = self.properties['alpha'] * 100
adj_alpha = Gtk.Adjustment(alpha, 10.0, 100.0, 1.0)
self.alpha_scale = Gtk.HScale()
self.alpha_scale.set_adjustment(adj_alpha)
self.alpha_scale.set_draw_value(False)
self.alpha_scale.set_size_request(style.zoom(200), -1)
self.alpha_label = Gtk.Label(label=_('Opacity'))
self.alpha_label.props.halign = Gtk.Align.START
self.vbox_brush_options.pack_start(self.alpha_label, True, True, 0)
self.vbox_brush_options.pack_start(self.alpha_scale, True, True, 0)
self.alpha_scale.connect('value-changed', self._on_alpha_changed)
# User is able to choose Shapes for 'Brush' and 'Eraser'
self.shape_box = Gtk.HBox()
self.custom_box.pack_start(self.vbox_brush_options, True, True, 0)
item1 = RadioToolButton()
item1.set_icon_name('tool-shape-ellipse')
item2 = RadioToolButton()
item2.set_icon_name('tool-shape-rectangle')
item2.props.group = item1
if self.properties['line shape'] == 'circle':
item1.set_active(True)
else:
item2.set_active(True)
item1.connect('toggled', self._on_toggled, self.properties, 'circle')
item2.connect('toggled', self._on_toggled, self.properties, 'square')
self.shape_box.pack_start(Gtk.Label(_('Shape')), True, True, 0)
self.shape_box.pack_start(item1, True, True, 0)
self.shape_box.pack_start(item2, True, True, 0)
self.vbox_brush_options.pack_start(self.shape_box, True, True, 0)
self.keep_aspect_checkbutton = Gtk.CheckButton(_('Keep aspect'))
ratio = self._activity.area.keep_aspect_ratio
self.keep_aspect_checkbutton.set_active(ratio)
self.keep_aspect_checkbutton.connect(
'toggled', self._keep_aspect_checkbutton_toggled)
self.vbox_brush_options.pack_start(self.keep_aspect_checkbutton, True,
True, 0)
self.custom_separator = Gtk.VSeparator()
color_palette_hbox.pack_start(self.custom_separator, True, True,
padding=style.DEFAULT_SPACING)
color_palette_hbox.pack_start(self.custom_box, True, True,
padding=style.DEFAULT_SPACING)
color_palette_hbox.show_all()
self._update_palette()
return self._palette
示例9: HelpPanel
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
class HelpPanel(Gtk.Grid):
def __init__(self, task_master):
Gtk.Grid.__init__(self)
self.set_row_spacing(style.DEFAULT_SPACING)
self.set_column_spacing(style.DEFAULT_SPACING)
self.set_column_homogeneous(True)
self.set_border_width(style.DEFAULT_SPACING)
self._task_master = task_master
self._connected = False
self._mode = _FEEDBACK_TICKET
alignment = Gtk.Alignment.new(0., 0.5, 0., 0.)
phone_label = Gtk.Label()
phone_label.set_use_markup(True)
phone_label.set_justify(Gtk.Justification.LEFT)
phone_label.set_markup(
'<span foreground="%s" size="large">%s</span>' %
(style.COLOR_WHITE.get_html(), _('Call: 1-800 ONE EDU\n'
'Email: [email protected]')))
alignment.add(phone_label)
phone_label.show()
self.attach(alignment, 0, 0, 4, 1)
alignment.show()
alignment = Gtk.Alignment.new(0., 0.5, 0., 0.)
self._info_label = Gtk.Label()
self._info_label.set_use_markup(True)
self._info_label.set_justify(Gtk.Justification.LEFT)
self._info_label.set_markup(
'<span foreground="%s" size="large">%s</span>' %
(style.COLOR_WHITE.get_html(), _('Or use the form below:')))
alignment.add(self._info_label)
self._info_label.show()
self.attach(alignment, 0, 4, 4, 1)
alignment.show()
self._email_entry = Gtk.Entry()
email_address = self._task_master.read_task_data(EMAIL_UID)
if email_address is not None:
self._email_entry.set_text(email_address)
else:
self._email_entry.set_text(_EMAIL_TEXT)
self.attach(self._email_entry, 0, 5, 4, 1)
self._email_entry.show()
self._email_entry.connect('changed', self._email_changed_cb)
self._email_entry.set_can_focus(True)
grid = Gtk.Grid()
self._feedback_button = RadioToolButton(group=None)
self._feedback_button.set_icon_name('edit-description')
self._feedback_button.connect('clicked', self._feedback_button_cb)
grid.attach(self._feedback_button, 0, 0, 1, 1)
self._feedback_button.show()
label = Gtk.Label()
label.set_use_markup(True)
label.set_justify(Gtk.Justification.LEFT)
label.set_markup('<span foreground="%s" size="large">%s</span>' %
(style.COLOR_WHITE.get_html(), _('Send feedback')))
grid.attach(label, 1, 0, 1, 1)
label.show()
alignment = Gtk.Alignment.new(0., 0.5, 0., 0.)
alignment.add(grid)
grid.show()
self.attach(alignment, 0, 6, 2, 1)
alignment.show()
grid = Gtk.Grid()
self._help_button = RadioToolButton(group=self._feedback_button)
self._help_button.set_icon_name('toolbar-help-gray')
self._help_button.connect('clicked', self._help_button_cb)
grid.attach(self._help_button, 0, 0, 1, 1)
self._help_button.show()
label = Gtk.Label()
label.set_use_markup(True)
label.set_justify(Gtk.Justification.LEFT)
label.set_markup('<span foreground="%s" size="large">%s</span>' %
(style.COLOR_WHITE.get_html(), _('Ask for help')))
grid.attach(label, 1, 0, 1, 1)
label.show()
alignment = Gtk.Alignment.new(0., 0.5, 0., 0.)
alignment.add(grid)
grid.show()
self.attach(alignment, 2, 6, 2, 1)
alignment.show()
self._feedback_button.set_active(True)
self._text_view = Gtk.TextView()
self._text_view.set_wrap_mode(Gtk.WrapMode.WORD)
self._text_view.set_size_request(-1, style.GRID_CELL_SIZE * 2)
self._text_buffer = self._text_view.get_buffer()
self._text_buffer.set_text(_ACTIVE_TEXT)
self.attach(self._text_view, 0, 7, 4, 4)
self._text_view.show()
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import set_icon_name [as 别名]
def __init__(self, model, alerts=None):
SectionView.__init__(self)
self._model = model
self._images_loaded = False
self._append_to_store_sid = None
self.connect('realize', self.__realize_cb)
self.connect('unrealize', self.__unrealize_cb)
self.set_border_width(style.DEFAULT_SPACING * 2)
self.set_spacing(style.DEFAULT_SPACING)
label_box = Gtk.Box()
label_bg = Gtk.Label(label=_('Select a background:'))
label_bg.modify_fg(Gtk.StateType.NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
label_bg.show()
label_box.pack_start(label_bg, False, True, 0)
label_box.show()
self.pack_start(label_box, False, True, 1)
clear_button = Gtk.Button()
clear_button.set_label(_('Clear background'))
clear_button.connect('clicked', self._clear_clicked_cb)
clear_button.show()
self.pack_end(clear_button, False, True, 0)
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.pack_start(scrolled_window, True, True, 0)
scrolled_window.show()
self._store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
self._icon_view = Gtk.IconView.new_with_model(self._store)
self._icon_view.set_selection_mode(Gtk.SelectionMode.SINGLE)
self._icon_view.connect('selection-changed', self._background_selected)
self._icon_view.set_pixbuf_column(0)
self._icon_view.grab_focus()
scrolled_window.add(self._icon_view)
self._icon_view.show()
alpha = self._model.get_background_alpha_level()
alpha_box = Gtk.HBox()
alpha_buttons = []
alpha_icons = [
[1.0, 'network-wireless-000'],
[0.8, 'network-wireless-020'],
[0.6, 'network-wireless-040'],
[0.4, 'network-wireless-060'],
[0.2, 'network-wireless-080']]
for value, icon_name in alpha_icons:
if len(alpha_buttons) > 0:
button = RadioToolButton(group=alpha_buttons[0])
else:
button = RadioToolButton(group=None)
button.set_icon_name(icon_name)
button.value = value
button.props.active = value == alpha
button.show()
alpha_box.pack_start(button, False, True, 0)
alpha_buttons.append(button)
for button in alpha_buttons:
button.connect('toggled', self._set_alpha_cb)
alpha_alignment = Gtk.Alignment()
alpha_alignment.set(0.5, 0, 0, 0)
alpha_alignment.add(alpha_box)
alpha_box.show()
self.pack_start(alpha_alignment, False, False, 0)
alpha_alignment.show()
self._paths_list = []
file_paths = []
for directory in self._model.BACKGROUNDS_DIRS:
if directory is not None and os.path.exists(directory):
for root, dirs, files in os.walk(directory):
for file_ in files:
file_paths.append(os.path.join(root, file_))
self._append_to_store(file_paths)
self.setup()