def _create_window(self): canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True) from basic_move import Box box = Box(color="red", bounds=[50,50], resizable="") box.position= [75,75] canvas.add(box) viewport = Viewport(component=canvas) viewport.view_position = [0,0] viewport.tools.append(ViewportPanTool(viewport)) return Window(self, -1, component=viewport)
def _create_component(self): canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True) boxgridsize = 8 boxsize = 50 spacing = boxsize * 2 offset = spacing / 2 origin_color = array([0.0, 0.0, 1.0]) x_color = array([0.0, 1.0, 0.0]) y_color = array([1.0, 0.0, 0.0]) for i in range(boxgridsize): for j in range(boxgridsize): color = tuple(x_color / (boxgridsize - 1) * i + y_color / (boxgridsize - 1) * j + origin_color) + (1.0, ) box = Box(color=color, bounds=[boxsize, boxsize], resizable="") box.position = [ i * spacing + offset - boxsize / 2 + 0.5, j * spacing + offset - boxsize / 2 + 0.5, ] canvas.add(box) viewport = Viewport( component=canvas, enable_zoom=True, vertical_anchor="center", horizontal_anchor="center", ) # viewport.view_position = [0,0] viewport.tools.append(ViewportPanTool(viewport)) # Uncomment the following to enforce limits on the zoom # viewport.min_zoom = 0.1 # viewport.max_zoom = 3.0 scrolled = Scrolled( canvas, fit_window=True, inside_padding_width=0, mousewheel_scroll=False, viewport_component=viewport, always_show_sb=True, continuous_drag_update=True, ) return scrolled
def normal_dropped_on(self, event): self.window.set_drag_result("link") print(event.obj) box = Box(x=event.x - 2, y=event.y - 2, width=4, height=4) self.add(box) self.request_redraw() event.handled = True
def _create_window(self): canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True) boxgridsize = 8 boxsize = 50 spacing = boxsize * 2 offset = spacing / 2 origin_color = array([0.0, 0.0, 1.0]) x_color = array([0.0, 1.0, 0.0]) y_color = array([1.0, 0.0, 0.0]) for i in range(boxgridsize): for j in range(boxgridsize): color = tuple(x_color / (boxgridsize - 1) * i + \ y_color / (boxgridsize - 1) * j + \ origin_color) + (1.0,) box = Box(color=color, bounds=[boxsize, boxsize], resizable="") box.position= [i*spacing + offset - boxsize/2 + 0.5, j*spacing + offset - boxsize/2 + 0.5] canvas.add(box) viewport = Viewport(component=canvas, enable_zoom=True, vertical_anchor='center', horizontal_anchor='center') #viewport.view_position = [0,0] viewport.tools.append(ViewportPanTool(viewport)) # Uncomment the following to enforce limits on the zoom #viewport.min_zoom = 0.1 #viewport.max_zoom = 3.0 scrolled = Scrolled(canvas, fit_window = True, inside_padding_width = 0, mousewheel_scroll = False, viewport_component = viewport, always_show_sb = True, continuous_drag_update = True) return Window(self, -1, component=scrolled)
def _create_window(self): box = Box(bounds=[100, 100], position=[50, 50], color='red') move_tool = MoveCommandTool(component=box, command_stack=self.command_stack) box.tools.append(move_tool) container = Container(bounds=[600, 600]) container.add(box) undo_tool = UndoTool(component=container, undo_manager=self.undo_manager, undo_keys=[KeySpec('Left')], redo_keys=[KeySpec('Right')]) container.tools.append(undo_tool) window = Window(self.control, -1, component=container) return window