multiple editors for a single control

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

multiple editors for a single control

_jelle_
Hi,

I'm working on a CAD app, using PythonOCC.
What I'd like to achieve is to have an editor for a Vertex, Edge, Face or a
Solid, though the editors share a single OpenGL viewer.
So I couldnt thing of anything better than using a singleton ( sigh )
and check if an instance ( ._instance ) was already created.
Fine, that works. However, in the View, each Item ( logically ) is displayed
in its proper widget. What I need is to have multiple editors refer to a single
widget, so the View is split up n number of Item's defined in the View
So rather than using an Item need to <blank>... in order not to split up
 the OpenGL viewer? Should I subclass Item or use a Handler?

Thanks so much!

-jelle




class OCCEditor(Editor):
    shapes = List(Any)
    selection = List(Any)
    display = Instance(OCCViewer)
    initialized = Bool

    def init ( self, parent):
        # self.control = OCCTraitViewer(self, self.selection)
        if OCCTraitViewer._instance is None:
            self.control = OCCTraitViewer(self, self.selection)
        else:
            self.control = OCCTraitViewer._instance


 class Example(HasTraits):
        shapes = List
        more_shapes = List

        add_stuff = Button
        remove_stuff = Button

        #these are synced with the OCCEditor, name is refered to in OCCEditorFactory
        selection = List
        display = Instance(OCCViewer)
       
        view = View(
            #set editor for the shapelist

            Item('shapes',
             editor=OCCEditorFactory(selection='selection', display='display'), show_label=False),
           
          Item('more_shapes',
          editor=OCCEditorFactory(selection='selection', display='display'), show_label=False),


            # one OpenGL Viewer split up in two, since two Item's are defined
            # how can these refer to the same control without the split?
            Item('add_stuff', show_label=False),
            Item('remove_stuff', show_label=False),
            width= 0.8,
            height=0.8,
            resizable=True
        )


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