Esempio n. 1
0
    def traits_view(self):
        w_view = 350 if is_display_small() else 480

        parameters_group = VGroup(
            Item('_'),
            HGroup(
                VGroup(
                    Spring(),
                    Item('handler.omega_hinton_diagram',
                         style='custom',
                         resizable=False,
                         show_label=False,
                         width=w_view), Spring()), Spring(),
                VGroup(Spring(), Item('handler.view_omega', show_label=False),
                       Spring())), Spring(), Item('_'), Spring(),
            HGroup(
                VGroup(
                    UItem('handler.theta_views'),
                    UItem('handler.theta_view',
                          style='custom',
                          resizable=False,
                          width=w_view), Spring()), Spring(),
                VGroup(Spring(), UItem('handler.view_theta'), Spring())))

        body = VGroup(Include('info_group'), parameters_group)

        traits_view = View(body, buttons=[OKButton], resizable=True)
        return traits_view
Esempio n. 2
0
 def default_traits_view(self):
     view = View(
         Item('scene',
              editor=SceneEditor(scene_class=MayaviScene),
              height=600,
              width=600,
              show_label=False),
         HGroup(
             Item("current_time", label="Date"), Item(" "),
             Item("num_of_shown_days", label="Show"),
             Item("_home_button", show_label=False),
             Item("_selected_source_name", show_label=False),
             Item("_selected_event_name",
                  editor=CheckListEditor(name='_selected_events_list'),
                  show_label=False), Item("_back1", show_label=False),
             Item(
                 "Relative_Start_Day",
                 show_label=False,
                 editor=RangeEditor(mode="slider",
                                    low_name="_low_start_day_number",
                                    high_name="_high_start_day_number"),
                 tooltip=
                 "Shows total number of days in data set and the currently selected day",
                 springy=True,
                 full_size=True), Item("_forward1", show_label=False),
             Item("move_step", show_label=False),
             Item("play_button", label='Play')),
         title="Visualization of Events",
         resizable=True)
     view.resizable = True
     return view
class VisibleWhenProblem(HasTraits):

    which = Enum('one', 'two')

    on = Bool
    txt = Str

    onoff_group = HGroup(
        VGroup(Item('on', resizable=False, width=-100, height=-70),
               show_left=False,
               show_border=True,
               visible_when='which == "one"'), )

    text_group = VGroup(
        Item('txt', width=-_TEXT_WIDTH, height=-_TEXT_HEIGHT),
        visible_when='which == "two"',
        show_border=True,
    )

    traits_view = View(Item('which'),
                       VGroup(
                           Include('onoff_group'),
                           Include('text_group'),
                       ),
                       resizable=True,
                       buttons=['OK', 'Cancel'])
class VisibleWhenProblem(HasTraits):

    which = Enum("one", "two")

    on = Bool()
    txt = Str()

    onoff_group = HGroup(
        VGroup(
            Item("on", resizable=False, width=-100, height=-70),
            show_left=False,
            show_border=True,
            visible_when='which == "one"',
        )
    )

    text_group = VGroup(
        Item("txt", width=-_TEXT_WIDTH, height=-_TEXT_HEIGHT),
        visible_when='which == "two"',
        show_border=True,
    )

    traits_view = View(
        Item("which"),
        VGroup(Include("onoff_group"), Include("text_group")),
        resizable=True,
        buttons=["OK", "Cancel"],
    )
Esempio n. 5
0
    def traits_view(self):
        ident_grp = VGroup(Item('irradiation', editor=EnumEditor(name='irradiations')),
                           Item('level', editor=EnumEditor(name='levels')),
                           Item('identifier', editor=EnumEditor(name='identifiers')),
                           Item('aliquot_offset'),
                           Item('step_offset'),
                           Item('dry',
                                tooltip='Do a dry run. Do not save changes to database'),
                           Item('use_secondary', label='Use Secondary DB',
                                tooltip='Also modify the secondary db, e.g. a Mass Spec db.'))

        ogrp = UItem('analyses', editor=TabularEditor(adapter=AnalysisAdapter(),
                                                      editable=False))
        ngrp = UItem('modified_analyses', editor=TabularEditor(adapter=AnalysisAdapter(),
                                                               refresh='refresh',
                                                               multi_select=True,
                                                               selected='selected'))
        agrp = HGroup(ogrp, ngrp)
        v = View(VGroup(ident_grp, agrp),
                 resizable=True,
                 width=600,
                 kind='livemodal',
                 title='Edit Analyses',
                 buttons=['OK', 'Cancel'])
        return v
Esempio n. 6
0
class HResizeDialog(HasTraits):

    txt = Str('hallo')

    traits_view = View(HGroup(Item('txt', width=_TXT_WIDTH, resizable=True), ),
                       width=_DIALOG_WIDTH,
                       height=_DIALOG_HEIGHT,
                       resizable=True)
Esempio n. 7
0
 def traits_view(self):
     self.statistics_name = "Cohen's Kappa"
     traits_view = View(VGroup(
         HGroup(Item("statistics_name", show_label=False),
                Item("info_button", show_label=False)),
         Spring(),
         HGroup(
             Spring(),
             Item("stats_view",
                  style="custom",
                  show_label=False,
                  width=300,
                  resizable=False), Spring()),
     ),
                        width=400,
                        resizable=True)
     return traits_view
Esempio n. 8
0
 def _get_toggle_group(self):
     g = HGroup(
         # UItem('global_fit',editor=EnumEditor(name='fit_types')),
         # UItem('global_error_type', editor=EnumEditor(name='error_types')),
         UItem('show_all_button',
               editor=ButtonEditor(label_value='show_all_label')),
         UItem('use_all_button'))
     return g
Esempio n. 9
0
    def traits_view(self):
        v = View(
            HGroup(UItem('use'), Item('center'), Item('threshold'),
                   UItem('color')))
        return v


#============= EOF =============================================
Esempio n. 10
0
 def test_horizontal_layout(self):
     # layout
     view = View(HGroup(
         Item("txt1"),
         Item("txt2"),
     ))
     with reraise_exceptions(), \
             create_ui(MultipleTrait(), ui_kwargs=dict(view=view)):
         pass
Esempio n. 11
0
 def traits_view(self):
     contour_grp = VGroup(Item('color_map_name',
                               label='Color Map',
                               editor=EnumEditor(values=sorted(color_map_name_dict.keys()))),
                          Item('levels'),
                          visible_when='plot_kind=="Contour"')
     monitor_grp=Item('monitor', editor=EnumEditor(name='monitors'))
     v = View(
         VGroup(HGroup(UItem('calculate_button'),
                       UItem('data_source', editor=EnumEditor(values=['database', 'file'])),
                       monitor_grp),
                HGroup(Item('group_positions'), Item('object.monitor.sample', style='readonly',label='Sample')),
                HGroup(UItem('plot_kind'),
                       Item('model_kind', label='Fit Model',
                         editor=EnumEditor(values=['Bowl', 'Plane']))),
                       # UItem('plot_kind', editor=EnumEditor(values=['Contour', 'Hole vs J']))),
                contour_grp))
     return v
Esempio n. 12
0
class HResizeDialog(HasTraits):

    txt = Str("hallo")

    traits_view = View(
        HGroup(Item("txt", width=_TXT_WIDTH, resizable=True)),
        width=_DIALOG_WIDTH,
        height=_DIALOG_HEIGHT,
        resizable=True,
    )
Esempio n. 13
0
    def traits_view(self):
        l = VGroup(UItem('low_post_time'),
                   UItem('low_post_date', style='custom'))
        h = VGroup(UItem('high_post_time'),
                   UItem('high_post_date', style='custom'))

        v = okcancel_view(Item('pad', label='Pad (hrs)'),
                          HGroup(l, h),
                          width=500)
        return v
Esempio n. 14
0
 def traits_view(self):
     contour_grp = HGroup(Item('color_map_name',
                               label='Color Map',
                               editor=EnumEditor(values=sorted(color_map_name_dict.keys()))),
                          Item('levels'),
                          Item('marker_size'),
                          visible_when='plot_kind=="Contour"')
     monitor_grp = Item('monitor', editor=EnumEditor(name='monitors'))
     v = View(
         VGroup(HGroup(UItem('calculate_button'),
                       UItem('data_source', editor=EnumEditor(values=['database', 'file'])),
                       monitor_grp),
                HGroup(Item('save_mean_j', label='Save Mean J'),
                       Item('auto_clear_cache', label='Auto Clear Cache')),
                Item('mean_j_error_type', label='Mean J Error'),
                HGroup(Item('use_weighted_fit'),
                       Item('use_monte_carlo'),
                       Item('monte_carlo_ntrials',
                            enabled_when='object.use_monte_carlo')),
                Item('predicted_j_error_type', label='Predicted J Error',
                     enabled_when='not (object.use_weighted_fit or object.use_monte_carlo)'),
                HGroup(Item('group_positions'),
                       Item('object.monitor.sample',
                            style='readonly', label='Sample')),
                Item('show_labels',
                     label='Display Labels',
                     tooltip='Display hole labels on plot'),
                HGroup(UItem('plot_kind'),
                       Item('model_kind', label='Fit Model',
                            editor=EnumEditor(values=['Bowl', 'Plane']))),
                # UItem('plot_kind', editor=EnumEditor(values=['Contour', 'Hole vs J']))),
                contour_grp))
     return v
Esempio n. 15
0
    def traits_view(self):
        if is_display_small():
            w_view = 350
        else:
            w_view = 450

        info_group = VGroup(Item('_name',
                                 label='Annotations name:',
                                 style='readonly',
                                 padding=0),
                            VGrid(Item('_nclasses',
                                       label='Number of classes:',
                                       style='readonly',
                                       width=10),
                                  Item('_labels',
                                       label='Labels:',
                                       style='readonly'),
                                  Item('_nannotators',
                                       label='Number of annotators:',
                                       style='readonly',
                                       width=10),
                                  Item('_nitems',
                                       label='Number of items:',
                                       style='readonly'),
                                  padding=0),
                            padding=0)

        body = VGroup(
            info_group,
            Item('_'),
            HGroup(
                VGroup(
                    Spring(),
                    Item('frequency_plot',
                         style='custom',
                         resizable=False,
                         show_label=False,
                         width=w_view), Spring()), Spring(),
                VGroup(
                    Spring(),
                    Item('edit_data',
                         enabled_when='annotations_are_defined',
                         show_label=False),
                    Item('save_data',
                         enabled_when='annotations_are_defined',
                         show_label=False), Spring())),
            Spring(),
            Item('_'),
        )

        traits_view = View(body)
        return traits_view
Esempio n. 16
0
 def _get_auto_group(self):
     return VGroup(
         HGroup(
             icon_button_editor(
                 'plot_button',
                 'refresh',
                 tooltip='Replot the isotope evolutions. '
                 'This may take awhile if many analyses are selected'),
             icon_button_editor('save_event',
                                'database_save',
                                tooltip='Save fits to database'),
             Item(
                 'auto_update',
                 label='Auto Plot',
                 tooltip=
                 'Should the plot refresh after each change ie. "fit" or "show". '
                 'It is not advisable to use this option with many analyses'
             )),
         HGroup(
             UItem('global_fit', editor=EnumEditor(name='fit_types')),
             UItem('global_error_type',
                   editor=EnumEditor(name='error_types'))))
Esempio n. 17
0
    def traits_view(self):
        l = VGroup(UItem('low_post_time'),
                   UItem('low_post_date', style='custom'))
        h = VGroup(UItem('high_post_time'),
                   UItem('high_post_date', style='custom'))

        v = View(UItem('pad'),
                 HGroup(l, h),
                 kind='livemodal',
                 width=500,
                 resizable=True,
                 buttons=['OK', 'Cancel'])
        return v
Esempio n. 18
0
    def traits_view(self):
        db_table_editor = TableEditor(
            columns=[
                ObjectColumn(name='data_id',
                             label='Annotations ID',
                             editable=False,
                             width=0.65),
                ObjectColumn(name='model_name', editable=False, width=0.20),
                ObjectColumn(name='value',
                             label='Log likelihood',
                             editable=False,
                             width=0.15)
            ],
            search=SearchIDFilter(),
            editable=True,
            deletable=True,
            configurable=False,
            sortable=True,
            sort_model=False,
            auto_size=False,
            orientation='vertical',
            show_toolbar=True,
            selection_mode='row',
            on_dclick=self.forward_to_model_data_view,
            on_select=self.track_selection)

        traits_view = View(
            VGroup(
                Item(
                    'results_table',
                    editor=db_table_editor,
                    show_label=False,
                ),
                HGroup(
                    Item('open_to_main', show_label=False, width=100),
                    Item('delete_action',
                         show_label=False,
                         enabled_when='current_selection is not None',
                         width=100), Spring(),
                    Item('close_view', show_label=False, width=100)),
            ),
            title='pyAnno results database',
            width=800,
            height=400,
            resizable=True,
            #buttons   = [ 'OK' ],
            kind='live')

        return traits_view
Esempio n. 19
0
class HResizeTestDialog(HasTraits):
    """ Dialog with checkbox and text elements and labels on the right.
    We test the separation between element and label in HGroups.
    """

    bool_item = Bool(True)
    txt_item = Str

    traits_view = View(VGroup(
        HGroup(Item('bool_item', springy=True), show_left=False),
        VGroup(Item('txt_item', resizable=True), show_left=False),
    ),
                       width=_DIALOG_WIDTH,
                       height=100,
                       resizable=True)
Esempio n. 20
0
class GuiDefine(HasTraits):
    name = Str()
    value = Str()
    traits_view = View(
        HGroup(
            Item('name',
                 width=200,
                 label='#define',
                 ),
            Item('value',
                 width=200,
                 show_label=False,
                 ),
        ),
    )
Esempio n. 21
0
    def traits_view(self):

        a = UItem('_tabs',
                  width=-200,
                  editor=myTabularEditor(adapter=CatergoryAdapter(),
                                         row_height=32,
                                         editable=False,
                                         horizontal_lines=False,
                                         selected='_selected'))
        b = UItem('_selected', style='custom')
        v = okcancel_view(HGroup(a, b),
                          height=500,
                          width=800,
                          title='Preferences')
        return v
Esempio n. 22
0
 def _get_auto_group(self):
     return HGroup(
         icon_button_editor(
             'plot_button',
             'chart_curve_go',
             tooltip='Replot the isotope evolutions. '
             'This may take awhile if many analyses are selected'),
         icon_button_editor('save_event',
                            'database_save',
                            tooltip='Save fits to database'), spring,
         Item(
             'auto_update',
             label='Auto Plot',
             tooltip=
             'Should the plot refresh after each change ie. "fit" or "show". '
             'It is not advisable to use this option with many analyses'))
Esempio n. 23
0
    def traits_view(self):

        a = UItem('_tabs', width=-200,
                  editor=myTabularEditor(adapter=CatergoryAdapter(),
                                         row_height=32,
                                         editable=False,
                                         horizontal_lines=False,
                                         selected='_selected'))
        b = UItem('_selected', style='custom')
        v = View(HGroup(a, b),
                 height=500,
                 width=800,
                 kind='livemodal',
                 title='Preferences',
                 resizable=True,
                 buttons=['OK', 'Cancel'])
        return v
Esempio n. 24
0
 def traits_view(self):
     return View(
         HGroup(
             Item('age_kind', style='readonly', show_label=False),
             Item('display_age',
                  format_func=lambda x: floatfmt(x, 3),
                  label='Age',
                  style='readonly'),
             Item('display_age_err',
                  label=u'\u00b11\u03c3',
                  format_func=lambda x: floatfmt(x, 4),
                  style='readonly'),
             Item('display_age_units', style='readonly', show_label=False),
             Item('mswd',
                  format_func=lambda x: floatfmt(x, 2),
                  style='readonly',
                  label='MSWD')))
Esempio n. 25
0
 def traits_view(self):
     traits_view = View(
         VGroup(
             Item('annotator_idx',
                  label='Annotator index',
                  editor=RangeEditor(mode='spinner',
                                     low=0, high=self.theta.shape[0]-1,
                                     ),
             ),
             HGroup(
                 Item('theta_j_view',
                      style='custom',
                      show_label=False),
             ),
         ),
         width = 500,
         height = 400,
         resizable = True
     )
     return traits_view
Esempio n. 26
0
class ScopeWnd(AbstractWnd):
    pin = PinTrait('analog')
    interval = Time()

    @property
    def conf(self):
        return dict(pin=self.pin,
                    interval=self.interval)

    def plot(self, data, fig):
        time_plot(data, fig)

    def measure(self, conf, stop_condition):
        return measure(self.conf, stop_condition)

    view = View(
        HGroup(
            'start',
            'stop',
            'auto_update',
            readonly('alive', checkbox=True),
        ),
#               instance('tester', view=View(
        slider('interval', 0.1, 10),
        'pin',
#                                                         ),
#                    ),
        Group(
        Item('figure',
             editor=MPLFigureEditor(),
             show_label=False
             ),
        ),
        width=600,
        height=300,
        resizable=True)
Esempio n. 27
0
class ProjectInfoUI(cmp.project.ProjectInfo):
    """Class that extends the :class:`ProjectInfo` with graphical components.

    It supports graphically the setting of all processing properties / attributes
    of an :class:`ProjectInfo` instance.

    Attributes
    -----------
    creation_mode : traits.Enum
        Mode for loading the dataset. Valid values are
        'Load BIDS dataset', 'Install Datalad BIDS dataset'

    install_datalad_dataset_via_ssh : traits.Bool
        If set to True install the datalad dataset from a remote server
        via ssh.(True by default)

    ssh_user : traits.Str
        Remote server username.
        (Required if ``install_datalad_dataset_via_ssh`` is True)

    ssh_pwd <traits.Password>
        Remote server password.
        (Required if ``install_datalad_dataset_via_ssh`` is True)

    ssh_remote : traits.Str
        Remote server IP or URL.
        (Required if ``install_datalad_dataset_via_ssh`` is True)

    datalad_dataset_path : traits.Directory
        Path to the datalad dataset on the remote server.
        (Required if ``install_datalad_dataset_via_ssh`` is True)

    summary_view_button : traits.ui.Button
        Button that shows the pipeline processing summary table

    pipeline_processing_summary_view : traits.ui.VGroup
        TraitsUI VGroup that contains ``Item('pipeline_processing_summary')``

    dataset_view : traits.ui.View
        TraitsUI View that shows a summary of project settings and
        modality available for a given subject

    traits_view : QtView
        TraitsUI QtView that includes the View 'dataset_view'

    create_view : traits.ui.View
        Dialog view to create a BIDS Dataset

    subject_view : traits.ui.View
        Dialog view to select of subject

    subject_session_view : traits.ui.View
        Dialog view to select the subject session

    dmri_bids_acq_view : traits.ui.View
        Dialog view to select the diffusion acquisition model

    anat_warning_view : traits.ui.View
        View that displays a warning message regarding
        the anatomical T1w data

    anat_config_error_view : traits.ui.View
        Error view that displays an error message regarding
        the configuration of the anatomical pipeline

    dmri_warning_view : traits.ui.View
        View that displays a warning message regarding
        the diffusion MRI data

    dmri_config_error_view : traits.ui.View
        View that displays an error message regarding
        the configuration of the diffusion pipeline

    fmri_warning_view : traits.ui.View
        View that displays a warning message regarding
        the functional MRI data

    fmri_config_error_view : traits.ui.View
        View that displays an error message regarding
        the configuration of the fMRI pipeline

    open_view : traits.ui.View
        Dialog view to load a BIDS Dataset

    anat_select_config_to_load : traits.ui.View
        Dialog view to load the configuration file of the anatomical pipeline

    diffusion_imaging_model_select_view : traits.ui.View
        Dialog view to select the diffusion acquisition model

    dmri_select_config_to_load : traits.ui.View
        Dialog view to load the configuration file of the diffusion MRI pipeline

    fmri_select_config_to_load : traits.ui.View
        Dialog view to load the configuration file of the fMRI pipeline
    """

    creation_mode = Enum("Load BIDS dataset", "Install Datalad BIDS dataset")
    install_datalad_dataset_via_ssh = Bool(True)
    ssh_user = String("remote_username")
    ssh_pwd = Password("")
    ssh_remote = String("IP address/ Machine name")
    datalad_dataset_path = Directory(
        "/shared/path/to/existing/datalad/dataset")

    anat_runs = List()
    anat_run = Enum(values="anat_runs")

    dmri_runs = List()
    dmri_run = Enum(values="dmri_runs")

    fmri_runs = List()
    fmri_run = Enum(values="fmri_runs")

    summary_view_button = Button("Pipeline processing summary")

    pipeline_processing_summary_view = VGroup(
        Item("pipeline_processing_summary"))

    dataset_view = VGroup(
        VGroup(
            HGroup(
                Item(
                    "base_directory",
                    width=-0.3,
                    style="readonly",
                    label="",
                    resizable=True,
                ),
                Item(
                    "number_of_subjects",
                    width=-0.3,
                    style="readonly",
                    label="Number of participants",
                    resizable=True,
                ),
                "summary_view_button",
            ),
            label="BIDS Dataset",
        ),
        spring,
        HGroup(
            Group(
                Item("subject",
                     style="simple",
                     show_label=True,
                     resizable=True)),
            Group(
                Item("subject_session",
                     style="simple",
                     label="Session",
                     resizable=True),
                visible_when='subject_session!=""',
            ),
            springy=True,
        ),
        spring,
        Group(
            Item("t1_available", style="readonly", label="T1", resizable=True),
            HGroup(
                Item(
                    "dmri_available",
                    style="readonly",
                    label="Diffusion",
                    resizable=True,
                ),
                Item(
                    "diffusion_imaging_model",
                    label="Model",
                    resizable=True,
                    enabled_when="dmri_available",
                ),
            ),
            Item("fmri_available",
                 style="readonly",
                 label="BOLD",
                 resizable=True),
            label="Modalities",
        ),
        spring,
        Group(
            Item(
                "anat_last_date_processed",
                label="Anatomical pipeline",
                style="readonly",
                resizable=True,
                enabled_when="t1_available",
            ),
            Item(
                "dmri_last_date_processed",
                label="Diffusion pipeline",
                style="readonly",
                resizable=True,
                enabled_when="dmri_available",
            ),
            Item(
                "fmri_last_date_processed",
                label="fMRI pipeline",
                style="readonly",
                resizable=True,
                enabled_when="fmri_available",
            ),
            label="Last date processed",
        ),
        spring,
        Group(Item("number_of_cores", resizable=True),
              label="Processing configuration"),
        "550",
        spring,
        springy=True,
    )

    traits_view = QtView(Include("dataset_view"))

    create_view = View(
        Item("creation_mode", style="custom"),
        Group(
            Group(
                Item("base_directory", label="BIDS Dataset"),
                visible_when='creation_mode=="Load BIDS dataset"',
            ),
            Group(
                Item("install_datalad_dataset_via_ssh"),
                visible_when='creation_mode=="Install Datalad/BIDS dataset"',
            ),
            Group(
                Item(
                    "ssh_remote",
                    label="Remote ssh server",
                    visible_when="install_datalad_dataset_via_ssh",
                ),
                Item(
                    "ssh_user",
                    label="Remote username",
                    visible_when="install_datalad_dataset_via_ssh",
                ),
                Item(
                    "ssh_pwd",
                    label="Remote password",
                    visible_when="install_datalad_dataset_via_ssh",
                ),
                Item(
                    "datalad_dataset_path",
                    label="Datalad/BIDS Dataset Path/URL to be installed",
                ),
                Item("base_directory", label="Installation directory"),
                visible_when='creation_mode=="Install Datalad/BIDS dataset"',
            ),
        ),
        kind="livemodal",
        title="Data creation: BIDS dataset selection",
        # style_sheet=style_sheet,
        width=modal_width,
        buttons=["OK", "Cancel"],
    )

    subject_view = View(
        Group(Item("subject", label="Selected Subject")),
        kind="modal",
        title="Subject and session selection",
        # style_sheet=style_sheet,
        width=modal_width,
        buttons=["OK", "Cancel"],
    )

    subject_session_view = View(
        Group(
            Item("subject", style="readonly", label="Selected Subject"),
            Item("subject_session", label="Selected Session"),
        ),
        kind="modal",
        title="Session selection",
        # style_sheet=style_sheet,
        width=modal_width,
        buttons=["OK", "Cancel"],
    )

    dmri_bids_acq_view = View(
        Group(Item("dmri_bids_acq", label="Selected model"), ),
        kind="modal",
        title="Selection of diffusion acquisition model",
        # style_sheet=style_sheet,
        width=modal_width,
        buttons=["OK", "Cancel"],
    )

    anat_warning_view = View(
        Group(Item("anat_warning_msg", style="readonly", show_label=False), ),
        title="Warning : Anatomical T1w data",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    anat_config_error_view = View(
        Group(
            Item("anat_config_error_msg", style="readonly",
                 show_label=False), ),
        title="Error",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    dmri_warning_view = View(
        Group(Item("dmri_warning_msg", style="readonly", show_label=False), ),
        title="Warning : Diffusion MRI data",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    dmri_config_error_view = View(
        Group(
            Item("dmri_config_error_msg", style="readonly",
                 show_label=False), ),
        title="Error",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    fmri_warning_view = View(
        Group(Item("fmri_warning_msg", style="readonly", show_label=False), ),
        title="Warning : fMRI data",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    fmri_config_error_view = View(
        Group(
            Item("fmri_config_error_msg", style="readonly",
                 show_label=False), ),
        title="Error",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    open_view = View(
        Item("creation_mode", label="Mode"),
        Group(
            Item("install_datalad_dataset_via_ssh"),
            Item(
                "ssh_remote",
                label="Remote ssh server",
                visible_when="install_datalad_dataset_via_ssh",
            ),
            Item(
                "ssh_user",
                label="Remote username",
                visible_when="install_datalad_dataset_via_ssh",
            ),
            Item(
                "ssh_pwd",
                label="Remote password",
                visible_when="install_datalad_dataset_via_ssh",
            ),
            Item(
                "datalad_dataset_path",
                label="Datalad/BIDS Dataset Path/URL to be installed",
            ),
            Item("base_directory", label="Installation directory"),
            visible_when='creation_mode=="Install Datalad BIDS dataset"',
        ),
        Group(
            Item("base_directory", label="BIDS Dataset"),
            visible_when='creation_mode=="Load BIDS dataset"',
        ),
        kind="livemodal",
        title="BIDS Dataset Creation/Loading",
        # style_sheet=style_sheet,
        width=600,
        height=250,
        buttons=["OK", "Cancel"],
    )

    anat_select_config_to_load = View(
        Group(
            Item("anat_config_to_load_msg", style="readonly",
                 show_label=False),
            Item(
                "anat_config_to_load",
                style="custom",
                editor=EnumEditor(name="anat_available_config"),
                show_label=False,
            ),
        ),
        title="Select configuration for anatomical pipeline",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    anat_custom_map_view = View(
        Group(
            Item(
                "anat_custom_last_stage",
                editor=EnumEditor(name="anat_stage_names"),
                style="custom",
                show_label=False,
            ), ),
        title="Select until which stage to process the anatomical pipeline.",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    diffusion_imaging_model_select_view = View(
        Group(Item("diffusion_imaging_model",
                   label="Diffusion MRI modality"), ),
        title="Please select diffusion MRI modality",
        kind="modal",
        width=modal_width,
        buttons=["OK", "Cancel"],
    )

    dmri_select_config_to_load = View(
        Group(
            Item("dmri_config_to_load_msg", style="readonly",
                 show_label=False), ),
        Item(
            "dmri_config_to_load",
            style="custom",
            editor=EnumEditor(name="dmri_available_config"),
            show_label=False,
        ),
        title="Select configuration for diffusion pipeline",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    dmri_custom_map_view = View(
        Group(
            Item(
                "dmri_custom_last_stage",
                editor=EnumEditor(name="dmri_stage_names"),
                style="custom",
                show_label=False,
            ), ),
        title="Select until which stage to process the diffusion pipeline.",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    fmri_select_config_to_load = View(
        Group(
            Item("fmri_config_to_load_msg", style="readonly",
                 show_label=False), ),
        Item(
            "fmri_config_to_load",
            style="custom",
            editor=EnumEditor(name="fmri_available_config"),
            show_label=False,
        ),
        title="Select configuration for fMRI pipeline",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    fmri_custom_map_view = View(
        Group(
            Item(
                "fmri_custom_last_stage",
                editor=EnumEditor(name="fmri_stage_names"),
                style="custom",
                show_label=False,
            ), ),
        title="Select until which stage to process the fMRI pipeline.",
        kind="modal",
        width=modal_width,
        # style_sheet=style_sheet,
        buttons=["OK", "Cancel"],
    )

    def _summary_view_button_fired(self):
        self.configure_traits(view="pipeline_processing_summary_view")
Esempio n. 28
0
class BoardWrapper(HasTraits):
    pins = List(PinWrapper)
    digital_pins = List(PinWrapper)
    analog_pins = List(PinWrapper)
    defines = List(GuiDefine)
    port_type = Enum('serial',
                     [
                         'none',
                         'serial',
                     ]
                     )
    serial_device = Enum(_auto_detect_serial_unix())
    baudrate = Int(115200)
    sleep_after_connect = Int(2)
    timeout = Int(1)
    uptime = Float()
    tree = None
    vcc = Float()
    avr_name = Str()
    arduino_version = Str()
    firmware_build_time = Str()
    gcc_version = Str()
    libc_version = Str()
    libc_date = Str()

    connected = Bool(False)
    connect = Button()
    disconnect = Button()

    def _connect_fired(self):
            try:
                connection = SerialManager(device=self.serial_device,
                                           baudrate=self.baudrate,
                                           sleep_after_connect=self.sleep_after_connect,
                                           timeout=self.timeout)
                connection.open()
                print ArduinoApi(connection=connection).millis()
            except Exception as e:
                traceback.print_exc()
                message(traceback.format_exc(), buttons=['OK'])
                return

            a = self.tree = ArduinoTree(connection=connection)

            d = a.define.as_dict
            s = [GuiDefine(name=k, value=str(v)) for k, v in d.items()]
            s.sort(key=lambda x: x.name)
            self.defines = s
            self.digital_pins = [PinWrapper(pin=a.pin.get(x))
                                 for x in a.pin.names_digital]
            self.analog_pins = [PinWrapper(pin=a.pin.get(x))
                                for x in a.pin.names_analog]
            self.pins = self.digital_pins + self.analog_pins

            fw = a.firmware_info
            self.arduino_version = fw.get('arduino_version')
            self.firmware_build_time = str(fw.get('compile_datetime'))
            self.avr_name = fw.get('avr_name')
            self.gcc_version = fw.get('gcc_version')
            self.libc_version = fw.get('libc_version')
            self.libc_date = str(fw.get('libc_date'))
            self.connected = True

    def _disconnect_fired(self):
            self.digital_pins = []
            self.analog_pins = []
            self.pins = []
            self.defines = []
            self.avr_name = ''
            self.arduino_version = ''
            self.firmware_build_time = ''
            self.gcc_version = ''
            self.libc_version = ''
            self.libc_date = ''

            self.tree.connection.close()
            del self.tree
            self.tree = None
            self.connected = False

    update_interval = Int(1000, desc='interval in msec')
    update_enable = Bool(True)

    def update(self):
        if self.update_enable and self.connected and self.tree:
            for x in self.pins:
                x.update()
            self.uptime = self.tree.api.millis() / 1000.0
            self.vcc = self.tree.vcc.read() if self.tree.vcc else -1
        time.sleep(self.update_interval / 1000.0)

    traits_view = View(
        Tabbed(
            Group(
                HGroup(
                    Group(
                        button('connect', enabled_when='not connected'),
                        button('disconnect', enabled_when='connected'),
                        Item(
                            'port_type', enabled_when='not connected', width=300,
                        ),
                        Group(
                            'serial_device',
                            'baudrate',
                            'sleep_after_connect',
                            'timeout',
                            visible_when='port_type=="serial"',
                            enabled_when='not connected',
                        ),
                    ),
                    Group(
                        'avr_name',
                        'arduino_version',
                        'firmware_build_time',
                        'gcc_version',
                        'libc_version',
                        'libc_date',
                        #                     'baudrate',
                        #                     'sleep_after_connect',
                        # visible_when='port_type=="serial"',
                        springy=True,
                    ),
                ),
                label='connection',
            ),
            Group(
                'uptime',
                'vcc',
                label='misc',
            ),
            Item(name='digital_pins',
                      editor=ListEditor(
                     style='custom',
                 ),
                 style='readonly',
                 show_label=False,
                 ),
            Item(name='analog_pins',
                      editor=ListEditor(
                 style='custom',
                 ),
                 style='readonly',
                 show_label=False,
                 ),
            Group(
                  'update_enable',
                Item(name='update_interval',
                     editor=RangeEditor(
                     mode='slider',
                     low=1,
                     high=1000,
                     ),
                     style='custom',
                     ),
                label='settings',
            ),
            Item('defines',
                show_label=False,
                editor=ListEditor(
#                     auto_size=False,
#                     editable=False,
#                     configurable=False,
                 style='custom',
                ),
                style='readonly',
                 )
        ),
        width=800,
        height=600,
        buttons=['Undo', 'Revert', 'OK', 'Cancel'],
        kind='live',
        resizable=True,
        handler=Handler(),
    )
def right_group():
    return VGroup(
        HGroup(UItem('right_message', style='readonly'),
               UItem('right_date', style='readonly')),
        UItem('right', style='custom', editor=TextEditor(read_only=True)))
Esempio n. 30
0
class EventSelectionDialog(HasTraits):
    source_class_label = String("Select Event Source Classes")
    severity_level_label = String("Select Event Severity Levels")

    search = String(regex="^[_a-zA-Z0-9\*\.\$\^\?\s]*$")
    shown_event_names_list = String(regex="[_a-zA-Z0-9\*\.\$\^\?\n]*")
    quit_button = Button('Quit')
    query_button = Button('Run Query...')
    period_start_date = DelegatesTo("query_object")
    period_end_date = DelegatesTo("query_object")

    selected_list_of_event_severity_levels = DelegatesTo("query_object")
    list_of_event_severity_levels = DelegatesTo("query_object")

    selected_list_of_source_classes = DelegatesTo("query_object")
    list_of_source_classes = DelegatesTo("query_object")

    query_object = Instance(EventSelectionQuery)

    spring = Spring

    help_text = (
        "Search engine like queries using alphanumeric characters and '_'and '.' \n"
        + "Space indicate OR-separated queries\n" +
        "? = match any character\n" + "* = any number of characters\n" +
        "^ = match beginning\n"
        "$ = match end")

    view = View(
        Group(
            VGroup(
                HGroup(Item("period_start_date", label="Period"),
                       Item("period_end_date", show_label=False),
                       Item("", resizable=True, width=1.0, show_label=False),
                       HGroup(Item('quit_button', show_label=False),
                              Item('query_button', show_label=False)),
                       springy=True),
                HGroup(
                    VGroup(
                        HGroup(
                            Item("severity_level_label",
                                 show_label=False,
                                 style="readonly")),
                        Item("selected_list_of_event_severity_levels",
                             editor=CheckListEditor(
                                 name="list_of_event_severity_levels"),
                             style="custom",
                             show_label=False)),
                    VGroup(
                        HGroup(
                            Item("source_class_label",
                                 show_label=False,
                                 style="readonly")),
                        Item("selected_list_of_source_classes",
                             editor=CheckListEditor(
                                 name="list_of_source_classes"),
                             style="custom",
                             show_label=False)),
                    # springy=True
                ),
                show_border=True),
            Item("_"),
            VGroup(Item("search",
                        editor=HistoryEditor(auto_set=True),
                        show_label=False,
                        width=1.0,
                        tooltip=help_text),
                   Item(
                       name='shown_event_names_list',
                       style='readonly',
                       resizable=True,
                       show_label=False,
                   ),
                   scrollable=True,
                   show_border=True),
            orientation='vertical',
        ),
        title='Select Events to Visualize',
        dock='horizontal',
        resizable=True,
        width=.5,
        height=.7)

    def __init__(self, query_object, **kwargs):
        '''
        Creates a dialog window for selecting date period, source classes and event severity levels/types.
        :param query_object:
        :return:
        '''
        assert isinstance(query_object, EventSelectionQuery)

        self.shown_event_names_list = "\n".join(
            list(query_object.list_of_event_names))
        self.query_object = query_object
        self.query_start_date = query_object.period_start_date
        self.query_end_date = query_object.period_end_date

        HasTraits.__init__(self, **kwargs)

    def _search_changed(self):
        '''
        Matches search query to the event names.
        :return:
        '''
        query_st = str(self.search).strip()

        if re.match("^[_a-zA-Z0-9\*\.\$\^\?\s]*$", query_st) is None:
            return

        query_st = query_st.replace(".", "\.")
        query_st = query_st.replace("*", ".*")
        query_st = query_st.replace("?", ".?")
        queries = query_st.split()

        print self.search, query_st, queries,

        if len(queries) == 0:
            queries = [""]

        result = [
            s for s in list(self.query_object.list_of_event_names)
            for q in queries if re.search((".*%s.*" % q), s) is not None
        ]

        self.query_object.selected_list_of_event_names = result
        self.shown_event_names_list = "\n".join(result)

        print len(self.shown_event_names_list)

    def _save_search(self):
        # A bug fix, stops the clearing of the search expression
        tmp = self.search
        self.search = " "
        self.search = tmp

        print len(self.query_object.selected_list_of_event_names)

    def _query_button_changed(self):
        self._save_search()
        self.query_object.execute_query()

    def _quit_button_changed(self):
        self._save_search()
        sys.exit(0)