本文整理汇总了Python中sugar3.graphics.radiotoolbutton.RadioToolButton.connect方法的典型用法代码示例。如果您正苦于以下问题:Python RadioToolButton.connect方法的具体用法?Python RadioToolButton.connect怎么用?Python RadioToolButton.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.radiotoolbutton.RadioToolButton
的用法示例。
在下文中一共展示了RadioToolButton.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [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 connect [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: __init__
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def __init__(self, activity_name, has_local_help):
Gtk.Toolbar.__init__(self)
self._add_separator(False)
if has_local_help and get_social_help_server():
help_button = RadioToolButton()
icon = Icon(icon_name='toolbar-help',
pixel_size=style.STANDARD_ICON_SIZE,
fill_color=style.COLOR_TRANSPARENT.get_svg(),
stroke_color=style.COLOR_WHITE.get_svg())
help_button.set_icon_widget(icon)
icon.show()
help_button.props.tooltip = _('Help Manual')
help_button.connect('toggled', self.__button_toggled_cb,
_MODE_HELP)
self.insert(help_button, -1)
help_button.show()
self._add_separator(False)
social_help_button = RadioToolButton()
icon = Icon(icon_name='toolbar-social-help',
pixel_size=style.STANDARD_ICON_SIZE,
fill_color=style.COLOR_TRANSPARENT.get_svg(),
stroke_color=style.COLOR_WHITE.get_svg())
social_help_button.set_icon_widget(icon)
icon.show()
social_help_button.props.tooltip = _('Social Help')
social_help_button.props.group = help_button
social_help_button.connect(
'toggled', self.__button_toggled_cb, _MODE_SOCIAL_HELP)
self.insert(social_help_button, -1)
social_help_button.show()
self._add_separator(False)
self._back_button = ToolButton(icon_name='go-previous-paired')
self._back_button.props.tooltip = _('Back')
self._back_button.connect('clicked', self.__back_clicked_cb)
self.insert(self._back_button, -1)
self._back_button.show()
self._forward_button = ToolButton(icon_name='go-next-paired')
self._forward_button.props.tooltip = _('Forward')
self._forward_button.connect('clicked', self.__forward_clicked_cb)
self.insert(self._forward_button, -1)
self._forward_button.show()
title = _('Help: %s') % activity_name
self._label = Gtk.Label()
self._label.set_markup('<b>%s</b>' % title)
self._label.set_alignment(0, 0.5)
self._add_widget(self._label)
self._add_separator(True)
stop = ToolButton(icon_name='dialog-cancel')
stop.set_tooltip(_('Close'))
stop.connect('clicked', self.__stop_clicked_cb)
self.insert(stop, -1)
stop.show()
示例4: instance
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def instance(self):
book.wiki = book.WikiBook()
if not book.custom:
book.custom = book.CustomBook()
self.edit_page = 1
self.edit = edit.View()
self.library = library.View(self)
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
self.set_toolbar_box(toolbar_box)
self._toolbar = toolbar_box.toolbar
tool_group = None
search_button = RadioToolButton()
search_button.props.group = tool_group
tool_group = search_button
search_button.props.icon_name = 'white-search'
search_button.set_tooltip(_('Library'))
search_button.mode = 'search'
search_button.connect('clicked', self.__mode_button_clicked)
self._toolbar.insert(search_button, -1)
edit_button = RadioToolButton()
edit_button.props.group = tool_group
edit_button.props.icon_name = 'toolbar-edit'
edit_button.set_tooltip(_('Edit'))
edit_button.mode = 'edit'
edit_button.connect('clicked', self.__mode_button_clicked)
self._toolbar.insert(edit_button, -1)
self._toolbar.insert(Gtk.SeparatorToolItem(), -1)
self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar)
self.library_bar = library.ToolbarBuilder(self.library,
activity_button)
self.library_bar.publish.show()
edit_fake = Gtk.EventBox()
self.notebook.append_page(self.library, None)
self.notebook.append_page(self.edit, None)
self.notebook.append_page(edit_fake, None)
self.show_all()
self.__mode_button_clicked(search_button)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
separator.show()
self._toolbar.insert(separator, -1)
stop_button = StopButton(self)
stop_button.show()
self._toolbar.insert(stop_button, -1)
示例5: __init__
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def __init__(self, parent):
Gtk.Toolbar.__init__(self)
self._parent = parent
text_mode_btn = RadioToolButton(icon_name='text-mode')
text_mode_btn.set_tooltip(_('Text mode'))
text_mode_btn.set_accelerator(_('<ctrl>t'))
text_mode_btn.connect('clicked', self._parent.mode_cb,
MMapArea.MODE_TEXT)
self.insert(text_mode_btn, -1)
image_mode_btn = RadioToolButton(icon_name='image-mode', group=text_mode_btn)
image_mode_btn.set_tooltip(_('Image add mode'))
image_mode_btn.set_accelerator(_('<ctrl>i'))
image_mode_btn.connect('clicked', self._parent.mode_cb,
MMapArea.MODE_IMAGE)
self.insert(image_mode_btn, -1)
draw_mode_btn = RadioToolButton(icon_name='draw-mode', group=text_mode_btn)
draw_mode_btn.set_tooltip(_('Drawing mode'))
draw_mode_btn.set_accelerator(_('<ctrl>d'))
draw_mode_btn.connect('clicked', self._parent.mode_cb,
MMapArea.MODE_DRAW)
self.insert(draw_mode_btn, -1)
label_mode_btn = RadioToolButton(icon_name='label-mode', group=text_mode_btn)
label_mode_btn.set_tooltip(_('Label mode'))
label_mode_btn.set_accelerator(_('<ctrl>a'))
label_mode_btn.connect('clicked', self._parent.mode_cb,
MMapArea.MODE_LABEL)
self.insert(label_mode_btn, -1)
self.show_all()
示例6: add_level_button
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def add_level_button(icon_name, tooltip, numeric_level):
if self._levels_buttons:
button = RadioToolButton(icon_name=icon_name,
group=self._levels_buttons[0])
else:
button = RadioToolButton(icon_name=icon_name)
self._levels_buttons.append(button)
toolbar.add(button)
def callback(source):
if source.get_active():
self._game.set_level(numeric_level)
self._game.new_game()
button.connect('clicked', callback)
button.set_tooltip(tooltip)
示例7: radio_factory
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [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
示例8: radio_factory
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [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
示例9: _add_button
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def _add_button(self, icon_name, label, accelerator, zoom_level):
if self.get_children():
group = self.get_children()[0]
else:
group = None
button = RadioToolButton(icon_name=icon_name, group=group,
accelerator=accelerator)
button.connect('clicked', self.__level_clicked_cb, zoom_level)
self.add(button)
button.show()
palette = Palette(glib.markup_escape_text(label))
palette.props.invoker = FrameWidgetInvoker(button)
palette.set_group_id('frame')
button.set_palette(palette)
return button
示例10: _add_clock_controls
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def _add_clock_controls(self, display_toolbar):
# First group of radio button to select the type of clock to display
button1 = RadioToolButton(icon_name="simple-clock")
button1.set_tooltip(_('Simple Clock'))
button1.connect("toggled", self._display_mode_changed_cb,
_MODE_SIMPLE_CLOCK)
display_toolbar.insert(button1, -1)
self._display_mode_buttons.append(button1)
button2 = RadioToolButton(icon_name="nice-clock",
group=button1)
button2.set_tooltip(_('Nice Clock'))
button2.connect("toggled", self._display_mode_changed_cb,
_MODE_NICE_CLOCK)
display_toolbar.insert(button2, -1)
self._display_mode_buttons.append(button2)
button3 = RadioToolButton(icon_name="digital-clock",
group=button1)
button3.set_tooltip(_('Digital Clock'))
button3.connect("toggled", self._display_mode_changed_cb,
_MODE_DIGITAL_CLOCK)
display_toolbar.insert(button3, -1)
self._display_mode_buttons.append(button3)
# A separator between the two groups of buttons
separator = Gtk.SeparatorToolItem()
separator.set_draw(True)
display_toolbar.insert(separator, -1)
# Now the options buttons to display other elements: date, day
# of week... A button in the toolbar to write the time in
# full letters
self._write_time_btn = ToggleToolButton("write-time")
self._write_time_btn.set_tooltip(_('Display time in full letters'))
self._write_time_btn.connect("toggled", self._write_time_clicked_cb)
display_toolbar.insert(self._write_time_btn, -1)
# The button to display the weekday and date
self._write_date_btn = ToggleToolButton("write-date")
self._write_date_btn.set_tooltip(_('Display weekday and date'))
self._write_date_btn.connect("toggled", self._write_date_clicked_cb)
display_toolbar.insert(self._write_date_btn, -1)
# Another button to speak aloud the time
self._speak_time_btn = ToggleToolButton("microphone")
self._speak_time_btn.set_tooltip(_('Talking clock'))
self._speak_time_btn.connect("toggled", self._speak_time_clicked_cb)
display_toolbar.insert(self._speak_time_btn, -1)
# A separator between the two groups of buttons
separator = Gtk.SeparatorToolItem()
separator.set_draw(True)
display_toolbar.insert(separator, -1)
# And another button to toggle grabbing the hands
self._grab_button = ToggleToolButton("grab")
self._grab_button.set_tooltip(_('Grab the hands'))
self._grab_button.connect("toggled", self._grab_clicked_cb)
display_toolbar.insert(self._grab_button, -1)
示例11: _insert_create_tools
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [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
示例12: __init__
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def __init__(self, favorite_view):
RadioToolButton.__init__(self)
self.props.tooltip = desktop.get_favorite_names()[favorite_view]
self.props.accelerator = _("<Ctrl>%d" % (favorite_view + 1))
self.props.group = None
self.props.icon_name = desktop.get_view_icons()[favorite_view]
favorites_settings = favoritesview.get_settings(favorite_view)
self._layout = favorites_settings.layout
# someday, this will be a Gtk.Table()
layouts_grid = Gtk.HBox()
layout_item = None
for layoutid, layoutclass in sorted(favoritesview.LAYOUT_MAP.items()):
layout_item = RadioToolButton(icon_name=layoutclass.icon_name, group=layout_item, active=False)
if layoutid == self._layout:
layout_item.set_active(True)
layouts_grid.pack_start(layout_item, True, False, 0)
layout_item.connect("toggled", self.__layout_activate_cb, layoutid, favorite_view)
layouts_grid.show_all()
self.props.palette.set_content(layouts_grid)
示例13: build_toolbox
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def build_toolbox(self):
view_tool_group = None
registerbtn = RadioToolButton()
registerbtn.props.icon_name = 'view-list'
registerbtn.props.label = _('Register')
registerbtn.set_tooltip(_("Register"))
registerbtn.props.group = view_tool_group
view_tool_group = registerbtn
registerbtn.props.accelerator = '<Ctrl>1'
registerbtn.connect('clicked', self.register_cb)
budgetbtn = RadioToolButton()
budgetbtn.props.icon_name = 'budget'
budgetbtn.props.label = _('Budget')
budgetbtn.set_tooltip(_("Budget"))
budgetbtn.props.group = view_tool_group
budgetbtn.props.accelerator = '<Ctrl>2'
budgetbtn.connect('clicked', self.budget_cb)
chartbtn = RadioToolButton()
chartbtn.props.icon_name = 'chart'
chartbtn.props.label = _('Chart')
chartbtn.set_tooltip(_("Chart"))
chartbtn.props.group = view_tool_group
chartbtn.props.accelerator = '<Ctrl>3'
chartbtn.connect('clicked', self.chart_cb)
helpbutton = self._create_help_button()
helpbutton.show_all()
self.toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
self.toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
self.toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
self.toolbar_box.toolbar.insert(registerbtn, -1)
self.toolbar_box.toolbar.insert(budgetbtn, -1)
self.toolbar_box.toolbar.insert(chartbtn, -1)
self.toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
self.toolbar_box.toolbar.insert(helpbutton, -1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
self.toolbar_box.toolbar.insert(separator, -1)
self.toolbar_box.toolbar.insert(StopButton(self), -1)
self.set_toolbar_box(self.toolbar_box)
activity_button.page.insert(self._create_export_button(), -1)
self.toolbar_box.show_all()
示例14: __init__
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def __init__(self):
RadioToolButton.__init__(self)
self.props.tooltip = _('Favorites view')
self.props.accelerator = _('<Ctrl>1')
self.props.group = None
favorites_settings = favoritesview.get_settings()
self._layout = favorites_settings.layout
self._update_icon()
# someday, this will be a Gtk.Table()
layouts_grid = Gtk.HBox()
layout_item = None
for layoutid, layoutclass in sorted(favoritesview.LAYOUT_MAP.items()):
layout_item = RadioToolButton(icon_name=layoutclass.icon_name,
group=layout_item, active=False)
if layoutid == self._layout:
layout_item.set_active(True)
layouts_grid.pack_start(layout_item, True, False, 0)
layout_item.connect('toggled', self.__layout_activate_cb,
layoutid)
layouts_grid.show_all()
self.props.palette.set_content(layouts_grid)
示例15: ShareButton
# 需要导入模块: from sugar3.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar3.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
class ShareButton(RadioMenuButton):
def __init__(self, activity, **kwargs):
palette = RadioPalette()
self.private = RadioToolButton(
icon_name='zoom-home')
palette.append(self.private, _('Private'))
self.neighborhood = RadioToolButton(
icon_name='zoom-neighborhood',
group=self.private)
self._neighborhood_handle = self.neighborhood.connect(
'clicked', self.__neighborhood_clicked_cb, activity)
palette.append(self.neighborhood, _('My Neighborhood'))
activity.connect('shared', self.__update_share_cb)
activity.connect('joined', self.__update_share_cb)
RadioMenuButton.__init__(self, **kwargs)
self.props.palette = palette
if activity.max_participants == 1:
self.props.sensitive = False
def __neighborhood_clicked_cb(self, button, activity):
activity.share()
def __update_share_cb(self, activity):
self.neighborhood.handler_block(self._neighborhood_handle)
try:
if activity.shared_activity is not None and \
not activity.shared_activity.props.private:
self.private.props.sensitive = False
self.neighborhood.props.sensitive = False
self.neighborhood.props.active = True
else:
self.private.props.sensitive = True
self.neighborhood.props.sensitive = True
self.private.props.active = True
finally:
self.neighborhood.handler_unblock(self._neighborhood_handle)