warn("Error", "This folder contains no image files") show_file(file_pointer) except Exception as e: warn("Exception thrown", "Invalid folder. Please select valid folder.") # declare our main app app = App( title="Madeleine Ward Marker Prototype", width=IMAGE_WIDTH, height=IMAGE_HEIGHT, ) # CANVAS contains an image with lines that indicate species present canvas = Drawing(app, width=IMAGE_WIDTH, height=IMAGE_HEIGHT) # hook the events to the canvas object canvas.when_left_button_pressed = canvas_left_click canvas.when_right_button_pressed = canvas_right_click # define the menu bar menubar = MenuBar(app, toplevel=["File", "Mark Images"], options=[[["Pick Directory", pick_directory]], [["Mark Images", mark_function]]]) # hook the arrow keys (for now, might want to change this to local hook if permitted) app.when_key_pressed = keypress_hook app.display()
if painting.last_shape is not None: painting.delete(painting.last_shape) rectangle = painting.rectangle( painting.first_event.x, painting.first_event.y, event.x, event.y, color=color.value ) painting.last_shape = rectangle painting.last_event = event # ------------------------------ # App # ------------------------------ app = App("Paint") color = Combo(app, options=["black", "white", "red", "green", "blue"]) width = Slider(app, start=1, end=10) shape = Combo(app, options=["line", "rectangle"]) painting = Drawing(app, width="fill", height="fill") painting.when_left_button_pressed = start painting.when_mouse_dragged = draw app.display()