Adam Hughes | 9 Feb 17:36
Picon

Updating a chaco plot selected line color

I have a chaco plot object which stores several lineplots.  I have looked
through the Plot source and I am able to access the individual lineplots
using the name parameter.  For example, if I make a plot with 2 lines:

plots.plot( ('x', 'y'), name='plot1', color='green')
plots.plot(('x2','y2'), name='plot2', color='red')

Then I am able to access the lineplots individually with:

selected_lineplot=plots['plot1']

Everything is fine, but let's say I'd like to change the color of 'plot1'
to orange. I do the following:

plots['plot1'].color='orange'

The color trait is updated, I've checked, but the color on the plot is not
updated.  I've tried doing a request_redraw() on the whole plot and nothing
changes.  Any idea why there's no automatic update when I change the color
this way?

Thanks.
Thomas Wiecki | 9 Feb 16:49

Re: PrototypedFrom of List object

On Wed, Feb 8, 2012 at 2:53 PM, Robert Kern <rkern@...> wrote:
> On Wed, Feb 8, 2012 at 5:41 PM, Thomas Wiecki
> <thomas.wiecki@...> wrote:
>
>> However, there is an issue that comes up that once I replace 'things'
>> with a copy of itself, it seems to also remove the associated traits
>> event -- i.e. _things_items_changed() get's called only once and is
>> then ignored. Is there a way to reset the listener?
>
> I recommend something like the following:
>
> from traits.api import *
>
>
> class Original(HasTraits):
>    x = List()
>
> class Delegator(HasTraits):
>    original = Instance(Original, args=())
>    x = List()
>    _delegating_x = Bool(True)
>
>
>    @on_trait_change('original.x[]')
>    def _delegate_x(self):
>        if self._delegating_x:
>            self.x = self.original.x[:]
>            self._delegating_x = True
>
>    @on_trait_change('x[]')
(Continue reading)

Thomas Wiecki | 7 Feb 00:19

PrototypedFrom of List object

Hi,

I am trying to prototype a list object and want the items in that list
to get copied once the prototype gets copied, however, it seems
PrototypeFrom doesn't work that way:

This is my example, I expect that Toy would not show up in the father's things:
https://gist.github.com/1755796

This is for traits4.

Thanks,
Thomas
Severin Gsponer | 6 Feb 19:17
Picon
Gravatar

Scalar Cut Plane Size

Hi all, 

i have to visualize scalar data in from of a sphere. my scalar cut plane works great but no i have to show only a
certain segment of the cut plane. is it possible to set a range to a scalar cut plane? 

thanks

jojopij
Adam Hughes | 3 Feb 23:58
Picon

Adding range selection tool to chaco Plot object

Hey everyone,

I use the Plot() object in most of my codes, and noticed that the
range_selection demo uses LinePlot()..

    plot = create_line_plot((x,y), color=(0,0,1,1), width=2.0,
index_sort="ascending")  #plot is an instance of LinePlot()
    value_range = plot.value_mapper.range
    plot.active_tool = RangeSelection(plot, left_button_selects = True)
    plot.overlays.append(RangeSelectionOverlay(component=plot))

Anyway, when I try to adapt this to my code, where my plot object is an
instance of Plot() instead of LinePlot(), I get this error:

  File
"/usr/local/EPD/lib/python2.7/site-packages/chaco/tools/range_selection_overlay.py",
line 72, in overlay
    coords = self._get_selection_screencoords()
  File
"/usr/local/EPD/lib/python2.7/site-packages/chaco/tools/range_selection_overlay.py",
line 100, in _get_selection_screencoords
    ds = getattr(self.plot, self.axis)
AttributeError: 'Plot' object has no attribute 'index'

Does this mean that the RangeSelectionOverlay is not compatible with the
Plot() objects?
Martin Richter | 3 Feb 18:50
Gravatar

choosing colormap for volume rendering: example from docu in mlab.pipeline.volume breaks (solved)

Hi,

when trying to set the colormap of a volume-rendered dataset I was very
glad to find the enormously helpful docu at mlab.pipeline.volume. It
basically sais how to build up and set the ColorTransferFunction and the
opacity transfer function.

However a small example I tried did not work out as expected. After
digging a while I found that additionally to the mentioned docu you need
something like a

  ctf.range = [0, 1]

The range attribute is [0, 0] otherwise and the variable 'scale' in
enthought/tvtk/util/gradient_editor.py's load_from_vtk_volume_prop in
the class GradientTableOld is set to zero (approx. line 402; I'm using
mayavi2 3.3.0-1 from the Kubuntu lucid repositories)

I have to admit that this 'solution' is a bit cargocult-ish but at least
it solved my problem. Maybe this one line can be added just to the
__doc__ string?

Yours,
Martin

PS: And speaking of the docstring: Would it be a good idea to explicitly
mention that the 'value', 'r', 'g', 'b' parameters mentioned in
mlab.pipeline.volume are 0 <= value <= 1? I mean rather than uints in 0,
... , 255. I'm just mentioning that as I had to find out by trying. If
the docu would mention it it would have saved me 2 minutes ... okay ...
(Continue reading)

Pierre Barthelemy | 3 Feb 16:01
Picon
Gravatar

Chaco ToolbarPlot: change default toolbar

Dear all,

I need to include a toolbar in my plots, in such a way that i can save the
plot, retrieve the data ( and later save them in a certain format),...

I therefore use the ToolbarPlot class, which has a default toolbar, and try
to incude an extra button, defined in the class SaveToDataFormat

The code is the following:

from enthought.chaco.toolbar_plot import ToolbarPlot
from chaco.tools.toolbars.plot_toolbar import PlotToolbar
from modules.additional_buttons import SaveToDataFormat

plotdata = ArrayPlotData(x=x, y=y)
plot = ToolbarPlot(plotdata)
plot.toolbar.add_button(SaveToQtData())

But this makes that the extra button is added outside the toolbar, that i
already full with the default buttons.

My question is: how can i remove unnecessary buttons from this toolbar ? And
how can i redraw the toolbar such as to have the extra buttons within the
toolbar ?
Brennan Williams | 2 Feb 23:19
Gravatar

fractions calculator

I'm thinking of writing a fractions calculator in Python with a Traits 
GUI to help my kids. Before I reinvent the wheel, has anyone already 
done this? I was sort of thinking of an HP RPN type approach with a 
Traits-based calculator-like GUI.

Brennan
Chris Kees | 1 Feb 01:51
Picon
Gravatar

building mayavi on os x 10.7

Hi,

I'm trying to build mayavi in a custom installation and am wondering if I
can get some pointers.  When I run 'python ets.py develop' things go fine
until mayavi, which gives the following error. It looks like it fails
trying to build the docs, but I don't understand why it's trying to do that
before successfully building mayavi. If I just run 'python setup.py
install' I get seg fault and can't seem to get any information about why
it's failing. I'd appreciate any pointers on how to get more information
about why the build is failing.

Thanks,
Chris

Running command
['/Users/cekees/proteus/darwinclang/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python',
'setup.py', 'develop'] in package mayavi
running develop
running gen_docs
running build_docs
make -f MakefileMayavi html
sphinx-build -b html -d build/mayavi/doctrees   source/mayavi
build/mayavi/html
Running Sphinx v1.1.2
loading pickled environment... done
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 5 changed, 0 removed
Traceback (most recent call last):_view_objects

  File
(Continue reading)

Sam Wedge | 31 Jan 11:15
Gravatar

Table Filter [I]

Classification: Serco Internal

Hi,

I have been playing around with TableEditor and TabularEditor to display some data in a table, and would now
like to apply a filter to my data. Out of the two, I think I would rather use TabularEditor over TableEditor,
but in order to get a filter working I am willing to use whichever is necessary.

By trawling the documentation, I am aware that I need to create a function that outputs True or False for my
filter. What I am not sure about is how I can actually link this to my table view.

Have I missed any good examples on how to do this, or does anyone have any snippets that they wouldn't mind sharing?

Thanks,

Sam

*****Disclaimer************
This email and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only. If
you are not a named addressee, you must not use, retain or
disclose such information.

Serco cannot guarantee that the email or any attachments are free
from viruses.
The views expressed in this email are those of the originator and
do not necessarily represent the views of Serco.

Nothing in this email shall bind Serco in any contract or
obligation.
(Continue reading)

Adam Hughes | 31 Jan 02:30
Picon

Using HasTraits functions to set extended trait names

Hi,

I've been using some of the built-in features of HasTraits to run
simulations, mainly by using trait_get() and trait_set() methods.  I've
designed a structure that I think is fairly powerful for simulations,
because it allows a user to specify a set of ranges for valid float traits,
then the simulation will update all of these traits step by step, so it's
very easy to run simulations over many different types of variables in the
program using this same framework.  All the user has to provide are the
correct trait names.

For example, if I had traits A, B my simulation would update them both as
it runs along.  In practice, my objects are fairly complex, so the traits
that I really want to iterate over a buried deep in the class heirarchy.
In reality, I might want to run a simulation that varies A, and the trait
B.C.D where D is deep in the class heirarchy, a sub-sub-class of B.

The trait_get, and trait_set work() fine when I provide class trait names
like 'A' and 'B', but doesn't work with the extended notation as far as I
can tell (e.g. trait 'B.C.D').  Also I noticed that when I list trait names
using the .trait_names() method, it also does not access traits in the
subclasses.  Is there a known way to access subclass traits from the basic
HasTraits functions?

Thanks.

Gmane