コード例 #1
0
    def get_fav_group(self, edit_view=None):
        cols = self.get_columns()
        editor = TableEditor(columns=cols,
                             selected='_selected',
                             sortable=False)
        if edit_view:
            editor.edit_view = edit_view

        fav_grp = VGroup(
            UItem('_fav_items', width=100, editor=editor),
            HGroup(self.get_buttons(),
                   Spring(width=10, springy=False),
                   Label('Status:'),
                   CustomLabel('_connected_label',
                               label='Status',
                               weight='bold',
                               color_name='_connected_color'),
                   spring,
                   show_labels=False))
        return fav_grp
コード例 #2
0
 def options_group(self):
     g = HGroup(
         UItem('options_btn'),
         UItem('clear_btn'),
         UItem('line_selector', visible_when='not img_bool'),
         UItem('copy_data_btn', visible_when='not img_bool'),
         HGroup(
             VGroup(
                 HGroup(
                     Item('normalize_bool', label='normalize'),
                     Item('log_bool', label='log scale'),
                     Item('cmap_selector',
                          label='cmap',
                          visible_when='img_bool'),
                     UItem('image_slider_btn', visible_when='img_bool'),
                     UItem('save_fig_btn'),
                 ), HGroup(
                     UItem('widget_sel'),
                     UItem('widget_clear_btn'),
                 ))),
     )
     return g
コード例 #3
0
    def traits_view(self):

        tb = HGroup(
            icon_button_editor('add_button', 'add'),
            icon_button_editor('remove_button', 'delete'),
        )

        cols = [
            ObjectColumn(name='start_date', ),
            ObjectColumn(name='start_time', ),
            ObjectColumn(name='end_date', ),
            ObjectColumn(name='end_time'),
            ObjectColumn(name='power')
        ]
        table = UItem('dosages',
                      editor=TableEditor(columns=cols,
                                         selected='selected_dosage',
                                         sortable=False))
        v = View(VGroup(tb, table))
        return v
コード例 #4
0
class CustomCPFactory(FactoryTask):

    '''Seller of the crease pattern.
    '''

    formed_object = Instance(CreasePattern)

    def _formed_object_default(self):
        return CreasePattern(X=[0, 0, 0])

    traits_view = View(
        VGroup(
            HGroup(
                Item('node', springy=True)
            ),
            UItem('formed_object@'),
        ),
        resizable=True,
        title='Custom Factory'
    )
コード例 #5
0
    def _get_interpreted_age_group(self):
        grp = VGroup(
            UItem('interpreted_table.interpreted_ages',
                  # width=0.4,
                  editor=myTabularEditor(
                      adapter=self.model.interpreted_age_table.tabular_adapter,
                      operations=['move', 'delete'],
                      # column_clicked=make_name('column_clicked'),
                      # refresh='interpreted_table.refresh_needed',
                      selected='interpreted_table.selected',
                      # dclicked='interpreted_table.dclicked',
                      multi_select=True,
                      # drag_external=True,
                      # scroll_to_row='interpreted_table.scroll_to_row',
                      stretch_last_section=False)),
            # HGroup(spring, Item(make_name('omit_invalid'))),
            show_border=True,
            label='Interpreted Ages')

        return grp
コード例 #6
0
ファイル: demo_group_size.py プロジェクト: zakou3570/traitsui
class PlotView(HasTraits):
    """Defines a sub-view whose size we wish to explicitly control."""
    n = Int(123)
    data = Instance(AbstractPlotData)
    plot1 = Instance(Plot)
    view = View(
        # This HGroup keeps 'n' from over-widening, by implicitly placing
        # a spring to the right of the item.
        HGroup(Item('n')),
        UItem('plot1', editor=ComponentEditor()),
        resizable=True,
    )

    def create_plot(self, data, name, color):
        p = Plot(self.data)
        p.plot(data, name=name, color=color)
        return p

    def _data_changed(self):
        self.plot1 = self.create_plot(("x", "y1"), "sin plot", "red")
コード例 #7
0
ファイル: blanks_views.py プロジェクト: ael-noblegas/pychron
    def traits_view(self):
        aux_plots_grp = UItem('aux_plots',
                              style='custom',
                              width=525,
                              editor=myTableEditor(
                                  columns=self._get_columns(),
                                  sortable=False,
                                  deletable=True,
                                  clear_selection_on_dclicked=True,
                                  orientation='vertical',
                                  selected='selected',
                                  selection_mode='rows',
                                  edit_view=self._get_edit_view(),
                                  reorderable=False))

        # rgrp = HGroup(Item('use_restricted_references'), show_border=True)
        atgrp = self._get_analysis_group()
        v = self._make_view(atgrp, aux_plots_grp)

        return v
コード例 #8
0
 def traits_view(self):
     v = View(
         VGroup(
             HGroup(spring,
                    CustomLabel('plot_title',
                                weight='bold',
                                size=14),
                    spring
             ),
             UItem(
                 'graphs',
                 editor=ListEditor(use_notebook=True,
                                   selected='selected_graph',
                                   page_name='.page_name'
                 ),
                 style='custom'
             )
         )
     )
     return v
コード例 #9
0
 def _get_date_group(self):
     date_grp = HGroup(UItem('use_low_post'),
                       UItem('low_post',
                             style='custom',
                             enabled_when='use_low_post'),
                       UItem('use_high_post'),
                       UItem('high_post',
                             style='custom',
                             enabled_when='use_high_post'),
                       UItem('use_named_date_range'),
                       UItem('named_date_range'),
                       label='Date',
                       visible_when='date_visible',
                       show_border=True)
     return date_grp
コード例 #10
0
class DampedOscView(HasTraits):
    """
    Access the model using DelegatesTo().
    """

    model = Instance(DampedOsc)

    x = DelegatesTo('model')
    y = DelegatesTo('model')
    a = DelegatesTo('model')

    # Add delegated traits for the remaining DampedOsc traits...

    # The Plot instance that will show the graph of the function.
    plot = Instance(Plot)

    traits_view = \
        View(
            Group(
                UItem('plot', editor=ComponentEditor(), style='custom'),
            ),
            Item('a', label='a', editor=RangeEditor(low=0.0, high=10.0)),
            # Add additional Items here so the user can change b, omega,
            # and phase with sliders...

            # The following completes the definition of the View.
            resizable=True,
            width=600,
            height=550,
            title="a * exp(-b*x) * cos(omega*x + phase)",
        )

    def _plot_default(self):
        data = ArrayPlotData(x=self.x, y=self.y)
        plot = Plot(data)
        plot.plot(('x', 'y'), style='line', color='green')
        plot.value_range.set_bounds(-self.a, self.a)
        return plot

    def _a_changed(self):
        self.plot.value_range.set_bounds(-self.a, self.a)
コード例 #11
0
class Demo(HasTraits):
    plot = Instance(Component)

    traits_view = View(Group(UItem('plot',
                                   editor=ComponentEditor(size=(1000, 500))),
                             orientation="vertical"),
                       resizable=True,
                       title="Demo of image origin and orientation")

    def _plot_default(self):
        # Create a GridContainer to hold all of our plots: 2 rows, 4 columns:
        container = GridContainer(fill_padding=True,
                                  bgcolor="lightgray",
                                  use_backbuffer=True,
                                  shape=(2, 4))

        arrangements = [('top left', 'h'), ('top right', 'h'),
                        ('top left', 'v'), ('top right', 'v'),
                        ('bottom left', 'h'), ('bottom right', 'h'),
                        ('bottom left', 'v'), ('bottom right', 'v')]
        orientation_name = {'h': 'horizontal', 'v': 'vertical'}

        pd = ArrayPlotData(image=face())
        # Plot some bessel functions and add the plots to our container
        for origin, orientation in arrangements:
            plot = Plot(pd, default_origin=origin, orientation=orientation)
            plot.img_plot('image')

            # Attach some tools to the plot
            plot.tools.append(PanTool(plot))
            zoom = ZoomTool(plot, tool_mode="box", always_on=False)
            plot.overlays.append(zoom)

            title = '{0}, {1}'
            plot.title = title.format(orientation_name[orientation],
                                      origin.replace(' ', '-'))

            # Add to the grid container
            container.add(plot)

        return container
コード例 #12
0
 def options_group_axes_sel(self):
     g = HGroup(
         UItem('options_btn'),
         UItem('clear_btn'),
         UItem('line_selector', visible_when='not img_bool'),
         UItem('copy_data_btn', visible_when='not img_bool'),
         Item('axes_selector'),
         Item('normalize_bool', label='normalize'),
         Item('log_bool', label='log scale'),
         Item('draw_legend_bool', label='draw legend'),
         Item('cmap_selector', label='cmap', visible_when='img_bool'),
         UItem('image_slider_btn', visible_when='img_bool'),
         UItem('save_fig_btn'),
     )
     return g
コード例 #13
0
class Setting(SettingBase):
  full_name = Str()
  section = Str()

  traits_view = View(
    VGroup(
      Item('full_name', label='Name', style='readonly'),
      Item('value', editor=TextEditor(auto_set=False, enter_set=True)),
      Item('description', style='readonly'),
      Item('units', style='readonly'),
      Item('default_value', style='readonly'),
      UItem('notes', label="Notes", height=-1,
            editor=MultilineTextEditor(TextEditor(multi_line=True)), style='readonly',
            show_label=True, resizable=True),
      show_border=True,
      label='Setting',
    ),
  )

  def __init__(self, name, section, value, ordering, settings):
    self.name = name
    self.section = section
    self.full_name = "%s.%s" % (section, name)
    self.value = value
    self.ordering = ordering
    self.settings = settings
    self.expert = settings.settings_yaml.get_field(section, name, 'expert')
    self.description = settings.settings_yaml.get_field(section,
                                                           name, 'Description')
    self.units = settings.settings_yaml.get_field(section, name, 'units')
    self.notes = settings.settings_yaml.get_field(section, name, 'Notes')
    self.default_value = settings.settings_yaml.get_field(section, name,
                                                             'default value')

  def _value_changed(self, name, old, new):
    if (old != new and
        old is not Undefined and
        new is not Undefined):
      if type(self.value) == unicode:
        self.value = self.value.encode('ascii', 'replace')
      self.settings.set(self.section, self.name, self.value)
コード例 #14
0
    def _get_geochron(self):
        auth_grp = HGroup('object.repository.username',
                          'object.repository.password')
        grp = Group(
                    auth_grp,
                    Item('object.repository.url',
                         label='URL'),
                    HGroup(spring,
                           UItem('object.repository.upload_button',
                                 style='custom',
                                 editor=ButtonEditor(image=ImageResource(name='arrow_up.png',
                                                                         search_path=paths.icon_search_path)),
                                 enabled_when='object.repo_enabled',
                                 tooltip='Upload to Geochron database'
                                 )
                           ),
                    show_border=True,
                    label='Geochron'
                    )

        return grp
コード例 #15
0
ファイル: spectra.py プロジェクト: miketrumpis/lfp_scroller
 def default_traits_view(self):
     v = View(
         VGroup(HGroup(
             Item('NW', label='NW'),
             Item('pow2', label='Use radix-2 FFT'),
             Item('adaptive', label='Adaptive MTM'),
         ),
                HGroup(Item('loglog', label='Log-Log'),
                       Item('avg_spec', label='Plot avg'),
                       Item('sem', label='Use S.E.M.'),
                       Item('new_figure', label='Plot in new figure')),
                HGroup(
                    UItem('plot'),
                    Item('label', label='Plot label', width=15),
                    Item('_bandwidth',
                         label='BW (Hz)',
                         style='readonly',
                         width=4),
                ),
                label='Spectrum plotting'))
     return v
コード例 #16
0
ファイル: depth.py プロジェクト: zijuzhang/chaco
class MyPlot(HasTraits):
    """ Plot where depth is the index such that the plot is vertical
        and the origin is the upper left
    """
    plot = Instance(ToolbarPlot)

    traits_view = View(UItem('plot', editor=ComponentEditor()),
                       width=600, height=600, resizable=True
                      )

    def __init__(self, depth, data_series, **kw):
        super(MyPlot, self).__init__(**kw)

        plot_data = ArrayPlotData(index=depth)
        plot_data.set_data('data_series', data_series)
        self.plot = ToolbarPlot(plot_data, orientation='v', origin='top left')
        line = self.plot.plot(('index', 'data_series'))[0]

        line_inspector = LineInspector(component=line, write_metadata=True)
        line.tools.append(line_inspector)
        line.overlays.append(line_inspector)
コード例 #17
0
    def check_checklist_mappings_value_change(self, style):
        check_list_editor_factory = CheckListEditor(
            values=["one", "two"],
            format_func=lambda v: v.upper(),
        )
        formatted_view = View(
            UItem(
                "value",
                editor=check_list_editor_factory,
                style=style,
            ))
        model = ListModel()

        with reraise_exceptions(), \
                self.setup_ui(model, formatted_view) as editor:

            self.assertEqual(editor.names, ["ONE", "TWO"])

            check_list_editor_factory.values = ["two", "one"]

            self.assertEqual(editor.names, ["TWO", "ONE"])
コード例 #18
0
ファイル: wait_control.py プロジェクト: sgallet/pychron
 def traits_view(self):
     v = View(
         VGroup(
             CustomLabel('message',
                         size=14,
                         weight='bold',
                         color_name='message_color'),
             HGroup(Spring(width=-5, springy=False),
                    Item('high', label='Set Max. Seconds'), spring,
                    UItem('continue_button')),
             HGroup(
                 Spring(width=-5, springy=False),
                 Item('current_time',
                      show_label=False,
                      editor=RangeEditor(
                          mode='slider',
                          low_name='low_name',
                          high_name='wtime',
                      ))),
         ), )
     return v
コード例 #19
0
 def traits_view(self):
     agrp = HGroup(
         Item('principal_investigator',
              label='PI',
              editor=EnumEditor(name='principal_investigators')),
         Item('project',
              label='Project',
              editor=ComboboxEditor(name='projects')),
         Item('sample',
              label='Sample',
              editor=ComboboxEditor(name='samples')))
     bgrp = VGroup(
         UItem('sessions',
               editor=TabularEditor(adapter=SessionAdapter(),
                                    selected='session')))
     v = View(VGroup(agrp, bgrp),
              buttons=['OK', 'Cancel'],
              kind='livemodal',
              resizable=True,
              title='Locate Sample')
     return v
コード例 #20
0
    def traits_view(self):
        cols = [
            ObjectColumn(name='queue_name', editable=False),
            ObjectColumn(name='identifier', editable=False),
            ObjectColumn(name='position', editable=False),
            ObjectColumn(
                name='repository_identifier',
                label='Assigned Repository',
                tooltip=
                'Repository assigned to this analysis in the Experiment Queue',
                editor=myEnumEditor(name='available_ids')),
            ObjectColumn(
                name='repository_ids',
                label='Existing Repositories',
                tooltip='Set of repositories that already contain this L#',
                editable=False)
        ]

        v = okcancel_view(UItem('conflicts', editor=TableEditor(columns=cols)),
                          title='Resolve Repository Conflicts')
        return v
コード例 #21
0
class ErrorDialogs(HasTraits):
    """Dialog to show errors"""

    error = Str()

    def open_error(self, msg):
        """Opens the dialog with the given message

        :param msg: Message
        :type msg: string
        """
        self.error = msg
        self.configure_traits(view="error_view", kind="livemodal")

    error_view = View(UItem('error', style='readonly'),
                      buttons=['OK'],
                      resizable=True,
                      width=300,
                      height=75,
                      title='Error',
                      icon=ImageResource("../icons/smrc_icon.png"))
コード例 #22
0
    def traits_view(self):
        # fill_grp = VGroup(HGroup(UItem('use_fill'),
        #                          UItem('color')),
        #                   Item('alpha', label='Opacity'),
        #                   label='Fill',
        #                   show_border=True)

        line_grp = VGroup(UItem('line_color'),
                          # Item('line_width',
                          #      label='Width'),
                          show_border=True,
                          label='Line')

        # g = VGroup(Item('bind_colors', label='Bind Colors',
        #                 tooltip='Bind the Fill and Line colors, i.e changing the Fill color changes'
        #                         'the line color and vice versa'),
        #            HGroup(fill_grp, line_grp),
        #            show_border=True,
        #            label='Group {}'.format(self.group_id + 1))
        v = View(line_grp)
        return v
コード例 #23
0
    def check_range_enum_editor_format_func(self, style):
        # RangeEditor with enum mode doesn't support format_func
        obj = RangeModel()
        view = View(
            UItem(
                "value",
                editor=RangeEditor(low=1,
                                   high=3,
                                   format_func=lambda v: "{:02d}".format(v),
                                   mode="enum"),
                style=style,
            ))

        tester = UITester()
        with tester.create_ui(obj, dict(view=view)) as ui:
            editor = ui.get_editors("value")[0]

            # No formatting - simple strings
            self.assertEqual(editor.names[:3], ["1", "2", "3"])
            self.assertEqual(editor.mapping, {"1": 1, "2": 2, "3": 3})
            self.assertEqual(editor.inverse_mapping, {1: "1", 2: "2", 3: "3"})
コード例 #24
0
ファイル: sample_entry.py プロジェクト: ael-noblegas/pychron
    def _configure_sample_button_fired(self):
        v = okcancel_view(VGroup(HGroup(icon_button_editor('clear_sample_attributes_button', 'clear')),
                                 VGroup(UItem('sample'),
                                        label='Name', show_border=True),
                                 VGroup(Item('lat', label='Latitude'),
                                        Item('lon', label='Longitude'),
                                        Item('location'),
                                        Item('elevation'),
                                        label='Location', show_border=True),
                                 VGroup(Item('lithology', editor=EnumEditor(name='lithologies')),
                                        Item('lithology_class', label='Class',
                                             editor=EnumEditor(name='lithology_classes')),
                                        Item('lithology_group', label='Group',
                                             editor=EnumEditor(name='lithology_groups')),
                                        Item('lithology_type', label='Type', editor=EnumEditor(name='lithology_types')),

                                        Item('approximate_age', label='Approx. Age (Ma)'),
                                        Item('storage_location'),
                                        show_border=True)),
                          title='Set Sample Attributes')
        self.edit_traits(view=v)
コード例 #25
0
ファイル: panes.py プロジェクト: waffle-iron/pychron
    def traits_view(self):
        main_grp = self._get_browser_group()

        v = View(
            VGroup(
                HGroup(
                    # icon_button_editor('advanced_query', 'application_form_magnify',
                    # tooltip='Advanced Query'),
                    icon_button_editor(
                        'filter_by_button',
                        'find',
                        tooltip='Filter analyses using defined criteria'),
                    icon_button_editor(
                        'graphical_filter_button',
                        'chart_curve_go',
                        # enabled_when='samples',
                        tooltip='Filter analyses graphically'),
                    icon_button_editor(
                        'toggle_view',
                        'arrow_switch',
                        tooltip='Toggle between Sample and Time views'),
                    spring,
                    UItem('use_focus_switching',
                          tooltip='Show/Hide Filters on demand'),
                    Spring(springy=False, width=10),
                    icon_button_editor(
                        'toggle_focus',
                        'arrow_switch',
                        enabled_when='use_focus_switching',
                        tooltip='Toggle Filter and Result focus'),
                    spring,
                    # UItem('current_task_name', style='readonly'),
                    CustomLabel('datasource_url', color='maroon'),
                ),
                main_grp),
            # handler=TablesHandler()
            # handler=UnselectTabularEditorHandler(selected_name='selected_projects')
        )

        return v
コード例 #26
0
 def traits_view(self):
     v = okcancel_view(
         BorderHGroup(UItem('delayed_start_enabled'),
                      UItem('start_date',
                            enabled_when='delayed_start_enabled'),
                      UItem('start_time',
                            enabled_when='delayed_start_enabled'),
                      label='Start'),
         BorderHGroup(UItem('scheduled_stop_enabled'),
                      UItem('stop_date',
                            enabled_when='scheduled_stop_enabled'),
                      UItem('stop_time',
                            enabled_when='scheduled_stop_enabled'),
                      label='Stop'),
         title='Configure Scheduler')
     return v
コード例 #27
0
    def check_enum_mappings_value_change(self, style):

        image_enum_editor_factory = ImageEnumEditor(
            values=['top left', 'top right'],
            format_func=lambda v: v.upper(),
            prefix='@icons:',
            suffix='_origin',
            path='dummy_path',
        )
        formatted_view = View(
            UItem(
                "value",
                editor=image_enum_editor_factory,
                style=style,
            ))

        with reraise_exceptions(), \
                self.setup_ui(EnumModel(), formatted_view) as editor:

            self.assertEqual(editor.names, ["TOP LEFT", "TOP RIGHT"])
            self.assertEqual(editor.mapping, {
                "TOP LEFT": "top left",
                "TOP RIGHT": "top right"
            })
            self.assertEqual(editor.inverse_mapping, {
                "top left": "TOP LEFT",
                "top right": "TOP RIGHT"
            })

            image_enum_editor_factory.values = ["top right", "top left"]

            self.assertEqual(editor.names, ["TOP RIGHT", "TOP LEFT"])
            self.assertEqual(editor.mapping, {
                "TOP RIGHT": "top right",
                "TOP LEFT": "top left"
            })
            self.assertEqual(editor.inverse_mapping, {
                "top right": "TOP RIGHT",
                "top left": "TOP LEFT"
            })
コード例 #28
0
        def traits_view(self):
            default_state_grp = VGroup(UItem('default_state_button'))

            action_grp = VGroup(default_state_grp,
                                HGroup(UItem('add_sleep_button', width=-60),
                                       UItem('duration')),
                                HGroup(UItem('add_info_button', width=-60),
                                       UItem('info_str')),
                                HGroup(Item('record_valve_actions',
                                            tooltip='Should valve actuations be added to the action list. '
                                                    'You can also hold down the "Shift" key to suppress addition',
                                            label='Record Actions')),
                                UItem('actions', editor=TabularEditor(adapter=ActionsAdapter(),
                                                                      operations=['move', 'delete'],
                                                                      selected='selected',
                                                                      refresh='refresh_needed',
                                                                      multi_select=True)))

            canvas_group = HGroup(
                UItem('canvas', style='custom',
                      editor=ComponentEditor()),
                label='Canvas')

            script_group = VGroup(UItem('script_text',
                                        editor=PyScriptCodeEditor(),
                                        style='custom'),
                                  label='script')

            tgrp = Group(canvas_group, script_group, layout='tabbed')

            v = View(
                # tgrp,
                HGroup(action_grp, tgrp),
                buttons=['OK', Action(action='save', name='Save')],
                resizable=True,
                width=900, height=700)
            return v
コード例 #29
0
 def test_list_enum_none_selected(self):
     enum_edit = EnumModelWithNone()
     view = View(
         UItem(
             "value",
             editor=EnumEditor(
                 # Note that for the list style editor, in order to select
                 # None, it must be one of the displayed options
                 values=[None, "one", "two", "three", "four"],
                 mode="list",
             ),
             style="custom",
         ),
         resizable=True,
     )
     tester = UITester()
     with tester.create_ui(enum_edit, dict(view=view)) as ui:
         self.assertEqual(enum_edit.value, None)
         list_editor = tester.find_by_name(ui, "value")
         # As a result the displayed text is actually the string 'None'
         displayed = list_editor.inspect(SelectedText())
         self.assertEqual(displayed, 'None')
コード例 #30
0
ファイル: settings_view.py プロジェクト: fnoble/piksi_tools
class EnumSetting(Setting):
    values = List()
    traits_view = View(
        VGroup(
            Item('full_name', label='Name', style='readonly'),
            Item('value', editor=EnumEditor(name='values')),
            Item('description', style='readonly'),
            Item('default_value', style='readonly'),
            UItem('notes',
                  label="Notes",
                  height=-1,
                  editor=MyTextEditor(TextEditor(multi_line=True)),
                  style='readonly',
                  show_label=True,
                  resizable=True),
            show_border=True,
            label='Setting',
        ), )

    def __init__(self, name, section, value, ordering, values, **kwargs):
        self.values = values
        Setting.__init__(self, name, section, value, ordering, **kwargs)