コード例 #1
0
def readonly(name, checkbox=False, format_func=None, format_str=None, **kwargs):
    if checkbox:
        return Item(name=name,
                    editor=BooleanEditor(),
                    enabled_when='0',
                    **kwargs
                    )
    else:
        item = Item(name=name,
                    # editor=TextEditor(format_func=format_func),
                    style='readonly',
                    **kwargs
                    )
        if format_func or format_str:
            item.editor = TextEditor(format_func=format_func,
                                     format_str=format_str)
        return item
コード例 #2
0
ファイル: modeler.py プロジェクト: btdevree/bikipy
    def config_model_view(self):
        menubar_config = MenuBar(
            Menu(Action(name='New Model',
                        action='new_model',
                        tooltip='Create a new model from scratch'),
                 Action(
                     name='Copy Model',
                     action='copy_model',
                     tooltip='Create a new model by copying an existing one'),
                 name='Create Model'))

        view_config = View(Group(Item(name='model_list', style='custom'),
                                 show_border=True),
                           Item(label="Lots of stuff should go here"),
                           menubar=menubar_config,
                           buttons=NoButtons,
                           title='BiKiPy Modeler')

        return (view_config)
コード例 #3
0
class DialogWithToolbar(HasTraits):
    """Test dialog with toolbar and menu."""

    action_successful = Bool(False)

    def test_clicked(self):
        self.action_successful = True

    menubar = MenuBar(Menu(ActionGroup(TestAction), name="&Test menu"))

    toolbar = ToolBar(ActionGroup(TestAction))

    traits_view = View(
        Item(label="Click the button on the toolbar or the menu item.\n"
             "The 'Action successful' element should turn to True."),
        Item("action_successful", style="readonly"),
        menubar=menubar,
        toolbar=toolbar,
        buttons=[TestAction, "OK"],
    )
コード例 #4
0
ファイル: test_datetime.py プロジェクト: enthought/traitsui
class DatetimeInitDailog(HasTraits):

    date = Datetime()

    def _date_default(self):
        return DATE

    traits_view = View(
        Item('date',
             editor=DatetimeEditor(maximum_datetime=MAX_DATE,
                                   minimum_datetime=MIN_DATE)))
コード例 #5
0
class NewModelADialog(NewModelDialog):
    """Create a dialog requesting the parameters to create Model A."""

    model_name = Str(MODEL_A_NAME)
    nclasses = Int(5)

    parameters_group = VGroup(
        Item(name='nclasses',
             editor=RangeEditor(mode='spinner', low=3, high=1000),
             label='Number of annotation classes:',
             width=100), )
コード例 #6
0
class _SingleStatView(HasTraits):
    value = Float
    name = Str
    txt = Str

    @on_trait_change('value')
    def _update_txt(self):
        txt = "{name} = {val:.4}".format(name=self.name, val=self.value)
        self.txt = txt

    traits_view = View(Item('txt', style='readonly', show_label=False))
コード例 #7
0
ファイル: popup_editor.py プロジェクト: kitchoi/traitsui
    def popup_view(self):
        """ Returns the popup View.
        """
        factory = self.factory
        item = Item(
            self.name,
            show_label=False,
            padding=-4,
            style=factory.style,
            height=factory.height,
            width=factory.width,
        )

        editor = factory.editor
        if editor is not None:
            if not isinstance(editor, EditorFactory):
                editor = editor()
            item.editor = editor

        return View(item, kind=factory.kind)
コード例 #8
0
def slider(name, low=0, high=100, is_float=True):
    return Item(
        name=name,
        editor=RangeEditor(
            mode='slider',
            low=low,
            high=high,
            is_float=is_float,
        ),
        style='custom',
    )
コード例 #9
0
def table(name, **kwargs):
    return Item(
        name=name,
        editor=TableEditor(
            auto_size=False,
            editable=False,
            configurable=False,
            # selection_mode='row',
        ),
        style='readonly',
        **kwargs)
コード例 #10
0
class DialogWithToolbar(HasTraits):
    """Test dialog with toolbar and menu."""

    action_successful = Bool(False)

    def test_clicked(self):
        print('perform action')
        self.action_successful = True

    menubar = MenuBar(Menu(ActionGroup(TestAction), name='&Test menu'), )

    toolbar = ToolBar(ActionGroup(TestAction), )

    traits_view = View(
        Item(label="Click the button on the toolbar or the menu item.\n"
             "The 'Action successful' element should turn to True."),
        Item('action_successful', style='readonly'),
        menubar=menubar,
        toolbar=toolbar,
        buttons=[TestAction, 'OK'])
コード例 #11
0
def readonly(name,
             checkbox=False,
             format_func=None,
             format_str=None,
             **kwargs):
    if checkbox:
        return Item(name=name,
                    editor=BooleanEditor(),
                    enabled_when='0',
                    **kwargs)
    else:
        item = Item(
            name=name,
            # editor=TextEditor(format_func=format_func),
            style='readonly',
            **kwargs)
        if format_func or format_str:
            item.editor = TextEditor(format_func=format_func,
                                     format_str=format_str)
        return item
コード例 #12
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
コード例 #13
0
class NoLabelResizeTestDialog(HasTraits):
    """ Test the combination show_label=False, show_left=False.
    """

    bool_item = Bool(True)

    traits_view = View(VGroup(Item('bool_item',
                                   resizable=True,
                                   show_label=False),
                              show_left=False),
                       resizable=True)
コード例 #14
0
ファイル: popup_editor.py プロジェクト: enthought/traitsui
 def base_view(self):
     """Returns the View that allows the popup view to be displayed."""
     return View(
         Item(
             self.name,
             show_label=False,
             style="readonly",
             editor=TextEditor(view=self.popup_view()),
             padding=-4,
         ),
         kind="subpanel",
     )
コード例 #15
0
class InputBox(HasPrivateTraits):
    message = Str
    input = Str
    view = View(
        [
            Item(
                name='message',
                show_label=False,
                style='readonly',
            ),
            Item(
                name='input',
                show_label=False,
            ),
        ],
        buttons=['OK', 'Cancel'],
        kind='modal',
        width=400,
        #        height=600,
        resizable=True,
    )
コード例 #16
0
class _ComponentDialogWithSize(HasTraits):
    """ View containing an item with ComponentEditor and given size. """
    thing = Any

    traits_view = View(
        Item(
            'thing',
            editor=ComponentEditor(),
            show_label=False,
            width=ITEM_WIDTH,
            height=ITEM_HEIGHT),
        resizable=True)
コード例 #17
0
def test_data_frame_editor_alternate_adapter():
    class AlternateAdapter(DataFrameAdapter):
        pass

    alternate_adapter_view = View(
        Item('data',
             editor=DataFrameEditor(adapter=AlternateAdapter()),
             width=400))
    viewer = sample_data()
    with store_exceptions_on_all_threads():
        ui = viewer.edit_traits(view=alternate_adapter_view)
        ui.dispose()
コード例 #18
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
    )
コード例 #19
0
def tabs(name, **kwargs):
    '''
    page_name
    '''
    return Item(
        name=name,
        editor=ListEditor(
            use_notebook=True,
            dock_style='fixed',
            #                                view=view,
            **kwargs),
        show_label=False,
        style='custom',
    )
コード例 #20
0
    def test_data_frame_editor_alternate_adapter(self):
        class AlternateAdapter(DataFrameAdapter):
            pass

        alternate_adapter_view = View(
            Item(
                "data",
                editor=DataFrameEditor(adapter=AlternateAdapter()),
                width=400,
            ))
        viewer = sample_data()
        with reraise_exceptions(), \
                create_ui(viewer, dict(view=alternate_adapter_view)):
            pass
コード例 #21
0
    def _data_frame_view(self):
        """ Return the view used by the editor.
        """

        return View(
            Item(
                self._target_name(self.name),
                id="tabular_editor",
                show_label=False,
                editor=TabularEditor(
                    show_titles=self.factory.show_titles,
                    editable=self.factory.editable,
                    adapter=self.adapter,
                    selected=self._target_name(self.factory.selected),
                    selected_row=self._target_name(self.factory.selected_row),
                    selectable=self.factory.selectable,
                    multi_select=self.factory.multi_select,
                    activated=self._target_name(self.factory.activated),
                    activated_row=self._target_name(
                        self.factory.activated_row
                    ),  # noqa
                    clicked=self._target_name(self.factory.clicked),
                    dclicked=self._target_name(self.factory.dclicked),
                    scroll_to_row=self._target_name(
                        self.factory.scroll_to_row
                    ),  # noqa
                    scroll_to_row_hint=self.factory.scroll_to_row_hint,
                    scroll_to_column=self._target_name(
                        self.factory.scroll_to_column
                    ),  # noqa
                    right_clicked=self._target_name(
                        self.factory.right_clicked
                    ),  # noqa
                    right_dclicked=self._target_name(
                        self.factory.right_dclicked
                    ),  # noqa
                    column_clicked=self._target_name(
                        self.factory.column_clicked
                    ),  # noqa
                    column_right_clicked=self._target_name(
                        self.factory.column_right_clicked
                    ),  # noqa
                    operations=self.factory.operations,
                    update=self._target_name(self.factory.update),
                    refresh=self._target_name(self.factory.refresh),
                ),
            ),
            id="data_frame_editor",
            resizable=True,
        )
コード例 #22
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
コード例 #23
0
ファイル: test_actions.py プロジェクト: enthought/traitsui
class DialogWithSchema(HasTraits):
    """Test dialog with toolbar and menu schemas."""

    action_successful = Bool(False)

    def test_clicked(self):
        self.action_successful = True

    menubar = SMenuBar(
        SMenu(
            SGroup(
                ActionSchema(
                    action_factory=lambda **traits: TestAction,
                ),
            ),
            name="&Test menu",
        ),
    )

    toolbar = SToolBar(
        SGroup(
            ActionSchema(
                action_factory=lambda **traits: TestAction,
            ),
        ),
    )

    traits_view = View(
        Item(
            label="Click the button on the toolbar or the menu item.\n"
            "The 'Action successful' element should turn to True."
        ),
        Item("action_successful", style="readonly"),
        menubar=menubar,
        toolbar=toolbar,
        buttons=[TestAction, "OK"],
    )
コード例 #24
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'))
コード例 #25
0
 def traits_view(self):
     ncolumns = len(self.data[0])
     w_table = min(WIDTH_CELL * ncolumns, MAX_WIDTH)
     w_view = min(w_table + W_MARGIN, MAX_WIDTH)
     return View(Group(
         Item('data',
              editor=TabularEditor(adapter=Array2DAdapter(
                  ncolumns=ncolumns, format='%s', show_index=True)),
              show_label=False,
              width=w_table,
              padding=10), ),
                 title='Annotations',
                 width=w_view,
                 height=800,
                 resizable=True,
                 buttons=OKCancelButtons)
コード例 #26
0
class TextBox (HasPrivateTraits):
    message = Str

    view = View([
        Item(name='message',
             show_label=False,
             style='readonly',
             editor=CodeEditor(),
             ),

    ],
        buttons=['OK'],
#        kind='modal',
        width=800,
        height=600,
        resizable=True,
    )
コード例 #27
0
ファイル: value_editor.py プロジェクト: enthought/traitsui
 def init(self, parent):
     """Finishes initializing the editor by creating the underlying toolkit
     widget.
     """
     self.update_editor()
     editor = TreeEditor(
         auto_open=self.factory.auto_open,
         hide_root=True,
         editable=False,
         nodes=value_tree_nodes,
     )
     self._ui = self.edit_traits(
         parent=parent,
         view=View(Item("root", show_label=False, editor=editor),
                   kind="subpanel"),
     )
     self._ui.parent = self.ui
     self.control = self._ui.control
コード例 #28
0
def icon_button_editor(trait, name, label=None, editor_kw=None, **kw):
    if editor_kw is None:
        editor_kw = {}

    name = add_extension(name, '.png')
    # name = '{}.png'.format(name)
    kw['show_label'] = label is not None
    kw['label'] = label or ''
    image = icon(name)

    return Item(
        trait,
        style='custom',
        editor=ButtonEditor(
            image=image,
            # style='toolbar',
            **editor_kw),
        **kw)
コード例 #29
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'))))
コード例 #30
0
ファイル: tool.py プロジェクト: sgallet/pychron
 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
コード例 #31
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)