Syntax for custom dictionary object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax for custom dictionary object

Adam Hughes
Hey everyone,

I recall from past examples that it's possible to define a custom trait
type for a dictionary object that stores a predetermined object type.  I'd
like to define a dictionary which has a Filename as key, and the value is 2
parts, the first of which is a tuple and the second of which is an array.
For example:

filename: (tuple), nparray

or

filename: [ (tuple), nparray]

Either way is fine.  How would I define such a trait object when defining
my trait types at the beginning of a class?

Also, the nparray is a special datatype that I've already defined.  Is it
possible to include this into my dictionary definitions?  For example:

filename: [(tuple), nparray(dtype='mytype')]

I figure this is possible but am having trouble with the syntax, so any
help is greatly appreciated.
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Syntax for custom dictionary object

Barth
Hello,


I am trying to use the cursor tools of chaco to get information on a plot.
I developped a new ToolbarButton to place two cursors on a plot. I would
like to make a modification of this button so that if the cursors are
already there, it supresses them.

The current code in the following:

class CursorButton(ToolbarButton):
    label = "Get Cursors"
    tooltip = 'Get Cursors'
    image = 'application-vnd-ms-excel'

    orientation = Enum('v', 'h')
    def perform(self, event):
        img_plot=self.container.component.imgplot[0]

        csr1 = CursorTool(img_plot,drag_button="right",color='blue')
        self.cursor1 = csr1
        csr1.current_position = 1, 1
        img_plot.overlays.append(csr1)

        csr2 = CursorTool(img_plot,drag_button="right",color='white')
        self.cursor2 = csr2
        csr2.current_position = 1, 1
        img_plot.overlays.append(csr2)

To supress the button, i should first check if there are there:

for item in img_plot.overlays:
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev