Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
slider.set_endcap_percent(0.1)
slider.min = 0
slider.max = 100
slider.value = 40
slider.padding = 25
slider.slider = "cross"
slider.orientation = "h"
slider.num_ticks = 4
slider.set_tick_percent(0.05)
container = OverlayContainer()
container.add(slider)
slider.on_trait_change(self.val_changed, "value")
self.slider = slider
return Window(self, component=container)
def _create_window(self):
box = Box(bounds=[100.0, 100.0], position=[50.0, 50.0])
box.tools.append(ResizeTool(component=box,
hotspots=set(["top", "left", "right",
"bottom", "top left",
"top right", "bottom left",
"bottom right"])))
container = Container(bounds=[500, 500])
container.add(box)
return Window(self, -1, component=container)
position = [label.x, label.y-15],
range = (0, 100.0, 10.0, 1.0),
enabled = True)
hscroll.on_trait_change(self._update_hscroll, "scroll_position")
container = Container(bounds=[200,200], border_visible=True,
padding=15)
container.add(label, hscroll, vscroll)
container.on_trait_change(self._update_layout, "bounds")
container.on_trait_change(self._update_layout, "bounds_items")
self.label = label
self.hscroll = hscroll
self.vscroll = vscroll
return Window(self, -1, component=container)
container1.add(rect1, rect2)
container1.bgcolor = (0.60, 0.98, 0.60, 0.5) #"palegreen"
rect3 = Region("purple", position=[50, 50])
rect4 = Region("teal", position=[200, 50])
rect3.overlays.append(Overlay("Three", component=rect3))
rect4.overlays.append(Overlay("Four", component=rect4))
container2 = OverlayPlotContainer(bounds=[400, 400], resizable="")
container2.add(rect3, rect4)
container2.bgcolor = "navajowhite"
container2.position = [200, 200]
top_container = OverlayPlotContainer()
top_container.add(container1, container2)
return Window(self, -1, component=top_container)
def _create_window(self):
text_field = TextField(position=[25,100], width=200)
text = "This a test with a text field\nthat has more text than\n"
text += "can fit in it."
text_field2 = TextField(position=[25,200], width=200,
height=50, multiline=True,
text=text, font="Courier New 14")
text_field3 = TextField(position=[250,50], height=300,
width=200, multiline=True,
font="Courier New 14")
container = Container(bounds=size, bgcolor='grey')
container.add(text_field, text_field2, text_field3)
return Window(self, -1, component=container)
def _create_window_simple(self):
viewport = self._create_viewport()
return Window(self, -1, component=viewport)
# Create an empty top-level container
if is_image:
top_container = self._create_top_img_container()
else:
top_container = self._create_top_container()
# The PlotSession of which we are a part. We need to know this in order
# to notify it of our being closed, etc.
self.session = None
# Create the Enable Window object, and store a reference to it.
# (This will be handy later.) The Window requires a WX parent object
# as its first argument, so we just pass 'self'.
self.plot_window = Window(self, component=top_container)
# We'll create a default sizer to put our plot_window in.
sizer = wx.BoxSizer(wx.HORIZONTAL)
# Since Window is an Enable object, we need to get its corresponding
# WX control. This is stored in its ".control" attribute.
sizer.Add(self.plot_window.control, 1, wx.EXPAND)
# Hook up event handlers for destroy, etc.
wx.EVT_WINDOW_DESTROY(self, self._on_window_close)
# More WX boilerplate.
self.SetSizer(sizer)
self.SetAutoLayout(True)
self.Show(True)
return
def _create_window(self):
box = Box(bounds=[100.0, 100.0], position=[50.0, 50.0])
container = Container(bounds=[500, 500])
container.add(box)
return Window(self, -1, component=container)
# Create some line plots of some of the data
plot = Plot(pd, title="Line Plot", padding=50, border_visible=True)
plot.legend.visible = True
plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")
plot.plot(("index", "y3"), name="j_3", color="blue")
# Attach some tools to the plot
plot.tools.append(PanTool(plot))
zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
plot.overlays.append(zoom)
# This Window object bridges the Enable and Qt4 worlds, and handles events
# and drawing. We can create whatever hierarchy of nested containers we
# want, as long as the top-level item gets set as the .component attribute
# of a Window.
return Window(parent, -1, component = plot)