How to use the traitsui.api function in traitsui

To help you get started, we’ve selected a few traitsui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperspy / hyperspy / hyperspy / gui / axes.py View on Github external
# due to a traits ui bug
                                 # editor=tui.RangeEditor(mode="slider"),
                             ),
                         ),
                     ),
                     ),
        )

    view = tui.View(tui.VSplit(view_tuple), title="Navigation sliders"
                    if title is None
                    else title)

    nav.edit_traits(view=view)


data_axis_view = tui.View(
    tui.Group(
        tui.Group(
            tui.Item(name='name'),
            tui.Item(name='size', style='readonly'),
            tui.Item(name='index_in_array', style='readonly'),
            tui.Item(name='index'),
            tui.Item(name='value', style='readonly'),
            tui.Item(name='units'),
            tui.Item(name='navigate', label='navigate'),
            show_border=True,),
        tui.Group(
            tui.Item(name='scale'),
            tui.Item(name='offset'),
            label='Calibration',
            show_border=True,),
        label="Data Axis properties",
github hyperspy / hyperspy / hyperspy / gui / axes.py View on Github external
),
                         ),
                     ),
                     ),
        )

    view = tui.View(tui.VSplit(view_tuple), title="Navigation sliders"
                    if title is None
                    else title)

    nav.edit_traits(view=view)


data_axis_view = tui.View(
    tui.Group(
        tui.Group(
            tui.Item(name='name'),
            tui.Item(name='size', style='readonly'),
            tui.Item(name='index_in_array', style='readonly'),
            tui.Item(name='index'),
            tui.Item(name='value', style='readonly'),
            tui.Item(name='units'),
            tui.Item(name='navigate', label='navigate'),
            show_border=True,),
        tui.Group(
            tui.Item(name='scale'),
            tui.Item(name='offset'),
            label='Calibration',
            show_border=True,),
        label="Data Axis properties",
        show_border=True,),
    title='Axis configuration',)
github enthought / enable / enable / savage / compliance / sike.py View on Github external
def trait_view(self, name=None, view_element=None):
        if name or view_element is not None:
            return super(ProfileResults, self).trait_view(name=name,
                view_element=view_element)

        view = tui.View(
            tui.Group(
                tui.Item('total_time', style='readonly'),
            ),
            tui.Item('records', editor=get_profile_editor(self.adapter),
                show_label=False),

            width=1024,
            height=768,
            resizable=True,
        )
        return view
github enthought / enable / enthought / savage / compliance / xml_view.py View on Github external
""" Convert an ElementTree Element to the view models for viewing in the
    TreeEditor.
    """
    element = Element(tag=root.tag)
    if root.text is not None:
        element.text = root.text.strip()
    for name in sorted(root.keys()):
        element.attributes.append(Attribute(name=name, value=root.get(name)))
    for child in root:
        element.children.append(xml_to_tree(child))
    return element


xml_tree_editor = tui.TreeEditor(
    nodes = [
        tui.TreeNode(
            node_for = [Element],
            children = 'kids',
            label = 'label',
            menu = False,
        ),
        tui.TreeNode(
            node_for = [Attribute],
            children = '',
            label = 'label',
            menu = False,
        )
    ],
    editable = False,
    show_icons = False,
)
github hyperspy / hyperspyUI / hyperspyui / widgets / dataviewwidget.py View on Github external
def edit_traits(self, comp, buttons=True):
        try:
            items = [tu.Item('name'), tu.Item('active')]
            for p in comp.parameters:
                name = '.'.join(('object', p.name))
                p_label = p.name.replace('_', ' ').capitalize()
                vi = tu.Item(name + '.value', label=p_label,
                             editor=tu.RangeEditor(low_name=name + '.bmin',
                                                   high_name=name + '.bmax'))
                items.extend((vi, tu.Item(name + '.free')))
            view = tu.View(*items,
                           handler=ComponentEditorHandler(),
                           buttons=tu.OKCancelButtons if buttons else [],
                           default_button=tu.OKButton,
                           kind='live',
                           resizable=True)
            comp.edit_traits(view=view)
        except AttributeError:
            pass
github hyperspy / hyperspy / hyperspy / gui_traitsui / preferences.py View on Github external
from hyperspy.gui_traitsui.utils import (
    register_traitsui_widget, add_display_arg)


class PreferencesHandler(tui.Handler):

    def close(self, info, is_ok):
        # Removes the span selector from the plot
        info.object.save()
        return True

PREFERENCES_VIEW = tui.View(
    tui.Group(tui.Item('General', style='custom', show_label=False, ),
              label='General'),
    tui.Group(tui.Item('Model', style='custom', show_label=False, ),
              label='Model'),
    tui.Group(tui.Item('EELS', style='custom', show_label=False, ),
              label='EELS'),
    tui.Group(tui.Item('EDS', style='custom', show_label=False, ),
              label='EDS'),
    tui.Group(tui.Item('MachineLearning', style='custom',
                       show_label=False,),
              label='Machine Learning'),
    tui.Group(tui.Item('Plot', style='custom', show_label=False, ),
              label='Plot'),
    title='Preferences',
    handler=PreferencesHandler,)

EELS_VIEW = tui.View(
    tui.Group(
        'synchronize_cl_with_ll',
github hyperspy / hyperspyUI / hyperspyui / widgets / dataviewwidget.py View on Github external
def edit_traits(self, comp, buttons=True):
        try:
            items = [tu.Item('name'), tu.Item('active')]
            for p in comp.parameters:
                name = '.'.join(('object', p.name))
                p_label = p.name.replace('_', ' ').capitalize()
                vi = tu.Item(name + '.value', label=p_label,
                             editor=tu.RangeEditor(low_name=name + '.bmin',
                                                   high_name=name + '.bmax'))
                items.extend((vi, tu.Item(name + '.free')))
            view = tu.View(*items,
                           handler=ComponentEditorHandler(),
                           buttons=tu.OKCancelButtons if buttons else [],
                           default_button=tu.OKButton,
                           kind='live',
                           resizable=True)
            comp.edit_traits(view=view)
        except AttributeError:
            pass
github yosefm / tracer / examples / parabolic_dish_gui.py View on Github external
    @t_api.on_trait_change('refl, concent')
    def recreate_dish(self):
        """
        Makes sure that the scene is redrawn upon dish design changes.
        """
        dish, source = self.create_dish_source()
        self.clear_scene()
        self.set_assembly(dish)
        self.set_source(source)
    
    # Parameters of the form that is shown to the user:
    view = tui.View(
        tui.Item('_scene', editor=SceneEditor(scene_class=MayaviScene),
            height=500, width=500, show_label=False),
        tui.HGroup('-', 
            tui.Item('concent', editor=tui.TextEditor(evaluate=float, auto_set=False)), 
            tui.Item('refl', editor=tui.TextEditor(evaluate=float, auto_set=False))))


if __name__ == '__main__':
    scene = DishScene()
    scene.configure_traits()
github enthought / traitsui / examples / tutorials / traitsui_4.0 / editors / tabular_editor / numpy_array.py View on Github external
from traitsui.tabular_adapter \
    import TabularAdapter

from traitsui.menu \
    import NoButtons

from pyface.image_resource \
    import ImageResource

#--------------------------------------------------------------------

# Necessary because of the dynamic way in which the demos are loaded:
import traitsui.api

search_path = [ join( dirname( traitsui.api.__file__ ),
                      'demo', 'Advanced' ) ]

#--[Tabular Adapter Definition]-------------------------------------------------

class ArrayAdapter ( TabularAdapter ):

    columns = [ ( 'i', 'index' ), ( 'x', 0 ), ( 'y', 1 ),  ( 'z', 2 ) ]

    font        = 'Courier 10'
    alignment   = 'right'
    format      = '%.4f'
    index_text  = Property
    index_image = Property

    def _get_index_text ( self ):
        return str( self.row )
github enthought / traitsui / examples / tutorials / traitsui_4.0 / editors / tabular_editor / sm_person_example.py View on Github external
from traitsui.tabular_adapter \
    import TabularAdapter

from traitsui.menu \
    import NoButtons

from pyface.image_resource \
    import ImageResource

#--------------------------------------------------------------

# Necessary because of the dynamic way in which the demos are loaded:
import traitsui.api

search_path = [join(dirname(traitsui.api.__file__),
                    'demo', 'Advanced')]

#--[Person Class]---------------------------------------------------------


class Person(HasTraits):

    name = Str
    address = Str
    age = Int

#--[MarriedPerson Class]--------------------------------------------------


class MarriedPerson(Person):