How to use the traits.api.Int 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 / lasers / points / maker.py View on Github external
velocity = Float

    def _get_controls(self):
        return Item('velocity', label='Velocity mm/min')

    def _accept_point(self, ptargs):
        self.canvas.new_line_point(point_color=self.point_color,
                                   line_color=self.point_color,
                                   velocity=self.velocity,
                                   **ptargs)


class PolygonMaker(FinishableMaker):
    velocity = Float(1.0)
    use_convex_hull = Bool(True)
    scan_size = Int(50)
    use_outline = Bool
    offset = Int(50)
    find_min = Bool(True)

    def _get_controls(self):
        g = VGroup(Item('velocity', label='Velocity mm/min'),
                   Item('use_convex_hull'),
                   Item('scan_size', label='Scan H (um)'),
                   Item('find_min', label='Find Min. Lines'),
                   HGroup(Item('use_outline'), Item('offset', show_label=False, enabled_when='use_outline'))
        )
        return g

    def _save(self):
        pe = self.stage_manager.points_programmer.polygon_entry
github ptomato / Beams / beams / Camera.py View on Github external
from traitsui.api import View, Label

class CameraError(Exception):
    def __init__(self, msg, cam):
        self.msg = msg
        self.camera_number = cam

    def __str__(self):
        return '{0} on camera {1}'.format(self.msg, self.camera_number)


class Camera(HasTraits):
    camera_number = Int(-1)
    id_string = Str()
    resolution = Tuple(Int(), Int())
    roi = Tuple(Int(), Int(), Int(), Int())
    frame_rate = Range(1, 500, 30)
    frame = Array()

    # Default configuration panel
    view = View(Label('No settings to configure'))

    def __enter__(self):
        self.open()
        return self

    def __exit__(self, *args):
        self.close()
        return False  # don't suppress exceptions

    def open(self):
        raise NotImplementedError()
github enthought / rested / rested / rest_editor_view.py View on Github external
cursor.movePosition(QtGui.QTextCursor.NextWord, QtGui.QTextCursor.MoveAnchor)
        on_border = self._chars_at_cursor(cursor, 1) == '+'
        cursor.setPosition(old_pos)
        return on_border


class ReSTHTMLPairView(HasTraits):

    model = Instance(ReSTHTMLPair)

    # ReST editor related traits
    title = Property(Str, depends_on='model.filepath, model.dirty')
    selected_line = Int
    selected_text = Str
    selected_start_pos = Int
    selected_end_pos = Int
    _editor_action = Event
    _editor_action_type = Enum('undo', 'redo', 'cut', 'copy', 'paste',
                               'selectAll')

    _new_selection = Str
    _replace_selection_action = Event
    _increase_selection = Int
    _increase_selection_action = Event
    _sync_scrollbar_rst2html_action = Event
    _sync_scrollbar_html2rst_action = Event
    _find_action = Event
    _replace_action = Event
    _change_font_action = Event
    _font = QtGui.QFont()
    sync_on_change = Bool(True)
github enthought / rested / rested / rest_editor_view.py View on Github external
_increase_selection = Int
    _increase_selection_action = Event
    _sync_scrollbar_rst2html_action = Event
    _sync_scrollbar_html2rst_action = Event
    _find_action = Event
    _replace_action = Event
    _change_font_action = Event
    _font = QtGui.QFont()
    sync_on_change = Bool(True)

    _fix_underline_action = Event
    _fix_overline_action = Event

    _fix_table_action = Event

    _html_pos = Int
    _get_html_pos_action = Event
    _set_html_pos_action = Event

    auto_table_fix = Bool(False)

    # HTML view related traits
    html = Property(Str, depends_on='model.html')
    base_url = Property(Str, depends_on='model.filepath')

    # Warning related traits
    dclicked_warning = Event
    show_warning_lines = Bool(True)
    warning_lines = Property(List(Int),
                             depends_on='model.warnings, show_warning_lines')

    def source_editor_action(self, action):
github acoular / acoular / acoular / tprocess.py View on Github external
source = Instance(SamplesGenerator)    
    
    #: Trigger data from :class:`acoular.tprocess.Trigger`.
    trigger = Instance(Trigger) 
    
    # internal identifier
    digest = Property(depends_on=['source.digest', 
                                  'trigger.digest', 
                                  'trigger_per_revo',
                                  'rot_direction',
                                  'interp_points',
                                  'start_angle'])
    
    #: Trigger signals per revolution,
    #: defaults to 1.
    trigger_per_revo = Int(1,
                   desc ="trigger signals per revolution")
        
    #: Flag to set counter-clockwise (1) or clockwise (-1) rotation,
    #: defaults to -1.
    rot_direction = Int(-1,
                   desc ="mathematical direction of rotation")
    
    #: Points of interpolation used for spline,
    #: defaults to 4.
    interp_points = Int(4,
                   desc ="Points of interpolation used for Spline")
    
    #: rotation angle in radians for first trigger position
    start_angle = Float(0,
                   desc ="rotation angle for trigger position")
github NMGRL / pychron / pychron / pipeline / editors / group_age_editor.py View on Github external
def _get_age_kind_text(self):
        pv = self.item.get_preferred_obj('age')
        return pv.kind


class SubGroupAdapter(GroupAdapter):
    columns = [('Status', 'tag'),
               ('Group', 'group_id'),
               ('SubGroup', 'subgroup_id'),
               ('Label', 'label_name'),
               ('Age Kind', 'age_kind'),
               ('Error', 'age_error_kind')
               ]

    subgroup_id_width = Int(60)
    tag_width = Int(60)
    tag_text = Property

    def _get_tag_text(self):
        return 'Omit' if self.item.is_omitted() else 'Include'

    def get_menu(self, obj, trait, row, column):
        m = MenuManager(Action(name='Toggle Omit', action='toggle_omit'))
        return m


class AnalysesAdapter(SubGroupAdapter):
    columns = [
        ('RunID', 'record_id'),
        ('Tag', 'tag'),
        ('Group', 'group_id'),
        ('SubGroup', 'subgroup'),
github NMGRL / pychron / pychron / pipeline / plot / options / spectrum.py View on Github external
from pychron.pipeline.plot.options.figure_plotter_options import SIZES
from pychron.pipeline.plot.options.option import SpectrumPlotOptions
from pychron.pipeline.plot.options.spectrum_group_options import SpectrumGroupEditor, SpectrumGroupOptions
from pychron.pychron_constants import ERROR_TYPES

plat_regex = re.compile(r'\w{1,2}-{1}\w{1,2}$')


class SpectrumOptions(AgeOptions):
    label = 'Spectrum'
    aux_plot_name = 'Age'
    aux_plot_klass = SpectrumPlotOptions
    edit_plateau_criteria = Button

    step_nsigma = dumpable(Int, 2)
    pc_nsteps = dumpable(Int, 3)
    pc_gas_fraction = dumpable(Float, 50)
    include_j_error_in_plateau = dumpable(Bool, True)
    plateau_age_error_kind = dumpable(Enum, *ERROR_TYPES)

    display_extract_value = dumpable(Bool, False)
    display_step = dumpable(Bool, False)
    display_plateau_info = dumpable(Bool, True)
    display_integrated_info = dumpable(Bool, True)
    plateau_sig_figs = dumpable(Int)
    integrated_sig_figs = dumpable(Int)

    plateau_font_size = dumpable(Enum, *SIZES)
    integrated_font_size = dumpable(Enum, *SIZES)
    step_label_font_size = dumpable(Enum, *SIZES)
    envelope_alpha = dumpable(Range, 0, 100, style='simple')
    envelope_color = dumpable(Color)
github enthought / pyface / pyface / i_system_metrics.py View on Github external
#
# Thanks for using Enthought open source!

""" The interface to system metrics (screen width and height etc). """


from traits.api import Int, Interface, Tuple


class ISystemMetrics(Interface):
    """ The interface to system metrics (screen width and height etc). """

    # 'ISystemMetrics' interface -------------------------------------------

    #: The width of the screen in pixels.
    screen_width = Int()

    #: The height of the screen in pixels.
    screen_height = Int()

    #: Background color of a standard dialog window as a tuple of RGB values
    #: between 0.0 and 1.0.
    # FIXME v3: Why isn't this a traits colour?
    dialog_background_color = Tuple()


class MSystemMetrics(object):
    """ The mixin class that contains common code for toolkit specific
    implementations of the ISystemMetrics interface.
github gallantlab / pycortex / cortex / mixer.py View on Github external
figure = Instance(MlabSceneModel, ())
    data_srcs = Any
    surfs = Any

    colormap = Enum(*lut_manager.lut_mode_list())
    fliplut = Bool
    show_colorbar = Bool
    vmin = Float
    vmax = Float

    #tex = Instance(ImageReader, ())
    tex = Instance(Source, ())
    texres = Float(default_texres)
    rois = Any
    roilabels = Dict
    labelsize = Int(default_labelsize)

    showrois = Bool(False)
    showlabels = Bool(False)

    reset_btn = Button(label="Reset View")
    datavars = List(DataPack)
    datapack = Instance(DataPack)

    saved_views = List
    viewpoint = Instance(SavedView)

    def __init__(self, points, flatpolys, fidpolys, coords, data=None, dataname=None, svgfile=None, **kwargs):
        super(Mixer, self).__init__(points=points, flatpolys=flatpolys, fidpolys=fidpolys, coords=coords, **kwargs)
        if data is not None:
            self.data = data
github NMGRL / pychron / pychron / processing / tasks / recall / context_editor.py View on Github external
('Ar39', 'ar39'),
               ('Ar38', 'ar38'),
               ('Ar37', 'ar37'),
               ('Ar36', 'ar36')]
    font = '10'
    record_id_width = Int(90)
    rundate_width = Int(125)
    sample_width = Int(100)
    cleanup_width = Int(80)
    duration_width = Int(80)
    extract_value_width = Int(80)
    position_width = Int(80)
    tag_width = Int(50)

    ar40_width = Int(70)
    ar39_width = Int(70)
    ar38_width = Int(70)
    ar37_width = Int(70)
    ar36_width = Int(70)

    ar40_text = Property
    ar39_text = Property
    ar38_text = Property
    ar37_text = Property
    ar36_text = Property

    def _get_ar40_text(self):
        return self._get_intensity('Ar40')

    def _get_ar39_text(self):
        return self._get_intensity('Ar39')