Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
address = Str
age = Int
# surname is displayed in qt-only row label:
surname = Property(fget=lambda self: self.name.split()[-1],
depends_on='name')
#-- MarriedPerson Class Definition ---------------------------------------------
class MarriedPerson(Person):
partner = Instance(Person)
#-- Tabular Adapter Definition -------------------------------------------------
class ReportAdapter(TabularAdapter):
columns = [ ('Name', 'name'),
('Age', 'age'),
('Address', 'address'),
('Spouse', 'spouse') ]
row_label_name = 'surname'
# Font fails with wx in OSX; see traitsui issue #13:
# font = 'Courier 10'
age_alignment = Constant('right')
MarriedPerson_age_image = Property
MarriedPerson_bg_color = Color(0xE0E0FF)
MarriedPerson_spouse_text = Property
Person_spouse_text = Constant('')
# limitations under the License.
# ===============================================================================
# ============= enthought library imports =======================
from traits.api import HasTraits , Float, Any, Button, Bool, List
from traitsui.api import View, Item, spring, ButtonEditor, HGroup, \
VGroup, UItem
# ============= standard library imports ========================
from numpy import polyfit, linspace
# ============= local library imports ==========================
from spectrometer_task import SpectrometerTask
from traitsui.tabular_adapter import TabularAdapter
from pychron.graph.guide_overlay import GuideOverlay
from pychron.core.ui.tabular_editor import myTabularEditor
class ResultsAdapter(TabularAdapter):
columns = [('N', 'cnt'), ('Endpoints', 'endpoints'), ('Linear', 'linear')]
class Result(HasTraits):
linear = Float
endpoints = Float
def calculate(self, xs, ys, rise, starttime):
ti = xs[-1]
run = (ti - starttime) / 60.
rrendpoints = rise / run
rrfit = polyfit(linspace(0, run, len(ys)), ys, 1)[0]
self.endpoints = rrendpoints
self.linear = rrfit
return rrendpoints, rrfit, ti, run
class RiseRate(SpectrometerTask):
selected='selected_unknowns',
operations=['delete'])),
UItem('object.selected.references',
visible_when='object.selected.references',
editor=TabularEditor(adapter=self.references_adapter,
update='refresh_table_needed',
# drag_external=True,
multi_select=True,
dclicked='dclicked_references',
selected='selected_references',
operations=['delete']))),
handler=AnalysesPaneHandler())
return v
class RepositoryTabularAdapter(TabularAdapter):
columns = [('Name', 'name'),
('Ahead', 'ahead'),
('Behind', 'behind')]
def get_menu(self, obj, trait, row, column):
return MenuManager(Action(name='Refresh Status', action='refresh_repository_status'),
Action(name='Get Changes', action='pull'),
Action(name='Share Changes', action='push'),
Action(name='Delete Local Changes', action='delete_local_changes'))
def get_bg_color(self, obj, trait, row, column=0):
if self.item.behind:
c = LIGHT_RED
elif self.item.ahead:
c = LIGHT_YELLOW
else:
# ============= local library imports ==========================
from pychron.core.progress import progress_loader
from pychron.database.core.database_adapter import DatabaseAdapter
from pychron.database.core.query import Query, compile_query
from pychron.viewable import Viewable
from pychron.core.ui.tabular_editor import myTabularEditor
# from pychron.database.core.base_results_adapter import BaseResultsAdapter
from pychron.core.ui.custom_label_editor import CustomLabel
from traitsui.tabular_adapter import TabularAdapter
from pychron.core.ui.gui import invoke_in_main_thread
from pychron.column_sorter_mixin import ColumnSorterMixin
class BaseTabularAdapter(TabularAdapter):
columns = [('ID', 'record_id'),
('Timestamp', 'timestamp')]
# class ColumnSorterMixin(HasTraits):
# _sort_field = None
# _reverse_sort = False
# column_clicked = Any
#
# def _column_clicked_changed(self, event):
# values = event.editor.value
#
# fields = [name for _, name in event.editor.adapter.columns]
# field = fields[event.column]
# self._reverse_sort = not self._reverse_sort
#
# self._sort_columns(values, field)
name = Str
reactor = Str
def traits_view(self):
v = okcancel_view(HGroup('name', 'reactor'),
buttons=['OK', 'Cancel', 'Revert'],
title='New Production Ratio')
return v
class ProductionAdapter(TabularAdapter):
columns = [('Name', 'name'), ('Reactor', 'reactor'), ('Last Modified', 'last_modified')]
font = '10'
class TrayAdapter(TabularAdapter):
columns = [('Name', 'name')]
name_text = Property
def _get_name_text(self):
return self.item
class EditView(ModelView):
title = 'Edit Level'
def traits_view(self):
rgrp = BorderHGroup(UItem('selected_reactor_name',
editor=EnumEditor(name='reactor_names')),
icon_button_editor('add_reactor_button', 'add',
tooltip='Add Default Production for the selected '
'Reactor to this Irradiation level'),
"""
Creating a multi-select list box
How to use a TabularEditor to create a multi-select list box.
This demo uses two TabularEditors, side-by-side. Selections from the left table
are shown in the right table. Each table has only one column.
"""
from traits.api import HasPrivateTraits, List, Str, Property
from traitsui.api import View, HGroup, UItem, TabularEditor
from traitsui.tabular_adapter import TabularAdapter
class MultiSelectAdapter(TabularAdapter):
""" This adapter is used by both the left and right tables
"""
# Titles and column names for each column of a table.
# In this example, each table has only one column.
columns = [('', 'myvalue')]
# Magically named trait which gives the display text of the column named
# 'myvalue'. This is done using a Traits Property and its getter:
myvalue_text = Property
# The getter for Property 'myvalue_text' simply takes the value of the
# corresponding item in the list being displayed in this table.
# A more complicated example could format the item before displaying it.
def _get_myvalue_text(self):
return self.item
from traitsui.api import View, UItem, VGroup, EnumEditor, \
HGroup, CheckListEditor, spring, Group, HSplit, Tabbed
from traitsui.menu import Action
from traitsui.tabular_adapter import TabularAdapter
from pychron.core.helpers.traitsui_shortcuts import okcancel_view
from pychron.core.pychron_traits import BorderVGroup, BorderHGroup
from pychron.core.ui.combobox_editor import ComboboxEditor
from pychron.core.ui.qt.tabular_editors import FilterTabularEditor
from pychron.core.ui.tabular_editor import myTabularEditor
from pychron.envisage.browser.adapters import ProjectAdapter, PrincipalInvestigatorAdapter, LoadAdapter
from pychron.envisage.browser.pane_model_view import PaneModelView
from pychron.envisage.icon_button_editor import icon_button_editor
class AnalysisGroupsAdapter(TabularAdapter):
columns = [('Set', 'name'),
('Date', 'create_date')]
font = 'Arial 10'
def get_menu(self, obj, trait, row, column):
actions = [Action(name='Delete', action='delete_analysis_group')]
return MenuManager(*actions)
class BaseBrowserSampleView(PaneModelView):
configure_date_filter_button = Button
configure_analysis_type_filter_button = Button
configure_mass_spectrometer_filter_button = Button
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================
# ============= enthought library imports =======================
from traits.api import HasTraits, Enum, List, Instance, File, Str, Password, Dict
from traitsui.api import View, Item, UItem, VGroup, InstanceEditor, ListStrEditor
# ============= standard library imports ========================
# ============= local library imports ==========================
from traitsui.tabular_adapter import TabularAdapter
class IrradiationAdapter(TabularAdapter):
columns = [('Irradiation', 'name')]
class BaseExportDestination(HasTraits):
def to_dict(self):
pass
class FileDestination(BaseExportDestination):
path = File
def to_dict(self):
return {'path': self.path}
def traits_view(self):
v = View(Item('path'))
#============= local library imports ==========================
from pychron.experiment.export.export_spec import ExportSpec
from pychron.database.isotope_database_manager import IsotopeDatabaseManager
from pychron.experiment.utilities.identifier import convert_special_name, make_runid
from pychron.experiment.automated_run.automated_run import assemble_script_blob
from pychron.processing.search.selector_manager import SelectorManager
from pychron.database.database_connection_spec import DBConnectionSpec
# from pychron.progress_dialog import myProgressDialog
import csv
from pychron.database.records.isotope_record import IsotopeRecordView
from threading import Thread
from pychron.core.ui.tabular_editor import myTabularEditor
from traitsui.tabular_adapter import TabularAdapter
from pychron.core.ui.progress_dialog import myProgressDialog
class ExportedAdapter(TabularAdapter):
columns = [('', 'n'), ('RID', 'rid')]
# def get_bg_color(self, *args, **kw):
# if self.item.skipped:
# return 'red'
# else:
# return 'lightgray'
class Exported(HasTraits):
rid = Str
n = Int
skipped = Bool(False)
class MassSpecDestination(HasTraits):
destination = Property
dbconn_spec = Instance(DBConnectionSpec, ())
def _get_destination(self):
def get_menu(self, obj, trait, row, column):
# item = getattr(obj, trait)[row]
actions = [Action(name='Move', action='move_to_session')]
menu = MenuManager(*actions)
return menu
class SimpleSampleAdapter(TabularAdapter):
columns = [('Name', 'name'),
('Material', 'material'),
('Grainsize', 'grainsize')]
font = 'arial 10'
odd_bg_color = '#d6f5f5'
class PrepStepAdapter(TabularAdapter):
columns = [('Date', 'timestamp'),
('Crush', 'crush'),
('Sieve', 'sieve'),
('Wash', 'wash'),
('Frantz', 'frantz'),
('Acid', 'acid'),
('Heavy_liquid', 'heavy_liquid'),
('Pick', 'pick'),
('Image', 'nimages'),
('Comments', 'comment')]
font = 'arial 10'
odd_bg_color = '#f5f5d6'
timestamp_width = Int(100)
crush_width = Int(75)
sieve_width = Int(75)
wash_width = Int(75)