Ejemplo n.º 1
0
 def default_traits_view(self):
     return View(
         VGroup(Item('controls_list',
                     editor=ListEditor(editor=InstanceEditor(
                         view=self.control_traits_view()),
                                       style='custom',
                                       mutable=False),
                     style='custom'),
                Item('handler.add_control',
                     editor=ButtonEditor(value=True,
                                         label="Add a control")),
                Item('handler.remove_control',
                     editor=ButtonEditor(value=True,
                                         label="Remove a control")),
                label="Controls",
                show_labels=False),
         VGroup(Item(
             'subset_dict',
             show_label=False,
             editor=SubsetEditor(
                 conditions="context.previous.conditions",
                 metadata="context.previous.metadata",
                 when="'experiment' not in vars() or not experiment")),
                label="Subset",
                show_border=False,
                show_labels=False), Heading("WARNING: Very slow!"),
         Heading("Give it a few minutes..."),
         Item('context.do_estimate',
              editor=ButtonEditor(value=True, label="Estimate!"),
              show_label=False), shared_op_traits)
Ejemplo n.º 2
0
 def traits_view(self):
     v = View(
         VGroup(
             #                       Item('show_scene_viewer', show_label=False),
             Item('position_entry',
                  label='Position'),  # @todo: move to stage manager
             Item('mode')),
         HGroup(
             Item('show_hide',
                  show_label=False,
                  editor=ButtonEditor(label_value='show_hide_label')),
             Item('program_points',
                  show_label=False,
                  editor=ButtonEditor(label_value='program_points_label')),
         ),
         Item('maker',
              style='custom',
              enabled_when='is_programming',
              show_label=False),
         HGroup(Item('load_points', show_label=False),
                Item('save_points', show_label=False)),
         #                                 HGroup(Item('clear'), Item('clear_mode'), show_labels=False),
         #                                 Item('finish', show_label=False, enabled_when='mode=="line" and object.is_programming'),
         #                                 enabled_when='object.is_programming'
         #                                 ),
         #                     label='Points'
         #                             )
         #                      )
     )
     return v
Ejemplo n.º 3
0
class PCAHandler(OpHandler):

    add_channel = Event
    remove_channel = Event
    channels = Property(List(Str), observe='context.channels')

    operation_traits_view = \
        View(Item('name',
                  editor = TextEditor(auto_set = False, placeholder = "None")),
             VGroup(Item('channels_list',
                         editor = VerticalListEditor(editor = InstanceHandlerEditor(view = 'channel_view',
                                                                                    handler_factory = ChannelHandler),
                                                     style = 'custom',
                                                     mutable = False),
                         style = 'custom'),
             Item('handler.add_channel',
                  editor = ButtonEditor(value = True,
                                        label = "Add a channel"),
                  show_label = False),
             Item('handler.remove_channel',
                  editor = ButtonEditor(value = True,
                                        label = "Remove a channel")),
             show_labels = False),
             VGroup(Item('num_components',
                         editor = TextEditor(auto_set = False),
                         label = "Num\nComponents"),
                    Item('whiten'),
                    Item('by',
                         editor = CheckListEditor(cols = 2,
                                                  name = 'context_handler.previous_conditions_names'),
                         label = 'Group\nEstimates\nBy',
                         style = 'custom'),
                    label = "Estimate parameters"),
             VGroup(Item('subset_list',
                         show_label = False,
                         editor = SubsetListEditor(conditions = "context_handler.previous_conditions",
                                                   editor = InstanceHandlerEditor(view = 'subset_view',
                                                                                  handler_factory = subset_handler_factory))),
                    label = "Subset",
                    show_border = False,
                    show_labels = False),
             Item('do_estimate',
                  editor = ButtonEditor(value = True,
                                        label = "Estimate!"),
                  show_label = False),
             shared_op_traits_view)

    # MAGIC: called when add_channel is set
    def _add_channel_fired(self):
        self.model.channels_list.append(PCAChannel())

    def _remove_channel_fired(self):
        if self.model.channels_list:
            self.model.channels_list.pop()

    def _get_channels(self):
        if self.context and self.context.channels:
            return natsorted(self.context.channels)
        else:
            return []
Ejemplo n.º 4
0
 def default_traits_view(self):
     return View(
         VGroup(
             Item('beads_name',
                  editor=EnumEditor(name='handler.beads_name_choices'),
                  label="Beads",
                  width=-125), Item('beads_file', width=-125)),
         VGroup(Item('units_list',
                     editor=VerticalListEditor(editor=InstanceEditor(
                         view=self.unit_traits_view()),
                                               style='custom',
                                               mutable=False),
                     style='custom'),
                Item('handler.add_channel',
                     editor=ButtonEditor(value=True,
                                         label="Add a channel")),
                Item('handler.remove_channel',
                     editor=ButtonEditor(value=True,
                                         label="Remove a channel")),
                label="Controls",
                show_labels=False),
         Item('bead_peak_quantile', label="Peak\nQuantile"),
         Item('bead_brightness_threshold', label="Peak\nThreshold "),
         Item('bead_brightness_cutoff', label="Peak\nCutoff"),
         Item('do_estimate',
              editor=ButtonEditor(value=True, label="Estimate!"),
              show_label=False), shared_op_traits)
Ejemplo n.º 5
0
 def default_traits_view(self):
     return View(VGroup(Item('controls_list',
                             editor = VerticalListEditor(editor = InstanceEditor(view = self.control_traits_view()),
                                                         style = 'custom',
                                                         mutable = False),
                             style = 'custom'),
                 Item('handler.add_control',
                      editor = ButtonEditor(value = True,
                                            label = "Add a control")),
                 Item('handler.remove_control',
                      editor = ButtonEditor(value = True,
                                            label = "Remove a control")),
                 label = "Controls",
                 show_labels = False),
                 Item('mixture_model',
                      label = "Use mixture\nmodel?"),
                 VGroup(Item('subset_list',
                             show_label = False,
                             editor = SubsetListEditor(conditions = "context.previous_wi.conditions",
                                                       metadata = "context.previous_wi.metadata",
                                                       when = "'experiment' not in vars() or not experiment")),
                        label = "Subset",
                        show_border = False,
                        show_labels = False),
                 Item('do_estimate',
                      editor = ButtonEditor(value = True,
                                            label = "Estimate!"),
                      show_label = False),
                 shared_op_traits)
    def _get_decay_group(self):
        presets = HGroup(
            Item('decay_constant_name',
                 editor=EnumEditor(name='decay_constant_names')),
            UItem('add_decay_constant',
                  tooltip='add decay constant entry',
                  style='custom',
                  editor=ButtonEditor(image=icon('add'))),
            UItem('delete_decay_constant',
                  tooltip='delete current constant entry',
                  enabled_when='decay_constant_entry_deletable',
                  style='custom',
                  editor=ButtonEditor(image=icon('delete'))))

        vs = [('Ar40K epsilon/yr', 'lambda_e', 'lambda_e_error'),
              ('Ar40K beta/yr', 'lambda_b', 'lambda_b_error'),
              ('Cl36/d', 'lambda_Cl36', 'lambda_Cl36_error'),
              ('Ar37/d', 'lambda_Ar37', 'lambda_Ar37_error'),
              ('Ar39/d', 'lambda_Ar39', 'lambda_Ar39_error')]
        items = [
            HGroup(Label(l), spring, UItem(v), UItem(e)) for l, v, e in vs
        ]
        decay = VGroup(presets,
                       HGroup(
                           Item('total_k_decay',
                                style='readonly',
                                label='Total Ar40K/yr')),
                       HGroup(spring, Label('Value'),
                              Spring(width=75, springy=False),
                              Label(PLUSMINUS_ONE_SIGMA),
                              Spring(width=75, springy=False)),
                       *items,
                       show_border=True,
                       label='Decay')
        return decay
    def _get_decay_group(self):
        presets = HGroup(Item('decay_constant_name', editor=EnumEditor(name='decay_constant_names')),
                         UItem('add_decay_constant',
                               tooltip='add decay constant entry',
                               style='custom',
                               editor=ButtonEditor(image=icon('add'))),
                         UItem('delete_decay_constant',
                               tooltip='delete current constant entry',
                               enabled_when='decay_constant_entry_deletable',
                               style='custom',
                               editor=ButtonEditor(image=icon('delete'))))

        vs = [
            ('Ar40K epsilon/yr', 'lambda_e', 'lambda_e_error'),
            ('Ar40K beta/yr', 'lambda_b', 'lambda_b_error'),
            ('Cl36/d', 'lambda_cl36', 'lambda_cl36_error'),
            ('Ar37/d', 'lambda_ar37', 'lambda_ar37_error'),
            ('Ar39/d', 'lambda_ar39', 'lambda_ar39_error')]
        items = [HGroup(Label(l), spring, UItem(v), UItem(e)) for l, v, e in vs]

        items.append(Item('use_irradiation_endtime', label='Use Irradiation End time',
                          tooltip='Use irradiation end time for decay calculations instead of the start time. '
                                  'FYI Mass Spec and NMGRL by default use the start time. '
                                  'McDougall and Harrison 1999 and ArArCalc use the end time.'))
        decay = VGroup(
            presets,
            HGroup(Item('total_k_decay', style='readonly', label='Total Ar40K/yr')),
            HGroup(spring, Label('Value'),
                   Spring(width=75, springy=False),
                   Label(PLUSMINUS_ONE_SIGMA),
                   Spring(width=75, springy=False)),
            *items,
            show_border=True,
            label='Decay')
        return decay
 def _get_ratio_group(self):
     presets = HGroup(Item('atm_constant_name', editor=EnumEditor(name='atm_constant_names')),
                      UItem('add_atm_constant',
                            tooltip='add atm constant entry',
                            style='custom',
                            editor=ButtonEditor(image=icon('add'))),
                      UItem('delete_atm_constant',
                            tooltip='delete current constant entry',
                            enabled_when='atm_constant_entry_deletable',
                            style='custom',
                            editor=ButtonEditor(image=icon('delete'))))
     ratios = VGroup(
         presets,
         HGroup(Spring(springy=False, width=125),
                Label('Value'),
                Spring(springy=False, width=55),
                Label(PLUSMINUS_ONE_SIGMA),
                Spring(springy=False, width=55),
                Label('Citation')),
         HGroup(Item('ar40_ar36_atm', label='(40Ar/36Ar)atm'),
                Item('ar40_ar36_atm_error', show_label=False),
                Item('ar40_ar36_atm_citation', show_label=False),
                enabled_when='atm_constant_entry_deletable'),
         HGroup(Item('ar40_ar38_atm', label='(40Ar/38Ar)atm'),
                Item('ar40_ar38_atm_error', show_label=False),
                Item('ar40_ar38_atm_citation', show_label=False),
                enabled_when='atm_constant_entry_deletable'),
         Item('_'),
         HGroup(
             Item('ar37_ar39_mode', label='(37Ar/39Ar)K'),
             Item('ar37_ar39', show_label=False, enabled_when='ar37_ar39_mode=="Fixed"'),
             Item('ar37_ar39_error', show_label=False, enabled_when='ar37_ar39_mode=="Fixed"')),
         label='Ratios')
     return ratios
Ejemplo n.º 9
0
    def traits_view(self):
        pos_grp = VGroup(
            UItem('move_enabled_button'),
            VGroup(HGroup(
                Item('position'),
                UItem('object.stage_manager.stage_map_name',
                      editor=EnumEditor(
                          name='object.stage_manager.stage_map_names')),
                UItem('stage_stop_button')),
                   Item('x', editor=RangeEditor(low=-25.0, high=25.0)),
                   Item('y', editor=RangeEditor(low=-25.0, high=25.0)),
                   Item('z', editor=RangeEditor(low=-25.0, high=25.0)),
                   enabled_when='_move_enabled'),
            label='Positioning')

        calibration_grp = VGroup(
            UItem('tray_calibration.style',
                  enabled_when='not tray_calibration.isCalibrating()'),
            UItem('tray_calibration.calibrate',
                  editor=ButtonEditor(
                      label_value='tray_calibration.calibration_step')),
            HGroup(
                Item('tray_calibration.x',
                     format_str='%0.3f',
                     style='readonly'),
                Item('tray_calibration.y',
                     format_str='%0.3f',
                     style='readonly')),
            Item('tray_calibration.rotation',
                 format_str='%0.3f',
                 style='readonly'),
            Item('tray_calibration.scale',
                 format_str='%0.4f',
                 style='readonly'),
            Item('tray_calibration.error',
                 format_str='%0.2f',
                 style='readonly'),
            UItem('tray_calibration.calibrator',
                  style='custom',
                  editor=InstanceEditor()),
            CustomLabel('tray_calibration.calibration_help',
                        color='green',
                        height=75,
                        width=300),
            label='Tray Calibration')

        tgrp = Group(pos_grp, calibration_grp, layout='tabbed')

        egrp = HGroup(
            UItem('enabled_led', editor=LEDEditor()),
            UItem('enable', editor=ButtonEditor(label_value='enable_label')),
            UItem('fire_laser_button', enabled_when='enabled'),
            Item('output_power', label='Power'), UItem('units'), spring,
            icon_button_editor('snapshot_button', 'camera'),
            icon_button_editor('test_connection_button',
                               'connect',
                               tooltip='Test Connection'))
        v = View(VGroup(egrp, tgrp))
        return v
Ejemplo n.º 10
0
 def traits_view(self):
     return View(
         Item('name'),
         Item('valve_button',
              label='Valve',
              editor=ButtonEditor(label_value='valve_label')),
         Item('pump_button',
              label='Pump',
              editor=ButtonEditor(label_value='pump_label')))
Ejemplo n.º 11
0
 def default_traits_view(self):
     return View(
         VGroup(Item('channels_list',
                     editor=VerticalListEditor(editor=InstanceEditor(
                         view=self.channel_traits_view()),
                                               style='custom',
                                               mutable=False),
                     style='custom'),
                Item('handler.add_channel',
                     editor=ButtonEditor(value=True,
                                         label="Add a channel")),
                Item('handler.remove_channel',
                     editor=ButtonEditor(value=True,
                                         label="Remove a channel")),
                show_labels=False),
         VGroup(Item('xfacet',
                     editor=ExtendableEnumEditor(
                         name='handler.conditions_names',
                         extra_items={"None": ""}),
                     label="Horizontal\nFacet"),
                Item('yfacet',
                     editor=ExtendableEnumEditor(
                         name='handler.conditions_names',
                         extra_items={"None": ""}),
                     label="Vertical\nFacet"),
                Item('huefacet',
                     editor=ExtendableEnumEditor(
                         name='handler.conditions_names',
                         extra_items={"None": ""}),
                     label="Color\nFacet"),
                Item('huescale', label="Color\nScale"),
                Item('plotfacet',
                     editor=ExtendableEnumEditor(
                         name='handler.conditions_names',
                         extra_items={"None": ""}),
                     label="Tab\nFacet"),
                label="2D Histogram",
                show_border=False),
         VGroup(Item(
             'subset_list',
             show_label=False,
             editor=SubsetListEditor(conditions="context.conditions")),
                label="Subset",
                show_border=False,
                show_labels=False),
         Item('context.view_warning',
              resizable=True,
              visible_when='context.view_warning',
              editor=ColorTextEditor(foreground_color="#000000",
                                     background_color="#ffff99")),
         Item('context.view_error',
              resizable=True,
              visible_when='context.view_error',
              editor=ColorTextEditor(foreground_color="#000000",
                                     background_color="#ff9191")))
Ejemplo n.º 12
0
 def default_traits_view(self):
     return View(
         Item('width', editor=TextEditor(auto_set=False)),
         Item('height', editor=TextEditor(auto_set=False)),
         Item('dpi', editor=TextEditor(auto_set=False)),
         Item('do_export',
              editor=ButtonEditor(value=True, label="Export figure..."),
              show_label=False),
         Item('do_exit',
              editor=ButtonEditor(value=True, label="Return to Cytoflow"),
              show_label=False))
Ejemplo n.º 13
0
class BleedthroughLinearHandler(OpHandler):
    add_control = Event
    remove_control = Event

    channels = Property(List(Str), observe='context.channels')

    operation_traits_view = \
        View(VGroup(
             Item('controls_list',
                  editor = VerticalListEditor(editor = InstanceHandlerEditor(view = 'control_view',
                                                                             handler_factory = ControlHandler),
                                              style = 'custom',
                                              mutable = False),
                  style = 'custom'),
             Item('handler.add_control',
                  editor = ButtonEditor(value = True,
                                        label = "Add a control")),
             Item('handler.remove_control',
                  editor = ButtonEditor(value = True,
                                        label = "Remove a control")),
             label = "Controls",
             show_labels = False),
             VGroup(Item('subset_list',
                         show_label = False,
                         editor = SubsetListEditor(conditions = "context_handler.previous_conditions",
                                                   editor = InstanceHandlerEditor(view = 'subset_view',
                                                                                  handler_factory = subset_handler_factory))),
                    label = "Subset",
                    show_border = False,
                    show_labels = False),
             Item('do_estimate',
                  editor = ButtonEditor(value = True,
                                        label = "Estimate!"),
                  show_label = False),
             shared_op_traits_view)

    # MAGIC: called when add_control is set
    def _add_control_fired(self):
        self.model.controls_list.append(BleedthroughControl())

    # MAGIC: called when remove_control is set
    def _remove_control_fired(self):
        if self.model.controls_list:
            self.model.controls_list.pop()

    # MAGIC: returns the value of the 'channels' property
    def _get_channels(self):
        if self.context and self.context.channels:
            return natsorted(self.context.channels)
        else:
            return []
Ejemplo n.º 14
0
 def default_traits_view(self):
     return View(
         Item('name', editor=TextEditor(auto_set=False)),
         Item('channel',
              editor=EnumEditor(name='context.previous.channels'),
              label="Channel"), Item('scale'),
         VGroup(Item('num_components',
                     editor=TextEditor(auto_set=False),
                     label="Num\nComponents"),
                Item('sigma', editor=TextEditor(auto_set=False)),
                Item('by',
                     editor=CheckListEditor(
                         cols=2, name='context.previous.conditions_names'),
                     label='Group\nEstimates\nBy',
                     style='custom'),
                VGroup(Item('subset_dict',
                            show_label=False,
                            editor=SubsetEditor(
                                conditions="context.previous.conditions")),
                       label="Subset",
                       show_border=False,
                       show_labels=False),
                Item('context.do_estimate',
                     editor=ButtonEditor(value=True, label="Estimate!"),
                     show_label=False),
                label="Estimation parameters",
                show_border=False), shared_op_traits)
class TimeSerieGenerator(HasTraits):
    """ Very basic time serie generator. """

    code = Str('Dataset1')
    from_date = Date(today - datetime.timedelta(days=365))
    to_date = Date(today)
    generate = Event

    timestamps = Property(depends_on='from_date,to_date')
    data = Property(depends_on='dates,generate')

    @cached_property
    def _get_data(self):
        days = (self.to_date - self.from_date).days
        results = np.cumprod(np.random.lognormal(0.0, 0.04, size=days))
        return results

    @cached_property
    def _get_timestamps(self):
        # horry gorry conversion
        days = np.arange(self.from_date, self.to_date, dtype='datetime64[D]')
        seconds = days.astype('datetime64[s]')
        timestamps = seconds.astype(int)
        return timestamps

    ### Traits UI view #########################################################

    traits_view = View(VGroup(
        HGroup('code'), HGroup('from_date', 'to_date'),
        HGroup(Spring(),
               Item('generate', editor=ButtonEditor(), show_label=False))),
                       title='Generator',
                       width=200,
                       resizable=True)
Ejemplo n.º 16
0
    def traits_view(self):
        v = View(
                 Item('_cdevice', style='custom', show_label=False),
                 Item('scan_button', show_label=False, editor=ButtonEditor(label_value='scan_label')),
                 Item('graph', show_label=False, style='custom'))

        return v
Ejemplo n.º 17
0
    def traits_view(self):
        led_grp = HGroup(
            UItem('enabled',
                  editor=LEDEditor(colors=['red', 'green']),
                  style='custom',
                  height=-35),
            UItem('enable', editor=ButtonEditor(label_value='enable_label')))

        status_grp = HGroup(
            spring,
            CustomLabel(
                'status_text',
                weight='bold',
                use_color_background=False,
                # bgcolor='transparent',
                color='orange',
                size=40),
            spring)
        request_grp = HGroup(
            Item('requested_power',
                 style='readonly',
                 format_str='%0.2f',
                 width=100), Spring(springy=False, width=50),
            UItem('units', style='readonly'), spring)

        v = View(
            VGroup(led_grp,
                   spring,
                   status_grp,
                   spring,
                   request_grp,
                   show_border=True))
        return v
Ejemplo n.º 18
0
    def traits_view(self):
        agrp = VGroup(
            HGroup(
                Item('power', tooltip='Hit Enter for change to take effect'),
                Item('units', style='readonly', show_label=False), spring,
                Item('duration',
                     label='Duration (s)',
                     tooltip='Set the laser pulse duration in seconds'),
                Item('pulse_button',
                     editor=ButtonEditor(label_value='pulse_label'),
                     show_label=False,
                     enabled_when='enabled')))
        mgrp = VGroup(
            HGroup(Spring(width=-5, springy=False),
                   Item('object.wait_control.high', label='Set Max. Seconds'),
                   spring, UItem('object.wait_control.continue_button')),
            HGroup(
                Spring(width=-5, springy=False),
                Item(
                    'object.wait_control.current_time',
                    show_label=False,
                    editor=RangeEditor(
                        mode='slider',
                        low=1,
                        # low_name='low_name',
                        high_name='object.wait_control.duration')),
                CustomLabel('object.wait_control.current_time',
                            size=14,
                            weight='bold')),
            show_border=True)

        v = View(VGroup(agrp, mgrp, show_border=True),
                 id='pulse',
                 handler=PulseHandler())
        return v
Ejemplo n.º 19
0
    def _button_factory(self,
                        name,
                        label=None,
                        enabled=None,
                        align=None,
                        **kw):
        '''
            
        '''
        b = Item(name, show_label=False, **kw)

        if label is None:
            label = '{}_label'.format(name)

        if label is not None:
            b.editor = ButtonEditor(label_value=label)

        if enabled is not None:
            b.enabled_when = enabled

        if align is not None:
            if align == 'right':
                b = HGroup(spring, b)
            elif align == 'center':
                b = HGroup(spring, b, spring)
            else:
                b = HGroup(b, spring)

        return b
Ejemplo n.º 20
0
    def default_traits_view(self):
        return View(Item("channels",
                         editor = CheckListEditor(cols = 2,
                                                  name = 'context.previous_wi.channels'),
                         style = 'custom'),
                    VGroup(
                        Item('blank_file'),
                        label = "Autofluorescence"),
                    VGroup(
                        Item('bleedthrough_list',
                                editor = VerticalListEditor(editor = InstanceEditor(view = self.bleedthrough_traits_view()),
                                                            style = 'custom',
                                                            mutable = False),
                                style = 'custom'),
                        label = "Bleedthrough Correction",
                        show_border = False,
                        show_labels = False),
                    VGroup(
                        Item('beads_name',
                             editor = EnumEditor(name = 'handler.beads_name_choices'),
                             label = "Beads",
                             width = -125),
                        Item('beads_file'),
                        Item('beads_unit', 
                             editor = EnumEditor(name = 'handler.beads_units')),
                        Item('bead_peak_quantile',
                             label = "Peak\nQuantile"),
                        Item('bead_brightness_threshold',
                             label = "Peak\nThreshold "),
                        Item('bead_brightness_cutoff',
                             label = "Peak\nCutoff"),
                        label = "Bead Calibration",
                        show_border = False),
                    VGroup(
                        Item('to_channel',
                             editor = EnumEditor(name = 'channels')),
                        Item('mixture_model',
                             label = "Use mixture\nmodel?"),
                           label = "Color Translation"),
                    VGroup(
                        Item('translation_list',
                                editor = VerticalListEditor(editor = InstanceEditor(view = self.translation_traits_view()),
                                                            style = 'custom',
                                                            mutable = False),
                                style = 'custom'),

                        show_labels = False),
                    VGroup(Item('subset_list',
                                show_label = False,
                                editor = SubsetListEditor(conditions = "context.previous_wi.conditions",
                                                      metadata = "context.previous_wi.metadata",
                                                      when = "'experiment' not in vars() or not experiment")),
                           label = "Subset",
                           show_border = False,
                           show_labels = False),
                    Item('do_estimate',
                         editor = ButtonEditor(value = True,
                                               label = "Estimate!"),
                         show_label = False),
                    shared_op_traits)
Ejemplo n.º 21
0
 def get_control_group(self):
     cg = Group(
         HGroup(
             UItem('pointer',
                   editor=ButtonEditor(label_value='pointer_label')),
             Item('time_constant',
                  editor=EnumEditor(values=TIME_CONSTANTS)),
             spring,
         ),
         HGroup(
             Item('temperature',
                  width=50,
                  format_str='%0.1f',
                  style='readonly'),
             Item('temperature',
                  width=-150,
                  show_label=False,
                  editor=BarGaugeEditor(low=300,
                                        high=1500,
                                        colormap='hot',
                                        scale='linear',
                                        width=100))),
         Item('emissivity',
              editor=RangeEditor(format='%0.1f',
                                 mode='slider',
                                 low_name='emmin',
                                 high_name='emmax')))
     return cg
Ejemplo n.º 22
0
    def check_button_disabled(self, style):
        button_text_edit = ButtonTextEdit(button_enabled=False, )

        view = View(
            Item(
                "play_button",
                editor=ButtonEditor(),
                enabled_when="button_enabled",
                style=style,
            ), )
        tester = UITester()
        with tester.create_ui(button_text_edit, dict(view=view)) as ui:
            button = tester.find_by_name(ui, "play_button")
            self.assertFalse(button.inspect(IsEnabled()))

            with self.assertTraitDoesNotChange(button_text_edit,
                                               "play_button"):
                button.perform(MouseClick())

            button_text_edit.button_enabled = True
            self.assertTrue(button.inspect(IsEnabled()))
            with self.assertTraitChanges(button_text_edit,
                                         "play_button",
                                         count=1):
                button.perform(MouseClick())
Ejemplo n.º 23
0
class ButtonEditorDemo(HasTraits):
    my_button = Button()

    my_button_label = Str("Initial Label")

    my_button_image = Image()

    my_button_image_options = List(Image(),
                                   value=[
                                       ImageResource("run", [traitsui.extras]),
                                       ImageResource("previous",
                                                     [traitsui.extras]),
                                       ImageResource("next",
                                                     [traitsui.extras]),
                                       ImageResource("parent",
                                                     [traitsui.extras]),
                                       ImageResource("reload",
                                                     [traitsui.extras])
                                   ])

    def _my_button_image_default(self):
        return self.my_button_image_options[0]

    traits_view = View(
        Item("my_button",
             style="custom",
             editor=ButtonEditor(label_value="my_button_label",
                                 image_value="my_button_image",
                                 orientation="horizontal")),
        Item("my_button_label"),
        Item("my_button_image",
             editor=InstanceEditor(name="my_button_image_options",
                                   adapter=ImageChoice),
             style="custom"))
Ejemplo n.º 24
0
    def traits_view(self):
        v = View(
                 VGroup(
                     Item('receive_data_stream', show_label=False),
                     Item('command'),
                     Item('response', show_label=False, style='custom',
                          width=-300
                          ),
                     Item('pcommand', editor=EnumEditor(name='object.sent_commands')),
                     Item('resend', show_label=False),

                     HGroup(Item('periodic',
                                 editor=ButtonEditor(label_value='periodic_label'),
                                 show_label=False), Item('period', show_label=False),
                                 Item('n_periods'),
                                 Item('periods_completed', show_label=False)
                            ),
                     HGroup(Item('calculated_duration', format_str='%0.3f', style='readonly'),
                            Item('time_remain', format_str='%0.3f', style='readonly'),
                            ),
                     Item('kind', show_label=False),
                     Item('port'),
                     Item('host')),

                 resizable=True
                 )
        return v
Ejemplo n.º 25
0
    def traits_view(self):
        '''
        '''
        cparams = VGroup(
            HGroup(
                Item('led', show_label=False, editor=LEDEditor()),
                Item('server_button',
                     show_label=False,
                     editor=ButtonEditor(label_value='server_label'),
                     enabled_when='_connected'),
            ),
            Item('host', visible_when='not _running'),
            Item('port', visible_when='not _running'),
            show_border=True,
            label='Connection',
        )
        stats = Group(Item('packets_received', style='readonly'),
                      Item('cur_rpacket', label='Received', style='readonly'),
                      Item('packets_sent', style='readonly'),
                      Item('cur_spacket', label='Sent', style='readonly'),
                      Item('repeater_fails', style='readonly'),
                      Item('run_time', style='readonly'),
                      show_border=True,
                      label='Statistics',
                      visible_when='_connected')

        buttons = HGroup(Item('save', show_label=False, enabled_when='_dirty'))
        v = View(
            VGroup(cparams, stats, buttons),
            handler=RCSHandler,
        )
        return v
Ejemplo n.º 26
0
 def default_traits_view(self):
     return View(
         Item('name', editor=TextEditor(auto_set=False)),
         Item('xchannel',
              editor=EnumEditor(name='context.previous_wi.channels'),
              label="X Channel"),
         Item('ychannel',
              editor=EnumEditor(name='context.previous_wi.channels'),
              label="Y Channel"), Item('xscale', label="X Scale"),
         Item('yscale', label="Y Scale"),
         VGroup(Item('num_clusters', editor=TextEditor(auto_set=False)),
                Item('by',
                     editor=CheckListEditor(
                         cols=2, name='handler.previous_conditions_names'),
                     label='Group\nEstimates\nBy',
                     style='custom'),
                VGroup(Item(
                    'subset_list',
                    show_label=False,
                    editor=SubsetListEditor(
                        conditions="context.previous_wi.conditions")),
                       label="Subset",
                       show_border=False,
                       show_labels=False),
                Item('do_estimate',
                     editor=ButtonEditor(value=True, label="Estimate!"),
                     show_label=False),
                label="Estimation parameters",
                show_border=False), shared_op_traits)
Ejemplo n.º 27
0
 def get_view(self, style):
     return View(
         Item(
             "play_button",
             editor=ButtonEditor(values_trait="values"),
             style=style,
         ), )
Ejemplo n.º 28
0
 def traits_view(self):
     v = View(
         VGroup(
             HGroup(
                 spring,
                 Item('clear_button',
                      show_label=False,
                      enabled_when='calculated'),
                 Item('execute_button',
                      editor=ButtonEditor(label_value='execute_label'),
                      show_label=False)),
             VGroup(
                 Item('result_endpoints',
                      style='readonly',
                      format_str='%0.3f',
                      label='Rise Rate endpoints (fA/min)'),
                 Item('result_fit',
                      style='readonly',
                      format_str='%0.3f',
                      label='Rise Rate linear fit  (fA/min)')),
             HGroup(UItem('clear_results_button')),
             UItem('results',
                   editor=myTabularEditor(operations=[],
                                          editable=False,
                                          adapter=ResultsAdapter()))))
     return v
Ejemplo n.º 29
0
 def _get_toggle_group(self):
     g = HGroup(
         UItem('show_all_button',
               editor=ButtonEditor(label_value='show_all_label')),
         UItem('filter_all_button'), UItem('inc_baseline_all_button'),
         UItem('use_all_button'))
     return g
Ejemplo n.º 30
0
    def traits_view(self):
        v = View(
            Group(Item('reference_detector',
                       editor=EnumEditor(name='detectors')),
                  Item('start_mass',
                       label='Start Mass',
                       tooltip='Start scan at this mass'),
                  Item('stop_mass',
                       label='Stop Mass',
                       tooltip='Stop scan when magnet reaches this mass'),
                  Item('step_mass',
                       label='Step Mass',
                       tooltip='Step from Start to Stop by this amount'),
                  Item('integration_time', label='Integration (s)'),
                  HGroup(
                      spring,
                      Item('execute_button',
                           editor=ButtonEditor(label_value='execute_label'),
                           show_label=False)),
                  label='Magnet Scan',
                  show_border=True))

        return v


#============= EOF =============================================