~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to examples/tutorials/scipy2008/custom_tool_screen.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
from numpy import linspace, sin
3
 
 
4
 
from chaco.api import ArrayPlotData, Plot
5
 
from enable.api import BaseTool
6
 
from enable.component_editor import ComponentEditor
7
 
from traits.api import Enum, HasTraits, Instance
8
 
from traitsui.api import Item, View
9
 
 
10
 
class CustomTool(BaseTool):
11
 
 
12
 
    def normal_mouse_move(self, event):
13
 
        print "Screen point:", event.x, event.y
14
 
 
15
 
class ScatterPlot(HasTraits):
16
 
 
17
 
    plot = Instance(Plot)
18
 
 
19
 
    traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False),
20
 
                       width=800, height=600, resizable=True,
21
 
                       title="Custom Tool")
22
 
 
23
 
    def _plot_default(self):
24
 
        # Create the data and the PlotData object
25
 
        x = linspace(-14, 14, 100)
26
 
        y = sin(x) * x**3
27
 
        plotdata = ArrayPlotData(x = x, y = y)
28
 
        # Create a Plot and associate it with the PlotData
29
 
        plot = Plot(plotdata)
30
 
        # Create a scatter plot in the Plot
31
 
        plot.plot(("x", "y"), type="scatter", color="blue")
32
 
        # Add our custom tool to the plot
33
 
        plot.tools.append(CustomTool(plot))
34
 
        return plot
35
 
 
36
 
#===============================================================================
37
 
# demo object that is used by the demo.py application.
38
 
#===============================================================================
39
 
demo=ScatterPlot()
40
 
if __name__ == "__main__":
41
 
    demo.edit_traits(kind="livemodal")