/usr/share/pyshared/chaco/toolbar_plot.py is in python-chaco 4.1.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 | from chaco.api import Plot
from chaco.tools.toolbars.plot_toolbar import PlotToolbar
from traits.api import Type, DelegatesTo, Instance, Enum, \
on_trait_change
class ToolbarPlot(Plot):
# Should we turn on the auto-hide feature on the toolbar?
auto_hide = DelegatesTo('toolbar')
toolbar = Instance(PlotToolbar)
toolbar_class = Type(PlotToolbar)
toolbar_added = False
# Location of the default toolbar that is created if a toolbar
# is not specified with the `toolbar` attribute. Changing this
# attribute after the ToolbarPlot instance is created has no effect;
# use obj.toolbar.location to dynamically change the location of the
# instance `obj`s toolbar.
toolbar_location = Enum('top', 'right', 'bottom', 'left')
def __init__(self, *args, **kw):
# initialize the toolbar class before super() has a chance to create
# the default using the default class. This can happen because of
# ordering issues
if "toolbar_class" in kw:
self.toolbar_class = kw.pop("toolbar_class")
super(ToolbarPlot, self).__init__(*args, **kw)
self.toolbar.component = self
self.add_toolbar()
def _toolbar_default(self):
return self.toolbar_class(self, location=self.toolbar_location)
def add_toolbar(self):
if not self.toolbar_added:
self.overlays.append(self.toolbar)
self.toolbar_added = True
self.request_redraw()
def remove_toolbar(self):
if self.toolbar_added and self.auto_hide:
self.overlays.remove(self.toolbar)
self.toolbar_added = False
self.request_redraw()
def _bounds_changed(self, old, new):
self.toolbar.do_layout(force=True)
super(ToolbarPlot, self)._bounds_changed(old, new)
@on_trait_change('toolbar')
def _toolbar_changed(self, name, obj, old, new):
if self.toolbar_added:
# fixup the new toolbar's component to match the old one
new.component = old.component
self.overlays.remove(old)
self.toolbar_added = False
self.add_toolbar()
|