def register_shortcuts(self): ''' .. versionchanged:: 0.14 Add keyboard shortcuts to set neighbouring electrode states based on directional input using ``<Control>`` key plus the corresponding direction (e.g., ``<Control>Up``) ''' def control_protocol(command): if self.plugin is not None: self.plugin.execute_async('microdrop.gui.protocol_controller', command) def actuate_direction(direction): if self.plugin is not None: self.plugin.execute_async('microdrop.electrode_controller_plugin', 'set_electrode_direction_states', direction=direction) # Tie shortcuts to protocol controller commands (next, previous, etc.) shortcuts = {'<Control>r': lambda *args: control_protocol('run_protocol'), '<Control>z': lambda *args: self.undo(), '<Control>y': lambda *args: self.redo(), 'A': lambda *args: control_protocol('first_step'), 'S': lambda *args: control_protocol('prev_step'), 'D': lambda *args: control_protocol('next_step'), 'F': lambda *args: control_protocol('last_step'), '<Control>Up': lambda *args: actuate_direction('up'), '<Control>Down': lambda *args: actuate_direction('down'), '<Control>Left': lambda *args: actuate_direction('left'), '<Control>Right': lambda *args: actuate_direction('right')} register_shortcuts(self.widget.parent, shortcuts)
def _register_shortcuts(self): class FocusWrapper(object): ''' This class allows for a function to be executed, restoring the focused state of the protocol grid view if necessary. ''' def __init__(self, controller, func): self.controller = controller self.func = func def __call__(self): focused = self.controller.widget.has_focus() self.func() if focused: self.controller.widget.grab_focus() app = get_app() view = app.main_window_controller.view shortcuts = { '<Control>c': self.widget.copy_rows, '<Control>x': FocusWrapper(self, self.widget.cut_rows), 'Delete': FocusWrapper(self, self.widget.delete_rows), '<Control>v': FocusWrapper(self, self.widget.paste_rows_after), '<Control><Shift>v': FocusWrapper(self, self.widget.paste_rows_before), '<Control><Shift>i': FocusWrapper(self, lambda: app.protocol.insert_step())} register_shortcuts(view, shortcuts, enabled_widgets=[self.widget])
def register_shortcuts(self): def control_protocol(command): if self.plugin is not None: self.plugin.execute_async('microdrop.gui.protocol_controller', command) # Tie shortcuts to protocol controller commands (next, previous, etc.) shortcuts = {'<Control>r': lambda *args: control_protocol('run_protocol'), '<Control>z': lambda *args: self.undo(), '<Control>y': lambda *args: self.redo(), 'A': lambda *args: control_protocol('first_step'), 'S': lambda *args: control_protocol('prev_step'), 'D': lambda *args: control_protocol('next_step'), 'F': lambda *args: control_protocol('last_step')} register_shortcuts(self.widget.parent, shortcuts)
def register_shortcuts(self): def control_protocol(command): if self.plugin is not None: self.plugin.execute_async('microdrop.gui.protocol_controller', command) # Tie shortcuts to protocol controller commands (next, previous, etc.) shortcuts = { '<Control>r': lambda *args: control_protocol('run_protocol'), '<Control>z': lambda *args: self.undo(), '<Control>y': lambda *args: self.redo(), 'A': lambda *args: control_protocol('first_step'), 'S': lambda *args: control_protocol('prev_step'), 'D': lambda *args: control_protocol('next_step'), 'F': lambda *args: control_protocol('last_step') } register_shortcuts(self.widget.parent, shortcuts)
def _register_shortcuts(self): app = get_app() view = app.main_window_controller.view shortcuts = { 'space': self.on_run_protocol, 'A': self.on_first_step, 'S': self.on_prev_step, 'D': self.on_next_step, 'F': self.on_last_step, #'Delete': self.on_delete_step, } register_shortcuts(view, shortcuts, disabled_widgets=[self.textentry_notes]) notes_shortcuts = { '<Control>z': self.textentry_notes.get_buffer().undo, '<Control>y': self.textentry_notes.get_buffer().redo, } register_shortcuts(view, notes_shortcuts, enabled_widgets=[self.textentry_notes])