forked from enthought/traits-enaml
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#---------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2013-14, Enthought, Inc. | ||
# All rights reserved. | ||
# | ||
# This software is provided without warranty under the terms of the BSD | ||
# license included in /LICENSE.txt and may be redistributed only | ||
# under the conditions described in the aforementioned license. The license | ||
# is also available online at http://www.enthought.com/licenses/BSD.txt | ||
# | ||
# Thanks for using Enthought open source! | ||
# | ||
#---------------------------------------------------------------------------- | ||
|
||
from enaml.widgets.api import MainWindow, Container | ||
from enaml.layout.api import vbox | ||
from traits_enaml.widgets.enable_canvas import EnableCanvas | ||
|
||
|
||
enamldef Main(MainWindow): main: | ||
attr model | ||
initial_size = (600, 400) | ||
Container: | ||
EnableCanvas: ecanvas: | ||
component = main.model.plot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#---------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2013-14, Enthought, Inc. | ||
# All rights reserved. | ||
# | ||
# This software is provided without warranty under the terms of the BSD | ||
# license included in /LICENSE.txt and may be redistributed only | ||
# under the conditions described in the aforementioned license. The license | ||
# is also available online at http://www.enthought.com/licenses/BSD.txt | ||
# | ||
# Thanks for using Enthought open source! | ||
# | ||
#---------------------------------------------------------------------------- | ||
|
||
from numpy import exp, linspace, meshgrid | ||
|
||
import traits_enaml | ||
from enaml.qt.qt_application import QtApplication | ||
from traits.api import HasStrictTraits, Instance | ||
from chaco.api import ArrayPlotData, jet, Plot | ||
|
||
class Model(HasStrictTraits): | ||
|
||
plot = Instance(Plot, ()) | ||
|
||
def _plot_default(self): | ||
# Create a scalar field to colormap | ||
xs = linspace(0, 10, 600) | ||
ys = linspace(0, 5, 600) | ||
x, y = meshgrid(xs,ys) | ||
z = exp(-(x**2+y**2)/100) | ||
|
||
# Create a plot data object and give it this data | ||
pd = ArrayPlotData() | ||
pd.set_data("imagedata", z) | ||
|
||
# Create the plot | ||
plot = Plot(pd) | ||
plot.img_plot("imagedata", colormap=jet) | ||
return plot | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
with traits_enaml.imports(): | ||
from enable_canvas import Main | ||
|
||
app = QtApplication() | ||
view = Main(model=Model()) | ||
view.show() | ||
|
||
app.start() |