Ejemplo n.º 1
0
class FECellView(CellView):
    geo_view = Instance(GeoCellView)

    def _geo_view_default(self):
        return GeoCellView()

    dof_view = Instance(DofCellView)

    def _dof_view_default(self):
        return DofCellView()

    @on_trait_change('cell_grid')
    def _reset_view_links(self):
        self.geo_view.cell_grid = self.cell_grid.geo_grid
        self.dof_view.cell_grid = self.cell_grid.dof_grid

    def set_cell_traits(self):
        self.dof_view.cell_idx = self.cell_idx
        self.dof_view.set_cell_traits()
        self.geo_view.cell_idx = self.cell_idx
        self.geo_view.set_cell_traits()

    def redraw(self):
        self.dof_view.redraw()
        self.geo_view.redraw()

    traits_view = View(HSplit(Item('geo_view@', show_label=False),
                              Item('dof_view@', show_label=False)),
                       resizable=True,
                       scrollable=True,
                       width=0.6,
                       height=0.2)
Ejemplo n.º 2
0
class OrderMenu(HasPrivateTraits):

    # The person's entree order:
    entree = Enum(values='capabilities.available')

    # Reference to the restaurant's current entree capabilities:
    capabilities = Constant(kitchen_capabilities)

    # The user interface view:
    view = View(
        HSplit(
            VGroup(Item('entree',
                        editor=EnumEditor(
                            name='object.capabilities.available',
                            evaluate=str,
                            completion_mode='popup',
                        )),
                   label='Order',
                   show_border=True,
                   dock='tab'),
            VGroup(Item('object.capabilities.available',
                        show_label=False,
                        style='custom',
                        editor=CheckListEditor(values=possible_entrees)),
                   label='Kitchen',
                   show_border=True,
                   dock='tab')),
        title='Dynamic EnumEditor Demo',
        resizable=True,
    )
Ejemplo n.º 3
0
class TmpClass(Handler):
    aa = Int(10)
    bb = Int(100)

    def init(self, ui_info):
        super(TmpClass, self).init(ui_info)
        self.save_prefs(ui_info)

    def reset_prefs(self, ui_info):
        """ Reset the split to be equally wide.
        """
        control = getattr(ui_info, 'h_split').control
        width = control.width()
        control.moveSplitter(width/2, 1)

    def restore_prefs(self, ui_info):
        """ Apply the last saved ui preferences.
        """
        ui_info.ui.set_prefs(self._prefs)

    def save_prefs(self, ui_info):
        """ Save the current ui preferences.
        """
        self._prefs = ui_info.ui.get_prefs()

    def collapse_right(self, ui_info):
        """ Collapse the split to the right.
        """
        control = getattr(ui_info, 'h_split').control
        width = control.width()
        control.moveSplitter(width, 1)

    def collapse_left(self, ui_info):
        """ Collapse the split to the left.
        """
        control = getattr(ui_info, 'h_split').control
        control.moveSplitter(0, 1)

    view = View(
        HSplit(
            Group(
                Item('aa', resizable=True, width=50), show_border=True,
            ),
            Group(
                Item('bb', width=100), show_border=True,
            ),
            id='h_split',
        ),
        resizable=True,
        # add actions to test manually.
        buttons=[Action(name='collapse left', action='collapse_left'),
                 Action(name='collapse right', action='collapse_right'),
                 Action(name='reset_layout', action='reset_prefs'),
                 Action(name='restore layout', action='restore_prefs'),
                 Action(name='save layout', action='save_prefs')],
        height=300,
        id='test_view_for_splitter_pref_restore',
    )
Ejemplo n.º 4
0
    def traits_view(self):
        rgrp = BorderHGroup(
            UItem('selected_reactor_name',
                  editor=EnumEditor(name='reactor_names')),
            icon_button_editor(
                'add_reactor_button',
                'add',
                tooltip='Add Default Production for the selected '
                'Reactor to this Irradiation level'),
            icon_button_editor('update_reactor_default_button',
                               'arrow_up',
                               tooltip='Set current as the reactor default'),
            label='Available Default Productions')

        pgrp = BorderHGroup(
            UItem('selected_production_name',
                  editor=EnumEditor(name='production_names')),
            icon_button_editor('apply_selected_production',
                               'arrow_left',
                               tooltip='Apply selection'),
            icon_button_editor('add_production_button',
                               'database_add',
                               tooltip='Add a Production Ratio'),
            icon_button_editor('edit_production_button',
                               'database_edit',
                               enabled_when='selected_production',
                               tooltip='Edit Production Ratio'),
            label='Production'),
        pr_group = VGroup(rgrp,
                          pgrp,
                          UItem('selected_production', style='custom'),
                          label='Production Ratios')

        editor = TabularEditor(adapter=TrayAdapter(),
                               editable=False,
                               selected='selected_tray')
        tray_grp = VGroup(HGroup(
            icon_button_editor('add_tray_button',
                               'add',
                               tooltip='Add a tray from file')),
                          HSplit(
                              UItem('trays', editor=editor, width=0.25),
                              UItem('canvas',
                                    editor=ComponentEditor(),
                                    width=0.75)),
                          label='Tray')

        v = okcancel_view(VGroup(
            HGroup(Item('name'), Item('z')),
            VGroup(UItem('level_note', style='custom'),
                   label='Level Note',
                   show_border=True), Group(pr_group,
                                            tray_grp,
                                            layout='tabbed')),
                          width=550,
                          height=650,
                          title=self.title)
        return v
Ejemplo n.º 5
0
class RTraceArraySnapshot(RTrace):
    '''
    Plot the current value of the array along the x_axis

    Used currently for plotting the integrity factor over microplanes
    '''
    var = Str('')
    var_eval = Callable
    idx = Int(-1)

    trace = Instance(MFnLineArray)

    x = Array(float)
    y = Array(float)

    def _trace_default(self):
        return MFnLineArray()

    view = View(HSplit(
        VGroup(VGroup('var'), VGroup('record_on', 'clear_on')),
        Item('trace@',
             style='custom',
             editor=MFnMatplotlibEditor(adapter=MFnPlotAdapter(var_y='var')),
             show_label=False,
             resizable=True),
    ),
                buttons=[OKButton, CancelButton],
                resizable=True)

    def bind(self):
        '''
        Locate the evaluators
        '''
        self.var_eval = self.rmgr.rte_dict[self.var]

    def setup(self):
        pass

    def add_current_values(self, sctx, U_k, *args, **kw):
        '''
        Invoke the evaluators in the current context for the specified control vector U_k.
        '''
        self.y = np.array(self.var_eval(sctx, U_k, *args, **kw), dtype='float')
        self.x = np.arange(0, len(self.y), dtype='float')
        self.redraw()

    def timer_tick(self, e=None):
        self.redraw()

    def redraw(self):
        self.trace.xdata = self.x
        self.trace.ydata = self.y

    def clear(self):
        # @todo:
        self.x = np.zeros((0, ), dtype='float_')
        self.y = np.zeros((0, ), dtype='float_')
Ejemplo n.º 6
0
    def traits_view(self):
        """ Default traits view for this class. """

        help_action = Action(name='Info', action='preferences_help')

        buttons = ['OK', 'Cancel']

        if self.show_apply:
            buttons = ['Apply'] + buttons
        if self.show_help:
            buttons = [help_action] + buttons

        # A tree editor for preferences nodes.
        tree_editor = TreeEditor(nodes=[
            TreeNode(
                node_for=[PreferencesNode],
                auto_open=False,
                children='children',
                label='name',
                rename=False,
                copy=False,
                delete=False,
                insert=False,
                menu=None,
            ),
        ],
                                 on_select=self._selection_changed,
                                 editable=False,
                                 hide_root=True,
                                 selected='selected_node',
                                 show_icons=False)

        view = View(
            HSplit(
                Item(
                    name='root',
                    editor=tree_editor,
                    show_label=False,
                    width=250,
                ),
                Item(
                    name='selected_page',
                    #editor     = WidgetEditor(),
                    show_label=False,
                    width=450,
                    style='custom',
                ),
            ),
            buttons=buttons,
            handler=PreferencesManagerHandler(model=self),
            resizable=True,
            title='Preferences',
            width=.3,
            height=.3,
            kind='modal')
        self.selected_page = self.pages[0]
        return view
Ejemplo n.º 7
0
    def traits_view(self):
        cols = [
            ObjectColumn(name='name', label='', editable=False),
            ObjectColumn(name='counts'),
            ObjectColumn(name='settle', label='Settle (s)'),
            ObjectColumn(name='isotopes_label',
                         editable=False,
                         width=175,
                         label='Isotopes')
        ]

        hgrp = VGroup(
            UItem('object.hop_sequence.hops',
                  editor=myTableEditor(columns=cols,
                                       clear_selection_on_dclicked=True,
                                       sortable=False,
                                       selected='selected')),
            HGroup(
                icon_button_editor('add_hop_button',
                                   'add',
                                   tooltip='Add peak hop'),
                icon_button_editor('remove_hop_button',
                                   'delete',
                                   tooltip='Delete selected peak hop',
                                   enabled_when='selected')))
        sgrp = UItem('selected', style='custom', editor=InstanceEditor())

        grp = HSplit(hgrp, sgrp)
        save_action = Action(name='Save',
                             image=icon('document-save'),
                             enabled_when='object.saveable',
                             action='save')
        save_as_acion = Action(
            name='Save As',
            image=icon('document-save-as'),
            action='save_as',
            enabled_when='object.saveasable',
        )

        teditor = myTextEditor(bgcolor='#F7F6D0',
                               fontsize=12,
                               fontsize_name='fontsize',
                               wrap=False,
                               tab_width=15)

        v = View(
            VGroup(
                VGroup(grp, label='Editor'),
                VGroup(UItem('object.text', editor=teditor, style='custom'),
                       label='Text')),
            # toolbar=ToolBar(),
            width=690,
            title=self.title,
            buttons=['OK', save_action, save_as_acion],
            resizable=True)
        return v
Ejemplo n.º 8
0
 def traits_view(self):
     if self.editable:
         v = View(
             HSplit(
                 self._get_edit_group(),
                 VGroup(self._get_conditionals_grp(),
                        self._get_tool_group())))
     else:
         v = View(self._get_conditionals_grp())
     return v
Ejemplo n.º 9
0
class AddLabelsWindow(Handler):
    model = Any
    #clumsily old a reference to the model object

    annotation = Str
    label = File

    add_annot_button = Button('Add annotation')
    add_label_button = Button('Add label file')

    annot_borders = Bool
    annot_opacity = Range(0., 1., 1.)
    annot_hemi = Enum('both', 'lh', 'rh')
    label_borders = Bool
    label_opacity = Range(0., 1., 1.)
    label_color = Color('blue')

    remove_labels_action = Action(name='Remove all labels', action='do_remove')

    def _add_annot_button_fired(self):
        self.model.add_annotation(self.annotation,
                                  border=self.annot_borders,
                                  hemi=self.annot_hemi,
                                  opacity=self.annot_opacity)

    def _add_label_button_fired(self):
        self.model.add_label(self.label,
                             border=self.label_borders,
                             opacity=self.label_opacity,
                             color=self.label_color)

    def do_remove(self, info):
        self.model.remove_labels()

    traits_view = View(
        HSplit(
            VGroup(
                Item('annotation'),
                Item('annot_borders', label='show border only'),
                Item('annot_opacity', label='opacity'),
                Item('annot_hemi', label='hemi'),
                Item('add_annot_button', show_label=False),
            ),
            VGroup(
                Item('label'),
                Item('label_borders', label='show_border_only'),
                Item('label_opacity', label='opacity'),
                Item('label_color', label='color'),
                Item('add_label_button', show_label=False),
            ),
        ),
        buttons=[remove_labels_action, OKButton],
        kind='livemodal',
        title='Dial 1-800-COLLECT and save a buck or two',
    )
Ejemplo n.º 10
0
    def default_traits_view(self):
        ht = 1000
        v = View(
            VSplit(
                UItem(
                    'graph',
                    editor=CustomEditor(setup_qwidget_control),
                    resizable=True,
                    #height=(ht-150)),
                    height=0.85),
                HSplit(
                    Group(
                        HGroup(
                            VGroup(Label('Trace spacing (uV)'),
                                   UItem('_y_spacing_enum', resizable=True),
                                   Label('Enter spacing (uV)'),
                                   UItem('_y_spacing_entry'),
                                   UItem('auto_space')),
                            VGroup(
                                Label('Heatmap curves'),
                                UItem(
                                    'object.curve_manager.heatmap_name',
                                    editor=EnumEditor(
                                        name='object.curve_manager._curve_names'
                                    )), Label('Color map'), UItem('colormap'),
                                UItem('auto_clim'))),
                        HGroup(
                            VGroup(UItem('clear_selected_channels'),
                                   UItem('curve_editor_popup')),
                            VGroup(
                                Label('Interactive curves'),
                                UItem(
                                    'object.curve_manager.interactive_name',
                                    editor=EnumEditor(
                                        name='object.curve_manager._curve_names'
                                    )))),
                        HGroup(Label('Vis. sample rate'),
                               UItem('vis_rate', style='readonly'))),
                    UItem(
                        'modules',
                        style='custom',
                        resizable=True,
                        editor=ListEditor(use_notebook=True,
                                          deletable=False,
                                          dock_style='tab',
                                          page_name='.name'),

                        # height=-150
                    ),
                )),
            width=1200,
            height=ht,
            resizable=True,
            title=self.recording)
        return v
Ejemplo n.º 11
0
class Viz2D(ROutputItem):
    '''Base class of the visualization adaptors
    '''

    viz_sheet = WeakRef

    name = Str('<unnamed>')
    visible = Bool(True)

    label = Property(depends_on='label')

    @cached_property
    def _get_label(self):
        return self.name

    vis2d = WeakRef

    def reset(self, ax):
        pass

    def clear(self):
        pass

    def plot(self, ax, vot=0):
        raise NotImplemented

    def plot_tex(self, ax, vot, *args, **kw):
        raise NotImplemented

    def write_figure(self, f, rdir, rel_study_path):
        fname = 'fig_' + self.name.replace(' ', '_') + '.pdf'
        f.write(r'''
\includegraphics[width=7.5cm]{%s}
''' % join(rel_study_path, fname))
        self.savefig(join(rdir, fname))

    def savefig_animate(self, vot, fname, figsize=(9, 6)):
        fig = plt.figure(figsize=figsize)
        ax = fig.add_subplot(111)
        self.plot(ax, vot)
        fig.tight_layout()
        fig.savefig(fname)

    def savefig(self, fname):
        fig = plt.figure()
        ax = fig.add_subplot(111)
        self.plot_tex(ax, 0.25)
        fig.savefig(fname)

    trait_view = View(HSplit(
        VGroup(UItem('label'),
               Item('visible'),
               label='Vizualization interface',
               springy=True)),
                      resizable=True)
Ejemplo n.º 12
0
class DatasetViewportLayout(DatasetViewportInterface):
    def mkitems(dummies=False):
        if dummies: view_order = ('dummy', 'dummy', 'dummy')
        else: view_order = ('mayavi', 'matrix', 'circle')
        for it in view_order:
            yield Item(name='%s_port' % it,
                       style='custom',
                       show_label=False,
                       editor=InstanceEditor(view='%s_view' % it),
                       height=500,
                       width=500)

    single_view = View(HSplit(content=[it for it in mkitems()], columns=3),
                       height=500,
                       width=1500)
    square_view = View(VSplit(
        HSplit(content=[it for it in mkitems()][:-1], columns=2),
        HSplit(content=[it for it in mkitems()][-1:], columns=2)),
                       height=1000,
                       width=1000)
Ejemplo n.º 13
0
    def traits_view(self):
        g = self.get_component_view()
        g.width = 0.75

        v = View(HSplit(
            g,
            UItem('items',
                  width=0.25,
                  editor=TabularEditor(adapter=VerticalFluxTabularAdapter()))),
                 resizable=True)
        return v
Ejemplo n.º 14
0
 def traits_view(self):
     v = View(HSplit(UItem('snapshots', editor=TabularEditor(adapter=SnapshotAdapter(),
                                                             editable=False,
                                                             selected='selected'),
                           width=200),
                     VGroup(Item('selected_path', label='Local', style='readonly'),
                            Item('selected_remote_path',label='Remote', style='readonly'),
                            VGroup(UItem('selected_image',
                                  width=500,
                                  editor=ImageEditor())))))
     return v
Ejemplo n.º 15
0
    def traits_view(self):
        hue_grp = VGroup(HGroup(spring, UItem('hue_default_button')),
                         Item('hue'),
                         Item('saturation'),
                         Item('brightness'),
                         show_border=True,
                         label='Hue/Saturation/Brightness')

        c_gamma_grp = VGroup(HGroup(spring, UItem('contrast_default_button')),
                             Item('contrast'),
                             Item('gamma'),
                             show_border=True,
                             label='Contrast/Gamma')

        exposure_grp = VGroup(Item('auto_exposure_enabled'),
                              Item('exposure_time', enabled_when='not auto_exposure_enabled'),
                              show_border=True,
                              label='Exposure')
        white_balance_grp = VGroup(UItem('awb_button'),
                                   show_border=True,
                                   label='White Balance')
        # color_grp = VGroup(label='Color')
        meta_grp = VGroup(HGroup(Item('use_auto_snapshot_name', label='Use Auto'),
                                 Item('snapshot_name',
                                      label='Name',
                                      enabled_when='not use_auto_snapshot_name'),
                                 Item('extension')),
                          VGroup(UItem('note', style='custom'), show_border=True, label='Note'),
                          show_border=True,
                          label='Meta')

        ctrlgrp = VFold(meta_grp,
                        hue_grp,
                        exposure_grp,
                        c_gamma_grp,
                        white_balance_grp)

        v = View(HSplit(ctrlgrp,
                        UItem('_device',
                              width=640, height=480,
                              editor=CameraEditor())),
                 toolbar=ToolBar(Action(action='do_snapshot',
                                        image=icon('camera'),
                                        name='Snapshot'
                                        ),
                                 # Action(action='save_settings',
                                 #        image=icon('cog'))
                                 ),
                 title='Camera',
                 resizable=True)
        # v = View(VGroup(meta_grp, exposure_grp, c_gamma_grp,
        #                 white_balance_grp))
        return v
Ejemplo n.º 16
0
class MyDialog(HasTraits):

    scene1 = Instance(MlabSceneModel, ())
    scene2 = Instance(MlabSceneModel, ())

    # print( scene1 )
    #     scene1.mayavi_scene.on_mouse_pick( lambda x : print( '5' ) )

    button1 = Button('Redraw')
    button2 = Button('Redraw')

    @on_trait_change('button1')
    def redraw_scene1(self):
        self.redraw_scene(self.scene1)

    @on_trait_change('button2')
    def redraw_scene2(self):
        self.redraw_scene(self.scene2)

    def redraw_scene(self, scene):
        # Notice how each mlab call points explicitely to the figure it
        # applies to.
        mlab.clf(figure=scene.mayavi_scene)
        x, y, z, s = np.random.random((4, 100))
        mlab.points3d(x, y, z, s, figure=scene.mayavi_scene)

    # The layout of the dialog created
    view = View(
        HSplit(
            Group(
                Item('scene1', editor=SceneEditor(), height=250, width=300),
                'button1',
                show_labels=False,
            ),
            Group(
                Item('scene2',
                     editor=SceneEditor(),
                     height=250,
                     width=300,
                     show_label=False),
                'button2',
                show_labels=False,
            ),
        ),
        resizable=True,
    )

    def mouseReleaseEvent(self, QMouseEvent):
        if QMouseEvent.button() == QtCore.Qt.LeftButton:
            print("Left Button Clicked")
        elif QMouseEvent.button() == QtCore.Qt.RightButton:
            #do what you want here
            print("Right Button Clicked")
 def traits_view(self):
     v = View(VGroup(
         HSplit(left_group(), right_group()),
         UItem('diff_items',
               editor=TabularEditor(editable=False,
                                    adapter=self.item_adapter))),
              title='Diff',
              width=900,
              buttons=['OK'],
              kind='livemodal',
              resizable=True)
     return v
class TmpClass(Handler):
    aa = Int(10)
    bb = Int(100)

    def init(self, ui_info):
        super().init(ui_info)
        self.save_prefs(ui_info)
        return True

    def reset_prefs(self, ui_info):
        """Reset the split to be equally wide."""
        control = getattr(ui_info, "h_split").control
        width = control.width()
        control.moveSplitter(width // 2, 1)

    def restore_prefs(self, ui_info):
        """Apply the last saved ui preferences."""
        ui_info.ui.set_prefs(self._prefs)

    def save_prefs(self, ui_info):
        """Save the current ui preferences."""
        self._prefs = ui_info.ui.get_prefs()

    def collapse_right(self, ui_info):
        """Collapse the split to the right."""
        control = getattr(ui_info, "h_split").control
        width = control.width()
        control.moveSplitter(width, 1)

    def collapse_left(self, ui_info):
        """Collapse the split to the left."""
        control = getattr(ui_info, "h_split").control
        control.moveSplitter(0, 1)

    view = View(
        HSplit(
            Group(Item("aa", resizable=True, width=50), show_border=True),
            Group(Item("bb", width=100), show_border=True),
            id="h_split",
        ),
        resizable=True,
        # add actions to test manually.
        buttons=[
            Action(name="collapse left", action="collapse_left"),
            Action(name="collapse right", action="collapse_right"),
            Action(name="reset_layout", action="reset_prefs"),
            Action(name="restore layout", action="restore_prefs"),
            Action(name="save layout", action="save_prefs"),
        ],
        height=300,
        id="test_view_for_splitter_pref_restore",
    )
Ejemplo n.º 19
0
class StoragePlotter(HasTraits):

    figure = Instance(Figure, ())
    avail_columns = List(Str)
    columns = List(editor=SetEditor(
        name='avail_columns',
        format_func=lambda x: x,
    ), )

    view = View(
        HSplit(
            Item('figure', editor=MPLFigureEditor(), show_label=False),
            Item(
                'columns',
                style='custom',
                show_label=False,
            ),
            scrollable=True,
        ),
        width=700,
        height=400,
        resizable=True,
    )

    def __init__(self, stofpath, *args):
        HasTraits.__init__(self, trait_value=True)
        if stofpath.endswith('.sto') or stofpath.endswith('.mot'):
            if 'StaticOptimization' in stofpath:
                self.data = storage2numpy(stofpath, excess_header_entries=2)
            else:
                self.data = storage2numpy(stofpath)
        elif stofpath.endswith('.trc'):
            self.data = TRCFile(stofpath).data
        avail_columns = list(self.data.dtype.names)
        avail_columns.remove('time')
        self.avail_columns = avail_columns

        self.axes = self.figure.add_subplot(111)

        # TODO
        #for arg in args:
        #    self.columns.append(arg)
        #    self._columns_changed()

    @on_trait_change('columns')
    def _columns_changed(self):
        self.axes.cla()
        for name in self.columns:
            self.axes.plot(self.data['time'], self.data[name], label=name)
        self.axes.set_xlabel('time (s)')
        self.axes.legend(loc='best')
        self.figure.canvas.draw()
Ejemplo n.º 20
0
    def traits_view(self):
        teditor, ieditor, ceditor, eeditor, meditor = self._get_editors()

        v = View(VSplit(
            HSplit(
                UItem('measurement_values',
                      editor=meditor,
                      height=300,
                      width=0.4),
                UItem('extraction_values',
                      editor=eeditor,
                      height=300,
                      width=0.6)),
            UItem('isotopes', editor=teditor, height=0.25),
            UItem('isotopes',
                  editor=ieditor,
                  defined_when='show_intermediate',
                  height=0.25),
            HSplit(UItem('computed_values', editor=ceditor, height=200),
                   UItem('corrected_values', height=200, editor=ceditor))),
                 handler=MainViewHandler())
        return v
Ejemplo n.º 21
0
 def traits_view(self):
     adapter = RunBlockAdapter()
     v = View(HSplit(VGroup(UItem('blocks',
                                  width=0.25,
                                  editor=ListStrEditor(selected='selected')),
                            HGroup(icon_button_editor('delete_run', 'delete'))),
                     UItem('runs',
                           width=0.75,
                           editor=TabularEditor(editable=False,
                                                adapter=adapter))),
              width=900,
              resizable=True)
     return v
Ejemplo n.º 22
0
    def default_traits_view(self):

        return View(
            HSplit(
                VSplit(
                    Item('data_file@', editor=FileEditor(filter_name='filter'),
                         show_label=False),
                    Group(
                        Item('figure', editor=MPLFigureEditor(),
                             resizable=True, show_label=False),
                        id='simexdb.plot_sheet',
                        label='plot sheet',
                        dock='tab',
                    ),
                    Group(
                        Item('plot_template'),
                        columns=1,
                        label='plot parameters',
                        id='simexdb.plot_params',
                        dock='tab',
                    ),
                    id='simexdb.plot.vsplit',
                    dock='tab',
                ),
                VSplit(
                    Item('model@',
                         id='simexdb.run.split',
                         dock='tab',
                         resizable=True,
                         label='experiment run',
                         show_label=False),
                    id='simexdb.mode_plot_data.vsplit',
                    dock='tab',
                    scrollable=True
                ),
                id='simexdb.hsplit',
                dock='tab',
            ),
            key_bindings=self.key_bindings,
            menubar=self.default_menubar(),
            toolbar=self.default_toolbar(),
            resizable=True,
            title='Simvisage: experiment database browser',
            id='simexdb',
            dock='tab',
            buttons=['Ok'],
            height=1.0,
            width=1.0
        )
Ejemplo n.º 23
0
 def traits_view(self):
     tgrp = Item('table',
                 show_label=False,
                 style='custom',
                 width=0.3,
                 editor=InstanceEditor(view='panel_view'))
     ggrp = VGroup(
         HGroup(Item('data_labels_visible', label='Label'), spring),
         Item('graph', show_label=False, style='custom', width=0.7))
     v = View(HSplit(tgrp, ggrp),
              width=1000,
              height=500,
              title='Recent Analyses',
              resizable=True)
     return v
Ejemplo n.º 24
0
 def traits_view(self):
     l = UItem('left_values',
               editor=TabularEditor(adapter=ValueTabularAdapter(),
                                    editable=False,
                                    selected_row='selected_row'))
     d = UItem('diff_values',
               editor=TabularEditor(adapter=DiffTabularAdapter(),
                                    editable=False,
                                    selected_row='selected_row'))
     r = UItem('right_values',
               editor=TabularEditor(adapter=ValueTabularAdapter(),
                                    editable=False,
                                    selected_row='selected_row'))
     v = View(HSplit(l, d, r))
     return v
Ejemplo n.º 25
0
class NSolver(HasTraits):
    d_t = Float(0.01)
    t_max = Float(1.)
    k_max = Float(50)
    tolerance = Float(1e-5)
    disps = Str('0.0,10.0')

    d_array = Property(depends_on='disps')
    ''' convert the disps string to float array
    '''
    @cached_property
    def _get_d_array(self):
        return np.array([float(x) for x in self.disps.split(',')])

    time_func = Property(depends_on='disps, t_max')

    @cached_property
    def _get_time_func(self):
        dd_arr = np.abs(np.diff(self.d_array))
        x = np.hstack((0, self.t_max * np.cumsum(dd_arr) / sum(dd_arr)))
        return interp1d(x, self.d_array)

    figure = Instance(Figure)

    def _figure_default(self):
        figure = Figure()
        return figure

    update = Button()

    def _update_fired(self):
        self.figure.clear()
        ax = self.figure.add_subplot(111)
        x = np.arange(0, self.t_max, self.d_t)
        ax.plot(x, self.time_func(x))
        ax.set_xlabel('time')
        ax.set_ylabel('displacement')
        self.figure.canvas.draw()

    view = View(HSplit(Group(Item('d_t'),
                             Item('k_max')),
                       Group(Item('t_max'),
                             Item('tolerance'))),
                Group(Item('disps'),
                      Item('update', show_label=False)),
                Item('figure', editor=MPLFigureEditor(),
                     dock='horizontal', show_label=False),
                kind='modal')
Ejemplo n.º 26
0
class UIDebugger(Handler):

    #---------------------------------------------------------------------------
    #  Trait definitions:
    #---------------------------------------------------------------------------

    # The name of the plugin:
    name = Str('UI Debugger')

    # The current wx Window being 'debugged':
    window = Trait(None,
                   WindowPayloadHandler(),
                   droppable='Drop a wx.Window object here.')

    # Root of a wxWindow window hierarchy:
    root = Instance(WXWindow, allow_none=True)

    # The currently selected window:
    selected = Instance(WXWindow, allow_none=True)

    #---------------------------------------------------------------------------
    #  Traits view definitions:
    #---------------------------------------------------------------------------

    view = View(HSplit(Item('root',
                            label='Hierarchy',
                            show_label=False,
                            editor=window_tree_editor,
                            resizable=True,
                            dock='horizontal'),
                       Item('selected@',
                            id='selected',
                            label='Selected',
                            show_label=False,
                            resizable=True,
                            dock='horizontal'),
                       id='splitter'),
                title='UI Debugger',
                id='etsdevtools.developer.tools.ui_debugger')

    #---------------------------------------------------------------------------
    #  Handles the 'window' trait being changed:
    #---------------------------------------------------------------------------

    def _window_changed(self, window):
        if window is not None:
            self.root = WXWindow(window=window)
            do_later(self.set, window=None)
Ejemplo n.º 27
0
class PythonBrowser(HasPrivateTraits):

    # -- Trait Definitions ----------------------------------------------------

    dir = Directory()
    files = List(FileInfo)
    file_info = Instance(FileInfo)
    code = Code()

    # -- Traits View Definitions ----------------------------------------------

    view = View(
        HSplit(
            Item('dir', style='custom'),
            VSplit(
                Item('files', editor=tabular_editor),
                Item('code', style='readonly'),
                show_labels=False,
            ),
            show_labels=False,
        ),
        resizable=True,
        width=0.75,
        height=0.75,
    )

    # -- Event Handlers -------------------------------------------------------

    def _dir_changed(self, dir):
        if dir != '':
            self.files = [
                FileInfo(file_name=join(dir, name)) for name in listdir(dir)
                if ((splitext(name)[1] == '.py') and isfile(join(dir, name)))
            ]
        else:
            self.files = []

    def _file_info_changed(self, file_info):
        fh = None
        try:
            fh = open(file_info.file_name, 'rU', encoding='utf8')
            self.code = fh.read()
        except:
            pass

        if fh is not None:
            fh.close()
Ejemplo n.º 28
0
class MainWindow(HasTraits):

    ftt = Instance(FTT)

    def _ftt_default(self):
        return FTT(root=CustomCPFactory())

    ftv = Instance(FTV)

    def _ftv_default(self):
        return FTV()

    traits_view = View(HSplit(UItem('ftt@', width=300), UItem('ftv@')),
                       width=1.0,
                       height=1.0,
                       resizable=True,
                       title='oricreate')
Ejemplo n.º 29
0
class ScriptedComponentView(ModelView):
    """ ModelView of a ScriptedComponent displaying the script and image """

    #: the component we are editing
    model = Instance(ScriptedComponent, ())

    view = View(HSplit(
        VGroup(
            UItem('model.draw_script'),
            UItem('model.error',
                  visible_when="model.error != ''",
                  style='readonly',
                  height=100)),
        VGroup(UItem('model', editor=ComponentEditor()),
               UItem('model.fps_display', height=20)),
    ),
                resizable=True)
Ejemplo n.º 30
0
    def traits_view(self):
        pr_group = VGroup(
            HGroup(
                icon_button_editor('add_production_button',
                                   'database_add',
                                   tooltip='Add a Production Ratio'),
                icon_button_editor('edit_production_button',
                                   'database_edit',
                                   enabled_when='selected_production',
                                   tooltip='Edit Production Ratio')),
            VGroup(
                HGroup(
                    UItem('selected_production_name',
                          editor=EnumEditor(name='production_names')),
                    Item('new_production_name', label='Name')),
                UItem('selected_production', style='custom')),
            label='Production Ratios')

        editor = TabularEditor(adapter=TrayAdapter(),
                               editable=False,
                               selected='selected_tray')
        tray_grp = VGroup(HGroup(
            icon_button_editor('add_tray_button',
                               'add',
                               tooltip='Add a tray from file')),
                          HSplit(
                              UItem('trays', editor=editor, width=0.25),
                              UItem('canvas',
                                    editor=ComponentEditor(),
                                    width=0.75)),
                          label='Tray')

        v = View(VGroup(
            HGroup(Item('name'), Item('z')),
            VGroup(UItem('level_note', style='custom'),
                   label='Level Note',
                   show_border=True), Group(pr_group,
                                            tray_grp,
                                            layout='tabbed')),
                 resizable=True,
                 width=550,
                 height=650,
                 title=self.title,
                 kind='livemodal',
                 buttons=['OK', 'Cancel'])
        return v