def _comp_default(self): canvas = Canvas(draw_axes=True, bgcolor="gray") self.triangle = SierpinskiTriangle( position=[0.0, 0.0], bounds=[self.base_width, self.base_width * (SQRT3 / 2)], iterations=self.iterations, max_iters=self.max_iters, base_width=self.base_width, bgcolor="gray") canvas.add(self.triangle) self.viewport = Viewport(component=canvas, enable_zoom=True, stay_inside=True) self.viewport.zoom_tool.min_zoom = 1.0 self.viewport.tools.append( ViewportPanTool(self.viewport, drag_button="right")) scrolled = Scrolled( canvas, inside_padding_width=0, mousewheel_scroll=False, viewport_component=self.viewport, always_show_sb=True, continuous_drag_update=True, ) return scrolled
def __container_default(self): """ default setter for _container """ viewport = Viewport(component=self._canvas, enable_zoom=True) viewport.view_position = [0, 0] viewport.tools.append(ViewportPanTool(viewport)) return Scrolled(self._canvas, viewport_component=viewport)
def _create_component(self): container = Container(bounds=[800, 600], bgcolor=(0.9, 0.7, 0.7, 1.0), auto_size=False, fit_window=False) circle1 = Circle(bounds=[75,75], position=[100,100], shadow_type="dashed") container.add(circle1) scr = Scrolled(container, bounds=[200,200], position=[50,50], stay_inside=True, vertical_anchor='top', horizontal_anchor='left', fit_window=False) return scr
def _create_component(self): container = VerboseContainer(auto_size=False, bounds=[800, 800]) a = Box(bounds=[50.0, 50.0], position=[50.0, 50.0]) b = Box(bounds=[50.0, 50.0], position=[200.0, 50.0]) c = Box(bounds=[50.0, 50.0], position=[50.0, 200.0]) d = Box(bounds=[50.0, 50.0], position=[200.0, 200.0]) container.add(a) container.add(b) container.add(c) container.add(d) scr = Scrolled(container, bounds=[300, 300], position=[50, 50], fit_window=False) return scr
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 _create_component(self): canvas = DropCanvas(bgcolor="lightsteelblue", draw_axes=True) canvas.overlays.append(EventTracer(canvas, color="green", size=8, angle=45.0)) viewport = Viewport(component=canvas, enable_zoom=True) viewport.view_position = [0, 0] viewport.tools.append(ViewportPanTool(viewport, drag_button="right")) viewport.overlays.append(EventTracer(viewport)) scrolled = Scrolled(canvas, inside_padding_width=0, mousewheel_scroll=False, viewport_component=viewport, always_show_sb=True, continuous_drag_update=True) return scrolled
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ canvas = self.value viewport = CanvasViewport(component=canvas, view_position=[0, 0]) viewport.tools.append(ViewportPanTool(viewport, drag_button='right')) viewport.max_zoom = 1.0 viewport.min_zoom = 0.2 self.canvas_view = viewport self.scrolled = Scrolled(canvas, fit_window=True, inside_padding_width=0, mousewheel_scroll=False, always_show_sb=True, continuous_drag_update=True, viewport_component=viewport) self._window = Window(parent, -1, component=self.scrolled) self.control = self._window.control