How to use the traits.api.Button function in traits

To help you get started, we’ve selected a few traits 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 NMGRL / pychron / pychron / experiment / queue / increment_heat_template.py View on Github external
return self._beam_diameter

    def _set_beam_diameter(self, v):
        self._beam_diameter = v


class BaseIncrementalHeatTemplate(Viewable):
    steps = List
    step_klass = BaseIncrementalHeatStep
    adapter_klass = BaseIncrementalHeatAdapter

    name = Property(depends_on='path')
    path = File
    names = List

    save_button = Button('save')
    save_as_button = Button('save as')
    add_row = Button('add step')
    title = Property

    selected = Any
    refresh_needed = Event

    units = Enum('', 'watts', 'temp', 'percent')

    gduration = Float
    gcleanup = Float

    # ===============================================================================
    # persistence
    # ===============================================================================
    def load(self, path):
github NMGRL / pychron / pychron / dashboard / server.py View on Github external
def set_nfail(elem, kw):
    nfail = elem.find('nfail')
    if nfail is not None:
        try:
            kw['nfail'] = int(nfail.text.strip())
        except ValueError:
            pass


class DashboardServer(Loggable):
    devices = List
    values = List
    selected_device = Instance(DashboardDevice)
    extraction_line_manager = Instance('pychron.extraction_line.extraction_line_manager.ExtractionLineManager')
    clear_button = Button('Clear')

    notifier = Instance(Notifier, ())
    emailer = Instance('pychron.social.emailer.Emailer')
    labspy_client = Instance('pychron.labspy.client.LabspyClient')

    use_db = False
    _alive = False

    def activate(self):
        if not self.extraction_line_manager:
            self.warning_dialog('Extraction Line Plugin not initialized. Will not be able to take valve actions')

        self.setup_notifier()

        self.load_devices()
        if self.devices:
github mne-tools / mne-python / mne / gui / _coreg_gui.py View on Github external
cancel_icp = Button(label=u'■')
    reset_tr = Button(label=_RESET_LABEL)
    fit_icp_running = DelegatesTo('model')

    # fit info
    fid_eval_str = DelegatesTo('model')
    points_eval_str = DelegatesTo('model')

    # saving
    can_prepare_bem_model = DelegatesTo('model')
    can_save = DelegatesTo('model')
    scale_labels = DelegatesTo('model')
    copy_annot = DelegatesTo('model')
    prepare_bem_model = DelegatesTo('model')
    save = Button(label="Save...")
    load_trans = Button(label='Load...')
    queue = Instance(queue.Queue, ())
    queue_feedback = Str('')
    queue_current = Str('')
    queue_len = Int(0)
    queue_status_text = Property(
        Str, depends_on=['queue_feedback', 'queue_current', 'queue_len'])

    fitting_options_panel = Instance(FittingOptionsPanel)
    fitting_options = Button('Fitting options...')

    def _fitting_options_panel_default(self):
        return FittingOptionsPanel(model=self.model)

    view = _make_view_coreg_panel()

    def __init__(self, *args, **kwargs):  # noqa: D102
github eteq / astropysics / astropysics / gui / spylot.py View on Github external
maintool = Tuple(Instance(Interactor),Instance(AbstractOverlay))

    featureselmode = Enum(['No Selection','Click Select','Range Select','Base Select','Click Delete'])
    editfeatures = Button('Features...')
    showfeatures = Bool(True)
    featurelocsmooth = Float(None)
    featurelocsize = Int(200)
    featurelist = List(Instance(spec.SpectralFeature))

    selectedfeatureindex = Int
    deletefeature = Button('Delete')
    idfeature = Button('Identify')
    recalcfeature = Button('Recalculate')
    clearfeatures = Button('Clear')

    delcurrspec = Button('Delete Current')
    saveloadfile = File(filter=['*.specs'])
    savespeclist = Button('Save Spectra')
    loadspeclist = Button('Load Spectra')
    loadaddfile = File(filter=['*.fits'])
    loadaddspec = Button('Add Spectrum')
    loadaddspectype = Enum('wcs','deimos','astropysics')

    titlegroup = HGroup(Item('specleft',show_label=False,enabled_when='currspeci>0'),
                         spring,
                         Label('Spectrum #',height=0.5),
                         Item('currspecip1',show_label=False,editor=RangeEditor(low_name='lowerspecip1',high_name='upperspecip1',mode='spinner')),
                         Item('_titlestr',style='readonly',show_label=False),
                         spring,
                         Item('specright',show_label=False,enabled_when='currspeci<(len(specs)-1)'))

    speclistgroup = HGroup(Label('Spectrum List:'),spring,
github ruoyu0088 / scpy2 / traitslib / utils.py View on Github external
class AskName(HasTraits):
    name = Unicode(u"")
    view = View(
        Item("name", label=u"名称"),
        kind="modal",
        buttons=OKCancelButtons
    )


class SettingManager(HasTraits):
    current_name = Unicode
    settings = Any
    names = List
    save_button = Button(u"保存设置")
    remove_button = Button(u"删除设置")
    target = Any

    view = View(
        HGroup(
            Item("current_name", editor=EnumEditor(name="object.names")),
            "save_button", "remove_button",
            show_labels=False
        )
    )

    def __init__(self, **kw):
        super(SettingManager, self).__init__(**kw)
        try:
            with open(self.setting_path(), "rb") as f:
                settings = json.load(f)
                self.settings = OrderedDict(settings)
github JohnKendrick / PDielec / PDielec / ViewerClass.py View on Github external
from traits.api import HasTraits, Button, Range, Float, Int, Instance, on_trait_change, Property
from traitsui.api import View, Item, Group, HGroup, RangeEditor, Label, spring
from mayavi.core.api import PipelineBase
from mayavi.core.ui.api import MayaviScene, SceneEditor, MlabSceneModel
import numpy as np
from mayavi import mlab
from PDielec.Constants import covalent_radii, elemental_colours

class ViewerClass(HasTraits):
    number_of_modesm1 = 0
    maxdisplacement = 0.3
    gui_mode_selection    = Int(label="Mode")
    gui_maxdisplacement   = Float(maxdisplacement,label="Displacement")
    gui_savepicture_button = Button('Snapshot')
    gui_animate_button    = Button('Animate')
    gui_exit_button       = Button('Exit')
    # gui_exit_button.label = '?????'
    #from objbrowser import browse
    #browse(gui_exit_button)
    selected_mode_frequency = Property(Float, depends_on = ['gui_mode_selection'], label="Fequency")
#
    scene = Instance(MlabSceneModel, ())
    plot = Instance(PipelineBase)
    view = View(Item('scene', editor=SceneEditor(scene_class=MayaviScene),
                     height=250, width=300, show_label=False,resizable=True),
                Group(
                    Item('gui_mode_selection',
                         editor =  RangeEditor(low=0, high=number_of_modesm1, high_name='number_of_modesm1',format='%d',mode='auto')
                        ),
#jk                    Label('Select mode number for display of displacements'),
github NMGRL / pychron / pychron / processing / fits / filter_fit_selector.py View on Github external
filter_iterations = Int
    filter_std_devs = Int
    truncate = Str
    include_baseline_error = Bool

    def _filter_outliers_changed(self):
        if self.filter_outliers:
            if not self.filter_iterations:
                self.filter_iterations = 1
            if not self.filter_std_devs:
                self.filter_std_devs = 2


class FilterFitSelector(FitSelector):
    fit_klass = FilterFit
    filter_all_button = Button('Toggle Filter')
    filter_state = Bool

    inc_baseline_all_button = Button('Toggle Inc. Base')
    inc_baseline_state = Bool

    def _filter_all_button_fired(self):
        self.filter_state = not self.filter_state
        fs = self._get_fits()
        for fi in fs:
            fi.filter_outliers = self.filter_state

    def _inc_baseline_all_button_fired(self):
        self.inc_baseline_state = not self.inc_baseline_state
        fs = self._get_fits()
        for fi in fs:
            fi.include_baseline_error = self.inc_baseline_state
github mne-tools / mne-python / mne / gui / _viewer.py View on Github external
class HeadViewController(HasTraits):
    """Set head views for the given coordinate system.

    Parameters
    ----------
    system : 'RAS' | 'ALS' | 'ARI'
        Coordinate system described as initials for directions associated with
        the x, y, and z axes. Relevant terms are: Anterior, Right, Left,
        Superior, Inferior.
    """

    system = Enum("RAS", "ALS", "ARI", desc="Coordinate system: directions of "
                  "the x, y, and z axis.")

    right = Button()
    front = Button()
    left = Button()
    top = Button()
    interaction = Enum('trackball', 'terrain')

    scale = Float(0.16)

    scene = Instance(MlabSceneModel)

    view = View(VGroup(
        VGrid('0', Item('top', width=_VIEW_BUTTON_WIDTH), '0',
              Item('right', width=_VIEW_BUTTON_WIDTH),
              Item('front', width=_VIEW_BUTTON_WIDTH),
              Item('left', width=_VIEW_BUTTON_WIDTH),
              columns=3, show_labels=False),
        '_',
        HGroup(Item('scale', label='Scale',
github mne-tools / mne-python / mne / gui / _marker_gui.py View on Github external
_write_dig_points(path, self.points)


class MarkerPointSource(MarkerPoints):  # noqa: D401
    """MarkerPoints subclass for source files."""

    file = File(filter=mrk_wildcard, exists=True)
    name = Property(Str, depends_on='file')
    dir = Property(Str, depends_on='file')

    use = List(list(range(5)), desc="Which points to use for the interpolated "
               "marker.")
    enabled = Property(Bool, depends_on=['points', 'use'])
    clear = Button(desc="Clear the current marker data")
    edit = Button(desc="Edit the marker coordinates manually")
    switch_left_right = Button(
        desc="Switch left and right marker points; this is intended to "
             "correct for markers that were attached in the wrong order")
    reorder = Button(desc="Change the order of the marker points")

    view = mrk_view_basic

    @cached_property
    def _get_enabled(self):
        return np.any(self.points)

    @cached_property
    def _get_dir(self):
        if self.file:
            return os.path.dirname(self.file)

    @cached_property
github enthought / mayavi / examples / mayavi / user_mayavi.py View on Github external
######################################################################
# `Worker` class
######################################################################
class Worker(HasTraits):
    """This class basically allows you to create a data set, view it
    and modify the dataset.  This is a rather crude example but
    demonstrates how things can be done.
    """

    # Set by envisage when this is contributed as a ServiceOffer.
    window = Instance('pyface.workbench.api.WorkbenchWindow')

    create_data = Button('Create data')
    reset_data = Button('Reset data')
    view_data = Button('View data')
    scale = Range(0.0, 1.0)
    source = Instance('mayavi.core.source.Source')

    # Our UI view.
    view = View(Item('create_data', show_label=False),
                Item('view_data', show_label=False),
                Item('reset_data', show_label=False),
                Item('scale'),
                resizable=True
                )

    def get_mayavi(self):
        from mayavi.plugins.script import Script
        return self.window.get_service(Script)

    def _make_data(self):