本文整理汇总了Python中sugar3.graphics.toolbutton.ToolButton.set_accelerator方法的典型用法代码示例。如果您正苦于以下问题:Python ToolButton.set_accelerator方法的具体用法?Python ToolButton.set_accelerator怎么用?Python ToolButton.set_accelerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.toolbutton.ToolButton
的用法示例。
在下文中一共展示了ToolButton.set_accelerator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeToolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def makeToolbar(self, activity):
self.activity = activity
toolbar = ToolbarBox()
activity_button = ActivityToolbarButton(activity)
toolbar.toolbar.insert(activity_button, -1)
activity_button.show()
editmode = ToolButton('edit-description')
editmode.set_tooltip(_("Enter Edit Mode"))
editmode.set_accelerator(_('<ctrl>e'))
editmode.connect('clicked', self.gotoCoding)
toolbar.toolbar.insert(editmode, -1)
editmode.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar.toolbar.insert(separator, -1)
separator.show()
stop_button = StopButton(activity)
toolbar.toolbar.insert(stop_button, -1)
stop_button.show()
return toolbar
示例2: build_toolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def build_toolbar(self):
toolbar_box = ToolbarBox()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, -1)
activity_button.show()
# Pause/Play button:
stop_play = ToolButton('media-playback-stop')
stop_play.set_tooltip(_("Stop"))
stop_play.set_accelerator(_('<ctrl>space'))
stop_play.connect('clicked', self._stop_play_cb)
stop_play.show()
toolbar_box.toolbar.insert(stop_play, -1)
# Blank space (separator) and Stop button at the end:
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()
示例3: __init__
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def __init__(self, calc):
Gtk.Toolbar.__init__(self)
copy_tool = ToolButton('edit-copy')
copy_tool.set_tooltip(_('Copy'))
copy_tool.set_accelerator(_('<ctrl>c'))
copy_tool.connect('clicked', lambda x: calc.text_copy())
self.insert(copy_tool, -1)
menu_item = MenuItem(_('Cut'))
try:
menu_item.set_accelerator(_('<ctrl>x'))
except AttributeError:
pass
menu_item.connect('activate', lambda x: calc.text_cut())
menu_item.show()
copy_tool.get_palette().menu.append(menu_item)
self.insert(IconToolButton('edit-paste', _('Paste'),
lambda x: calc.text_paste(),
alt_html='Paste'), -1)
self.show_all()
示例4: ViewToolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
class ViewToolbar(Gtk.Toolbar):
__gtype_name__ = 'ViewToolbar'
__gsignals__ = {
'go-fullscreen': (GObject.SignalFlags.RUN_FIRST,
None,
([])),
'toggle-playlist': (GObject.SignalFlags.RUN_FIRST,
None,
([]))
}
def __init__(self):
Gtk.Toolbar.__init__(self)
self._show_playlist = ToggleToolButton('view-list')
self._show_playlist.set_active(True) # due to Activity.show_all()
self._show_playlist.set_tooltip(_('Playlist'))
self._show_playlist.set_accelerator('<ctrl>l')
self._show_playlist.connect('toggled', self._playlist_toggled_cb)
self.insert(self._show_playlist, -1)
self._show_playlist.show()
self._fullscreen = ToolButton('view-fullscreen')
self._fullscreen.set_tooltip(_('Fullscreen'))
self._fullscreen.set_accelerator('<ctrl>f')
self._fullscreen.connect('clicked', self._fullscreen_cb)
self.insert(self._fullscreen, -1)
self._fullscreen.show()
def _fullscreen_cb(self, button):
self.emit('go-fullscreen')
def _playlist_toggled_cb(self, button):
self.emit('toggle-playlist')
示例5: build_toolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def build_toolbar(self):
# Create the toolbar box
toolbar_box = ToolbarBox()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
# Create the activity button
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, -1)
activity_button.show()
# Create the pause/play button
stop_play = ToolButton('media-playback-stop')
stop_play.set_tooltip(_("Stop"))
stop_play.set_accelerator(_('<ctrl>space'))
stop_play.connect('clicked', self.stop_play_cb)
stop_play.show()
toolbar_box.toolbar.insert(stop_play, -1)
# Create a blank separator and a Stop button
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()
示例6: __init__
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def __init__(self, main_area):
Gtk.Toolbar.__init__(self)
self._main_area = main_area
tool = ToolButton('zoom-best-fit')
tool.set_tooltip(_('Fit to window'))
tool.set_accelerator(_('<ctrl>9'))
tool.connect('clicked', self.__zoom_tofit_cb)
self.insert(tool, -1)
tool = ToolButton('zoom-original')
tool.set_tooltip(_('Original size'))
tool.set_accelerator(_('<ctrl>0'))
tool.connect('clicked', self.__zoom_original_cb)
self.insert(tool, -1)
tool = ToolButton('zoom-out')
tool.set_tooltip(_('Zoom out'))
tool.set_accelerator(_('<ctrl>minus'))
tool.connect('clicked', self.__zoom_out_cb)
self.insert(tool, -1)
tool = ToolButton('zoom-in')
tool.set_tooltip(_('Zoom in'))
tool.set_accelerator(_('<ctrl>equal'))
tool.connect('clicked', self.__zoom_in_cb)
self.insert(tool, -1)
self.show_all()
示例7: ToolbarBox
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
test = common.Test()
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
test.pack_start(box, True, True, 0)
toolbar_box = ToolbarBox()
box.pack_start(toolbar_box, False, False, 0)
separator = Gtk.SeparatorToolItem()
toolbar_box.toolbar.insert(separator, -1)
def __clicked_cb(button):
n = int(button.get_tooltip())
button.set_tooltip(str(n + 1))
print "tool button click count %d" % n
tool_button = ToolButton(icon_name='view-radial', tooltip='0')
tool_button.connect('clicked', __clicked_cb)
tool_button.set_hide_tooltip_on_click(False)
tool_button.set_accelerator('<Space>')
toolbar_box.toolbar.insert(tool_button, -1)
test.show_all()
if __name__ == '__main__':
common.main(test)
示例8: PhysicsActivity
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
class PhysicsActivity(activity.Activity):
def __init__(self, handle):
super(PhysicsActivity, self).__init__(handle)
self.metadata['mime_type'] = 'application/x-physics-activity'
self.add_events(Gdk.EventMask.ALL_EVENTS_MASK |
Gdk.EventMask.VISIBILITY_NOTIFY_MASK)
self.connect('visibility-notify-event', self._focus_event)
self.connect('window-state-event', self._window_event)
self.game_canvas = sugargame.canvas.PygameCanvas(self)
self.game = physics.main(self)
self.preview = None
self._sample_window = None
self._fixed = Gtk.Fixed()
self._fixed.put(self.game_canvas, 0, 0)
w = Gdk.Screen.width()
h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
self.game_canvas.set_size_request(w, h)
self._constructors = {}
self.build_toolbar()
self.set_canvas(self._fixed)
Gdk.Screen.get_default().connect('size-changed',
self.__configure_cb)
logging.debug(os.path.join(
activity.get_activity_root(), 'data', 'data'))
self.game_canvas.run_pygame(self.game.run)
GObject.idle_add(self._setup_sharing)
self.show_all()
def _setup_sharing(self):
self.we_are_sharing = False
if self.shared_activity:
# We're joining
if not self.get_shared():
xocolors = XoColor(profile.get_color().to_string())
share_icon = Icon(icon_name='zoom-neighborhood',
xo_color=xocolors)
self._joined_alert = Alert()
self._joined_alert.props.icon = share_icon
self._joined_alert.props.title = _('Please wait')
self._joined_alert.props.msg = _('Starting connection...')
self.add_alert(self._joined_alert)
self._waiting_cursor()
self._setup_presence_service()
def __configure_cb(self, event):
''' Screen size has changed '''
self.write_file(os.path.join(
activity.get_activity_root(), 'data', 'data'))
w = Gdk.Screen.width()
h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
pygame.display.set_mode((w, h),
pygame.RESIZABLE)
self.read_file(os.path.join(
activity.get_activity_root(), 'data', 'data'))
self.game.run(True)
def read_file(self, file_path):
self.game.read_file(file_path)
def write_file(self, file_path):
self.game.write_file(file_path)
def get_preview(self):
''' Custom preview code to get image from pygame. '''
return self.game_canvas.get_preview()
def build_toolbar(self):
self.max_participants = 4
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
create_toolbar = ToolbarButton()
create_toolbar.props.page = Gtk.Toolbar()
create_toolbar.props.icon_name = 'magicpen'
create_toolbar.props.label = _('Create')
toolbar_box.toolbar.insert(create_toolbar, -1)
self._insert_create_tools(create_toolbar)
self._insert_stop_play_button(toolbar_box.toolbar)
clear_trace = ToolButton('clear-trace')
clear_trace.set_tooltip(_('Clear Trace Marks'))
clear_trace.set_accelerator(_('<ctrl>x'))
clear_trace.connect('clicked', self.clear_trace_cb)
clear_trace.set_sensitive(False)
#.........这里部分代码省略.........
示例9: build_toolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def build_toolbar(self):
self.max_participants = 4
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
create_toolbar = ToolbarButton()
create_toolbar.props.page = Gtk.Toolbar()
create_toolbar.props.icon_name = 'magicpen'
create_toolbar.props.label = _('Create')
toolbar_box.toolbar.insert(create_toolbar, -1)
self._insert_create_tools(create_toolbar)
self._insert_stop_play_button(toolbar_box.toolbar)
clear_trace = ToolButton('clear-trace')
clear_trace.set_tooltip(_('Clear Trace Marks'))
clear_trace.set_accelerator(_('<ctrl>x'))
clear_trace.connect('clicked', self.clear_trace_cb)
clear_trace.set_sensitive(False)
toolbar_box.toolbar.insert(clear_trace, -1)
clear_trace.show()
self.clear_trace = clear_trace
self._insert_clear_all_button(toolbar_box.toolbar)
load_example = ToolButton('load-sample')
load_example.set_tooltip(_('Show sample projects'))
load_example.connect('clicked', self._create_store)
toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
toolbar_box.toolbar.insert(load_example, -1)
load_example.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_size_request(0, -1)
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
separator.show()
stop = StopButton(self)
toolbar_box.toolbar.insert(stop, -1)
stop.show()
separator = Gtk.SeparatorToolItem()
activity_button.props.page.insert(separator, -1)
separator.show()
export_json = ToolButton('save-as-json')
export_json.set_tooltip(_('Export tracked objects to journal'))
export_json.connect('clicked', self._export_json_cb)
activity_button.props.page.insert(export_json, -1)
export_json.show()
export_csv = ToolButton('save-as-csv')
export_csv.set_tooltip(_('Export tracked objects to journal'))
export_csv.connect('clicked', self._export_csv_cb)
activity_button.props.page.insert(export_csv, -1)
export_csv.show()
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
示例10: __init__
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def __init__(self, handle):
super(PeterActivity, self).__init__(handle)
# Get user's Sugar colors
sugarcolors = profile.get_color().to_string().split(',')
colors = [[int(sugarcolors[0][1:3], 16),
int(sugarcolors[0][3:5], 16),
int(sugarcolors[0][5:7], 16)],
[int(sugarcolors[1][1:3], 16),
int(sugarcolors[1][3:5], 16),
int(sugarcolors[1][5:7], 16)]]
# No sharing
self.max_participants = 1
# Build the activity toolbar.
toolbox = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbox.toolbar.insert(activity_button, 0)
activity_button.show()
cyan = ToolButton('media-playback-start')
toolbox.toolbar.insert(cyan, -1)
cyan.set_tooltip(_('Play'))
cyan.set_accelerator('space')
cyan.connect('clicked', self._button_cb, 'new')
cyan.show()
tick = ToolButton('dialog-ok')
toolbox.toolbar.insert(tick, -1)
tick.set_tooltip(_('Accept'))
tick.set_accelerator('Return')
tick.connect('clicked', self._button_cb, 'tick')
tick.show()
back = ToolButton('dialog-cancel')
toolbox.toolbar.insert(back, -1)
back.set_tooltip(_('Back'))
back.set_accelerator('Up')
back.connect('clicked', self._button_cb, 'back')
back.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = True
toolbox.toolbar.insert(separator, -1)
separator.show()
label = Gtk.Label()
label.set_use_markup(True)
label.show()
labelitem = Gtk.ToolItem()
labelitem.add(label)
toolbox.toolbar.insert(labelitem, -1)
labelitem.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbox.toolbar.insert(separator, -1)
separator.show()
stop = StopButton(self)
toolbox.toolbar.insert(stop, -1)
stop.show()
toolbox.show()
self.set_toolbar_box(toolbox)
# Create the game instance.
self.game = Letters.Letters(colors, sugar=True)
# Build the Pygame canvas.
self.game.canvas = self._pygamecanvas = sugargame.canvas.PygameCanvas(
self, main=self.game.run, modules=[pygame.display, pygame.font])
# Note that set_canvas implicitly calls
# read_file when resuming from the Journal.
self.set_canvas(self._pygamecanvas)
self.game.set_label(label)
self.game.set_buttons(cyan, tick, back)
Gdk.Screen.get_default().connect('size-changed',
self.__configure_cb)
示例11: PhysicsActivity
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
class PhysicsActivity(activity.Activity):
def __init__(self, handle):
super(PhysicsActivity, self).__init__(handle)
self._collab = CollabWrapper(self)
self._collab.message.connect(self.__message_cb)
self.metadata["mime_type"] = "application/x-physics-activity"
self.add_events(Gdk.EventMask.ALL_EVENTS_MASK | Gdk.EventMask.VISIBILITY_NOTIFY_MASK)
self.connect("visibility-notify-event", self._focus_event)
self.connect("window-state-event", self._window_event)
self.game_canvas = sugargame.canvas.PygameCanvas(self)
self.game = physics.main(self)
self.preview = None
self._sample_window = None
self._fixed = Gtk.Fixed()
self._fixed.put(self.game_canvas, 0, 0)
w = Gdk.Screen.width()
h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
self.game_canvas.set_size_request(w, h)
self._constructors = {}
self.build_toolbar()
self.set_canvas(self._fixed)
Gdk.Screen.get_default().connect("size-changed", self.__configure_cb)
logging.debug(os.path.join(activity.get_activity_root(), "data", "data"))
self.game_canvas.run_pygame(self.game.run)
self.show_all()
self._collab.setup()
def __configure_cb(self, event):
""" Screen size has changed """
self.write_file(os.path.join(activity.get_activity_root(), "data", "data"))
w = Gdk.Screen.width()
h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
pygame.display.set_mode((w, h), pygame.RESIZABLE)
self.read_file(os.path.join(activity.get_activity_root(), "data", "data"))
self.game.run(True)
def read_file(self, file_path):
self.game.read_file(file_path)
def write_file(self, file_path):
self.game.write_file(file_path)
def get_preview(self):
""" Custom preview code to get image from pygame. """
return self.game_canvas.get_preview()
def build_toolbar(self):
self.max_participants = 4
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
create_toolbar = ToolbarButton()
create_toolbar.props.page = Gtk.Toolbar()
create_toolbar.props.icon_name = "magicpen"
create_toolbar.props.label = _("Create")
toolbar_box.toolbar.insert(create_toolbar, -1)
self._insert_create_tools(create_toolbar)
color = ColorToolButton("Color Button")
color.props.icon_name = "color"
color.connect("notify::color", self.returnChosenColor)
toolbar_box.toolbar.insert(color, -1)
color.show()
self.randomColor = ToggleToolButton("Random Color")
self.randomColor.set_tooltip(_("Toggle random color"))
self.randomColor.props.icon_name = "colorRandom"
self.randomColor.connect("toggled", self.resetColors)
toolbar_box.toolbar.insert(self.randomColor, -1)
self.randomColor.set_active(True)
self.randomColor.show()
self._insert_stop_play_button(toolbar_box.toolbar)
clear_trace = ToolButton("clear-trace")
clear_trace.set_tooltip(_("Clear Trace Marks"))
clear_trace.set_accelerator(_("<ctrl>x"))
clear_trace.connect("clicked", self.clear_trace_cb)
clear_trace.set_sensitive(False)
toolbar_box.toolbar.insert(clear_trace, -1)
clear_trace.show()
self.clear_trace = clear_trace
self._insert_clear_all_button(toolbar_box.toolbar)
load_example = ToolButton("load-sample")
load_example.set_tooltip(_("Show sample projects"))
load_example.connect("clicked", self._create_store)
#.........这里部分代码省略.........
示例12: build_toolbar
# 需要导入模块: from sugar3.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar3.graphics.toolbutton.ToolButton import set_accelerator [as 别名]
def build_toolbar(self):
self.max_participants = 4
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
create_toolbar = ToolbarButton()
create_toolbar.props.page = Gtk.Toolbar()
create_toolbar.props.icon_name = "magicpen"
create_toolbar.props.label = _("Create")
toolbar_box.toolbar.insert(create_toolbar, -1)
self._insert_create_tools(create_toolbar)
color = ColorToolButton("Color Button")
color.props.icon_name = "color"
color.connect("notify::color", self.returnChosenColor)
toolbar_box.toolbar.insert(color, -1)
color.show()
self.randomColor = ToggleToolButton("Random Color")
self.randomColor.set_tooltip(_("Toggle random color"))
self.randomColor.props.icon_name = "colorRandom"
self.randomColor.connect("toggled", self.resetColors)
toolbar_box.toolbar.insert(self.randomColor, -1)
self.randomColor.set_active(True)
self.randomColor.show()
self._insert_stop_play_button(toolbar_box.toolbar)
clear_trace = ToolButton("clear-trace")
clear_trace.set_tooltip(_("Clear Trace Marks"))
clear_trace.set_accelerator(_("<ctrl>x"))
clear_trace.connect("clicked", self.clear_trace_cb)
clear_trace.set_sensitive(False)
toolbar_box.toolbar.insert(clear_trace, -1)
clear_trace.show()
self.clear_trace = clear_trace
self._insert_clear_all_button(toolbar_box.toolbar)
load_example = ToolButton("load-sample")
load_example.set_tooltip(_("Show sample projects"))
load_example.connect("clicked", self._create_store)
toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1)
toolbar_box.toolbar.insert(load_example, -1)
load_example.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_size_request(0, -1)
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
separator.show()
stop = StopButton(self)
toolbar_box.toolbar.insert(stop, -1)
stop.show()
separator = Gtk.SeparatorToolItem()
activity_button.props.page.insert(separator, -1)
separator.show()
export_json = ToolButton("save-as-json")
export_json.set_tooltip(_("Export tracked objects to journal"))
export_json.connect("clicked", self._export_json_cb)
activity_button.props.page.insert(export_json, -1)
export_json.show()
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