def on_key_release(self, symbol, modifiers): self.try_redraw() if not graphics.drawing and self.current_tool.key_release != tool.Tool.key_release: graphics.enter_canvas_mode() graphics.drawing = True self.current_tool.key_release(symbol, modifiers) graphics.drawing = False graphics.exit_canvas_mode()
def on_text(self, text): self.try_redraw() if not graphics.drawing and self.current_tool.text != tool.Tool.text: graphics.enter_canvas_mode() graphics.drawing = True self.current_tool.text(text) graphics.drawing = False graphics.exit_canvas_mode()
def on_mouse_press(self, x, y, button, modifiers): self.try_redraw() if x > graphics.canvas_x and y > graphics.canvas_y: if self.current_tool.ask_undo(): self.push_undo(graphics.get_canvas()) graphics.drawing = True graphics.enter_canvas_mode() self.current_tool.start_drawing(x,y) else: #pick a color if click was in color picker if self.colorpicker.coords_inside(x,y): graphics.set_selected_color(self.colorpicker.get_color(x,y))
def on_key_press(self, symbol, modifiers): self.try_redraw() if modifiers & key.MOD_ACCEL: if symbol == key.F: graphics.toggle_fullscreen() elif symbol == key.Z: self.undo() elif symbol == key.S: self.save() elif symbol == key.O: self.open() if not graphics.drawing and self.current_tool.key_press != tool.Tool.key_press: graphics.enter_canvas_mode() graphics.drawing = True self.current_tool.key_press(symbol, modifiers) graphics.drawing = False graphics.exit_canvas_mode() if symbol == key.ESCAPE: return True #stop Pyglet from quitting