def on_key_press(self, event): #print('you pressed ', event.key) if event.key in ('pagedown', ' ', 'right'): self.inc_i() elif event.key in ('pageup', 'backspace', 'left'): self.dec_i() elif event.key in self.keymap: newlabel = self.keymap[event.key] self.opstack.push(Update(self.i, 'name', newlabel)) self.inc_i() elif event.key in ('ctrl+i', 'down'): if self.N_points > 5000: self.N_points -= 5000 self.update_plot_data() elif event.key in ('ctrl+o', 'up'): self.N_points += 5000 self.update_plot_data() elif event.key == 'ctrl+s': self.save() elif event.key == 'ctrl+h': print(help_string) elif event.key in ('ctrl+m', 'ctrl+backspace') and self.i > 0: self.i -= 1 self.opstack.push(Merge(self.i)) self.inc_i() elif event.key in ('ctrl+x', 'tab'): self.opstack.push(Delete(self.i)) if self.i >= len(self.opstack.events): self.i = len(self.opstack.events) - 1 self.update_plot_data() elif event.key == 'ctrl+z' and self.opstack.ops: self.opstack.undo() self.i = self.opstack.undo_ops[-1].index self.update_plot_data() elif event.key == 'ctrl+y' and self.opstack.undo_ops: self.opstack.redo() self.i = self.opstack.ops[-1].index self.update_plot_data()
def delete(self): self.opstack.push(Delete(self.label_index)) if self.label_index >= len(self.opstack.events): self.label_index = len(self.opstack.events) - 1 self.update_plot_data()
def test_delete(labels): Delete(0).on(labels) assert labels[0]['name'] == 'b'