Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def traits_view(self):
v = View(BorderVGroup(UItem('analysis_groups',
editor=TabularEditor(adapter=self.adapter)),
label='Summary'))
return v
# ============= EOF =============================================
from tvtk.pyface.scene_editor import SceneEditor
from mayavi.tools.mlab_scene_model import MlabSceneModel
from mayavi.core.ui.mayavi_scene import MayaviScene
######################################################################
class ActorViewer(HasTraits):
# The scene model.
scene = Instance(MlabSceneModel, ())
######################
# Using 'scene_class=MayaviScene' adds a Mayavi icon to the toolbar,
# to pop up a dialog editing the pipeline.
view = View(Item(name='scene',
editor=SceneEditor(scene_class=MayaviScene),
show_label=False,
resizable=True,
height=500,
width=500),
resizable=True
)
def __init__(self, **traits):
HasTraits.__init__(self, **traits)
self.generate_data()
def generate_data(self):
# Create some data
X, Y = mgrid[-2:2:100j, -2:2:100j]
R = 10*sqrt(X**2 + Y**2)
def traits_view(self):
v = View(
UItem('container', editor=ComponentEditor(),
style='custom'),
width=500,
height=500,
resizable=True,
)
return v
#-------------------------------------------------------------------------
# 'TextInfo' class:
#-------------------------------------------------------------------------
class TextInfo(MFileDialogModel):
""" Defines a file dialog extension that displays a file's contents as text.
"""
# The file's text content:
text = Property(depends_on='file_name')
#-- Traits View Definitions ----------------------------------------------
view = View(
Item('text',
style='readonly',
show_label=False,
editor=CodeEditor()
)
)
#-- Property Implementations ---------------------------------------------
@cached_property
def _get_text(self):
try:
if getsize(self.file_name) > MAX_SIZE:
return 'File too big...'
with open(self.file_name, 'rb') as fh:
from traitsui.table_column \
import ObjectColumn
from traitsui.table_filter \
import EvalFilterTemplate, MenuFilterTemplate, RuleFilterTemplate, \
RuleTableFilter
# A helper class for 'Department' below:
class Employee ( HasTraits ):
name = Str
age = Int
gender = Enum( 'Male', 'Female' )
phone = Regex( value = '000-0000', regex = '\d\d\d[-]\d\d\d\d')
traits_view = View(
'name', 'age', 'phone',
title = 'Create new employee',
width = 0.18,
buttons = [ 'OK', 'Cancel' ]
)
# For readability, the parameters of the demo TableEditor are set here, rather
# than in the View:
table_editor = TableEditor(
columns = [ ObjectColumn( name = 'name', width = 0.30 ),
ObjectColumn( name = 'age', width = 0.20 ),
ObjectColumn( name = 'gender', width = 0.25 ),
ObjectColumn( name = 'phone', width = 0.25 ) ],
auto_size = False,
deletable = True,
sort_model = True,
# An outline source, optionally used to choose the bounds of the
# outline.
outline_source = Instance(tvtk.OutlineSource, ())
bounds = DelegatesTo('outline_source',
desc="the bounds of the outline: xmin, xmax, ymin, ymax")
manual_bounds = Bool(
desc="whether the bounds are automatically inferred from "
"the data source")
# Create the UI for the traits.
# The controls for the outline_filter should be enabled only when the
# Cornered Outline Filter is selected.
view = View(Group(
Group(
Item(name='outline_mode'),
Item(name='outline_filter',
style='custom',
enabled_when='outline_mode == "cornered"',
visible_when='outline_mode == "cornered"',
resizable=True,
show_label=False),
label='Outline',
show_labels=False),
Group('manual_bounds',
Item('bounds', enabled_when='manual_bounds'),
label='Bounds',
),
Item(name='actor', style='custom'),
layout='tabbed',
def control_traits_view(self):
return View(HGroup(Item('channel',
editor = EnumEditor(name = 'handler.context.previous_wi.channels')),
Item('file',
show_label = False)),
handler = self)
# Define a Color trait to view:
color_trait = RGBColor
# Items are used to define the demo display, one item per editor style:
color_group = Group(
Item( 'color_trait', style = 'simple', label = 'Simple' ),
Item( '_' ),
Item( 'color_trait', style = 'custom', label = 'Custom' ),
Item( '_'),
Item( 'color_trait', style = 'text', label = 'Text' ),
Item( '_'),
Item( 'color_trait', style = 'readonly', label = 'ReadOnly' )
)
# Demo view
view1 = View(
color_group,
title = 'ColorEditor',
buttons = ['OK'],
resizable = True
)
# Create the demo:
demo = ColorEditorDemo()
# Run the demo (if invoked from the command line):
if __name__ == '__main__':
demo.configure_traits()
self.ctl._proc_export_to_scalar()
def do_recalculate(self,info):
self.ctl._proc_recalculate()
############################################################################
class AdjmatChooserWindow(UnstableDatasetSpecificSubwindow):
please_note=Str("All but first field are optional. Specify adjmat order "
"if the desired display order differs from the existing matrix order."
" Specify unwanted channels as 'delete' in the label order. Data "
"field name applies to the data field for .mat matrices only.")
require_note=Str('Enter any ROIs you would like to force to display on the '
'circle plot. You must spell them precisely, e.g. "lh_frontalpole"')
open_adjmat_order=Button('Browse')
RequireButton=Action(name='clear all req\'d ROIs',action='do_rqls_clear')
traits_view=View(
Group(
current_dataset_item,
Item(name='please_note',style='readonly',height=140,width=250),
Item(name='adjmat',object='object.ctl',label='Adjmat',
editor=CustomFileEditor()),
Item(name='adjmat_order',object='object.ctl',label='Label Order',
editor=CustomFileEditor()),
Item(name='max_edges',object='object.ctl',label='Max Edges'),
Item(name='field_name',object='object.ctl',
label='Field (.mat files)',editor=TextEditor()),
Item(name='ignore_deletes',object='object.ctl',
label='Ignore deletes'),
label='Matrix'),
Group(
VGroup(
current_dataset_item,
def traits_view(self):
v = View(UItem('console_display',
style='custom'))
return v