-1

I have two class, it is child class of HasTraits. this case:

  view =View(
    VGroup(
        HGroup(
            Label(u' '),
            Item(
                "bt_import", label=' '
            ),
            Item(
                "bt_export", label=' '
            ),
            show_left=False
        ),
        HGroup(
            Label(u' '),
            Item(
                "signalplot",
                editor=ComponentEditor(size=(600, 300)),
                show_label=False
            ),
            Label(u' '),
        ),
        HGroup(
            Label(u' '),
            Item(
                "spectrumplot",
                editor=ComponentEditor(size=(600, 300)),
                show_label=False
            ),
            Label(u' '),
        ),
   ),
    width=600,
    height=800,
    resizable=False,
    title=u"FFT 过滤"
)

In here, I will put two class. signalplot<-signal class and spectrumplot<-spectrum class two class:

class Signal(HasTraits):
     view = View()
.......

class Spectrum(HasTraits):
       view = View()
.......

This case, How to make two class? and How to put two class in interface?

Tim D
  • 1,645
  • 1
  • 25
  • 46

1 Answers1

1

The pattern you're looking for is this:

class MySignalSpectrumView(HasTraits):
    sig = Instance(Signal)
    spec = Instance(Spectrum)

if __name__ == "__main__":
    mssv = MySignalSpectrumView()
    mssv.configure_traits(view=view)

That is, you are calling edit_traits or configure_traits on the model class and passing it the view you want to use. Defining a traits_view = View(...) will provide the view used by default. There are lots of good examples in the docs and the demos directory that ships with Traits, TraitsUI, and Chaco.

Tim D
  • 1,645
  • 1
  • 25
  • 46
  • I tired it. But it is generated traits error. in words, mssv.configure_traits(view=view) is not excute. thanks – jonghyon lee Mar 05 '16 at 13:00
  • Make sure that `view`, `Signal`, and `Spectrum` are all defined in that file or explicit imported.You'll either have to post the error traceback to this question or figure it out by looking into the traceback yourself. – Tim D Mar 07 '16 at 14:00