本文整理汇总了Python中sugar.graphics.radiotoolbutton.RadioToolButton.set_accelerator方法的典型用法代码示例。如果您正苦于以下问题:Python RadioToolButton.set_accelerator方法的具体用法?Python RadioToolButton.set_accelerator怎么用?Python RadioToolButton.set_accelerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar.graphics.radiotoolbutton.RadioToolButton
的用法示例。
在下文中一共展示了RadioToolButton.set_accelerator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_accelerator [as 别名]
def __init__(self, parent):
gtk.Toolbar.__init__(self)
self._parent = parent
text_mode_btn = RadioToolButton(named_icon='text-mode')
text_mode_btn.set_tooltip(_('Text mode'))
text_mode_btn.set_accelerator(_('<ctrl>t'))
text_mode_btn.set_group(None)
text_mode_btn.connect('clicked', self._parent.mode_cb,
MMapArea.MODE_TEXT)
self._parent.btn_group = text_mode_btn
self.insert(text_mode_btn, -1)
image_mode_btn = RadioToolButton(named_icon='image-mode')
image_mode_btn.set_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(named_icon='draw-mode')
draw_mode_btn.set_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(named_icon='label-mode')
label_mode_btn.set_tooltip(_('Label mode'))
label_mode_btn.set_accelerator(_('<ctrl>a'))
label_mode_btn.set_group(text_mode_btn)
label_mode_btn.connect('clicked', self._parent.mode_cb,
MMapArea.MODE_LABEL)
self.insert(label_mode_btn, -1)
self.show_all()
示例2: ActionButtons
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_accelerator [as 别名]
class ActionButtons():
''' This class manages the action buttons that move among toolsbars '''
def __init__(self, parent):
self._main_toolbar = parent.get_toolbar_box().toolbar
self._main_area = parent._main_area
self._erase_button = parent.edit_toolbar.erase_button
self._sw = parent._sw
if HASTOOLBARBOX:
target_toolbar = self._main_toolbar
else:
target_toolbar = self.parent.edit_toolbar
self._mods = RadioToolButton(named_icon='select-mode')
self._mods.set_tooltip(_('Select thoughts'))
self._mods.set_group(parent.btn_group)
self._mods.set_accelerator(_('<ctrl>e'))
self._mods.connect('clicked', parent.mode_cb, MMapArea.MODE_NULL)
target_toolbar.insert(self._mods, -1)
self._link_button = RadioToolButton(named_icon='link')
self._link_button.set_tooltip(_('Link/unlink two selected thoughts'))
self._link_button.set_group(parent.btn_group)
self._link_button.set_accelerator(_('<ctrl>l'))
self._link_button.connect('clicked', self.__link_cb)
target_toolbar.insert(self._link_button, -1)
self.move_button = RadioToolButton(named_icon='move')
self.move_button.set_tooltip(_('Move selected thoughs'))
self.move_button.set_group(parent.btn_group)
self.move_button.set_accelerator(_('<ctrl>m'))
self.move_button.connect('clicked', self.__move_cb)
target_toolbar.insert(self.move_button, -1)
self.drag_button = RadioToolButton(named_icon='drag')
self.drag_button.set_tooltip(_('Scroll the screen'))
self.drag_button.set_group(parent.btn_group)
self.drag_button.connect('clicked', self.__drag_cb)
target_toolbar.insert(self.drag_button, -1)
if HASTOOLBARBOX:
self._separator_2 = gtk.SeparatorToolItem()
self._separator_2.props.draw = False
# self._separator_2.set_size_request(0, -1)
self._separator_2.set_expand(True)
self._separator_2.show()
target_toolbar.insert(self._separator_2, -1)
self._stop_button = StopButton(parent)
target_toolbar.insert(self._stop_button, -1)
def stop_dragging(self):
if self._main_area.is_dragging():
self._main_area.drag_menu_cb(self._sw, False)
def _stop_moving(self):
self._main_area.move_mode = False
def __link_cb(self, widget):
self._stop_moving()
self.stop_dragging()
self._main_area.link_menu_cb()
def __move_cb(self, widget):
self.stop_dragging()
if self._main_area.move_mode:
self._main_area.stop_moving()
else:
self._main_area.start_moving(self.move_button)
self._erase_button.set_sensitive(False)
def __drag_cb(self, widget):
# If we were moving, stop
self._stop_moving()
if not self._main_area.is_dragging():
self._main_area.drag_menu_cb(self._sw, True)
else:
self.stop_dragging()
self._erase_button.set_sensitive(False)
def reconfigure(self):
''' If screen width has changed, we may need to reconfigure
the toolbars '''
if not HASTOOLBARBOX:
return
if hasattr(self, '_separator_2'):
if gtk.gdk.screen_width() / 13 > style.GRID_CELL_SIZE:
if self._separator_2.get_parent() is None:
self._main_toolbar.remove(self._stop_button)
self._main_toolbar.insert(self._separator_2, -1)
self._main_toolbar.insert(self._stop_button, -1)
else:
self._main_toolbar.remove(self._separator_2)