/usr/share/pyshared/chaco/tools/dataprinter.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 | """ Defines the DataPrinter tool class.
"""
# Enthought library imports
from traits.api import Str
from enable.api import BaseTool
# Chaco imports
from chaco.api import BaseXYPlot
class DataPrinter(BaseTool):
""" Simple listener tool that prints the (x,y) data space position of the
point under the cursor.
"""
# This tool is a listener, and does not display anything (overrides BaseTool).
visible = False
# Turn off drawing, because the tool prints to stdout.
draw_mode = "none"
# The string to format the (x,y) value in data space.
format = Str("(%.3f, %.3f)")
def normal_mouse_move(self, event):
""" Handles the mouse being moved in the 'normal' state.
Prints the data space position of the current mouse position.
"""
plot = self.component
if plot is not None:
if isinstance(plot, BaseXYPlot):
ndx = plot.map_index((event.x, event.y), index_only = True)
x = plot.index.get_data()[ndx]
y = plot.value.get_data()[ndx]
print self.format % (x,y)
else:
print "dataprinter: don't know how to handle plots of type",
print plot.__class__.__name__
return
# EOF
|