/usr/lib/python2.7/dist-packages/chaco/plot_canvas_toolbar.py is in python-chaco 4.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | from traits.api import Any, Enum, Int
from enable.drawing.api import ToolbarButton
# Local, relative imports
from plot_containers import VPlotContainer
from plot_component import PlotComponent
class PlotCanvasToolbar(VPlotContainer):
# The placement of the toolbar over the canvas
align = Enum("ur", "ul", "ll", "lr", "left", "right", "top", "bottom")
# The spacing between buttons
button_spacing = Int(5)
# The (optional) component that we overlay
component = Any
# Override some inherited traits
spacing = 5
fit_components = "hv"
resizable = "hv"
halign = "center"
valign = "center"
fill_padding = False
unified_draw = True
def overlay(self, component, gc, view_bounds=None, mode="normal"):
""" Allows the toolbar to behave like an overlay """
self._do_layout()
pref_size = self.get_preferred_size()
# Special check for when we are overlaying an instance of enable.Canvas
if hasattr(component, 'view_bounds'):
cx, cy, cx2, cy2 = component.view_bounds
cwidth = cx2 - cx + 1
cheight = cy2 - cy + 1
else:
cx, cy = component.position
cheight, cwidth = component.bounds
if self.align in ("ur", "ul", "top"):
y = cy + cheight - self.outer_height
elif self.align in ("lr", "ll", "bottom"):
y = cy
else:
y = cy + (cheight - pref_size[1])/2
if self.align in ("ur", "lr", "right"):
x = cx + cwidth - self.outer_width
elif self.align in ("ul", "ll", "left"):
x = cx
else:
x = cx + (cwidth - pref_size[0])/2
self.outer_position = [x, y]
VPlotContainer._draw(self, gc, view_bounds, mode)
def _request_redraw(self):
# Reproduce the behavior in AbstractOverlay to dispatch a
# redraw event up to our overlaid component
if self.component is not None:
self.component.request_redraw()
super(PlotCanvasToolbar, self)._request_redraw()
return
class PlotToolbarButton(PlotComponent, ToolbarButton):
label_font = "Arial 12"
unified_draw = True
def _draw_plot(self, *args, **kw):
return self._draw_mainlayer(*args, **kw)
|