def traits_view(self): ctrl_grp = VGroup( HGroup(UItem('use_project_exclusion'), Item('exclusion_pad', enabled_when='use_project_exclusion')), HGroup(Item('use_offset_analyses', label='Use Offset')), VGroup(HGroup(Item('toggle_analysis_types', label='Toggle')), UItem('analysis_types', style='custom', editor=CheckListEditor( cols=1, name='available_analysis_types')), label='Analysis Types', show_border=True)) v = View(HSplit(ctrl_grp, UItem('graph', style='custom', width=0.80)), buttons=[ 'Cancel', Action(name='Replace', on_perform=self.replace_action), Action(name='Append', on_perform=self.append_action), Action(name='Replace All', on_perform=self.replace_all_action), Action(name='Append All', on_perform=self.append_all_action) ], title='Graphical Filter', kind='livemodal', resizable=True) return v
def disconnect_actions(self, connections): """ Returns a list of Actions for a list of potential disconnects. """ force = (len(connections) == 1) actions = [] for i, connection in enumerate(connections): if connection.feature1 is self: ui_name2 = connection.ui_name2 if (not force) and (ui_name2 != ''): actions.append( Action(name='from the %s in the %s' % (ui_name2, connection.label2), action="self.disconnect('%s',%d)" % (connection.name1, i))) else: actions.append( Action(name='from the %s' % connection.label2, action="self.disconnect('%s',%d)" % (connection.name1, i))) else: ui_name1 = connection.ui_name1 if (not force) and (ui_name1 != ''): actions.append( Action(name='from the %s in the %s' % (ui_name1, connection.label1), action="self.disconnect('%s',%d)" % (connection.name2, i))) else: actions.append( Action(name='from the %s' % connection.label1, action="self.disconnect('%s',%d)" % (connection.name2, i))) return actions
def default_traits_view(self): """ Returns the default view to use for this class. """ # NOTE: I moved the view to this method so we can declare a handler # for the view. Alternatively, we could move the DemoController class # to the top and declare view=Instance(HasTraits) instead. traits_view = View( Item( 'plot', editor=ComponentEditor(), show_label=False, ), menubar=MenuBar( Menu( Action(name="Save Plot", action="save"), # see Controller for Action(name="Load Plot", action="load"), # these callbacks Separator(), CloseAction, name="File", ), ), width=600, height=600, resizable=True, handler=DemoController) return traits_view
class AffectsAverageColumn(ObjectColumn): # Define the context menu for the column: menu = Menu(Action(name='Add', action='column.add(object)'), Action(name='Sub', action='column.sub(object)')) # Right-align numeric values (override): horizontal_alignment = 'center' # Column width (override): width = 0.09 # Don't allow the data to be edited directly: editable = False # Action methods for the context menu items: def add(self, object): """ Increment the affected player statistic. """ setattr(object, self.name, getattr(object, self.name) + 1) def sub(self, object): """ Decrement the affected player statistic. """ setattr(object, self.name, getattr(object, self.name) - 1)
def __init__(self, **traits): """Initialise the object.""" buttons = [ Action(name="Search"), Action(name="Add"), Action(name="Modify"), Action(name="Delete"), CancelButton ] all_perms = list( get_permissions_manager().policy_manager.permissions.values()) perms_editor = SetEditor(values=all_perms, left_column_title="Available Permissions", right_column_title="Assigned Permissions") perms_group = Group(Item(name='permissions', editor=perms_editor), label='Permissions', show_border=True, show_labels=False) super(_RoleView, self).__init__(Item(name='name'), Item(name='description'), perms_group, buttons=buttons, **traits)
def default_traits_view(self): menu = Menu(Action(name='Refresh', action='editor.update_editor'), Action(name='Expand all', action='editor.expand_all')) self.menu = menu nodes = self.tree_generator.get_nodes(menu) self.tree_editor = TreeEditor(nodes=nodes, editable=False, orientation='vertical', hide_root=True, on_select=self._on_select, on_dclick=self._on_dclick) view = View(Group( VSplit(Item(name='_root', editor=self.tree_editor, resizable=True), Item(name='selected', style='custom', resizable=True), show_labels=False, show_border=False)), title='Pipeline browser', help=False, resizable=True, undo=False, revert=False, width=.3, height=.3) return view
def get_menu(self, object, trait, row, column): return MenuManager( Action(name='Group Selected', action='group_by_selected'), Action(name='Group by Labnumber', action='group_by_labnumber'), Action(name='Group by Aliquot', action='group_by_aliquot'), Action(name='Clear Grouping', action='clear_grouping'), Action(name='Unselect', action='unselect'))
def get_menu(self, object, trait, row, column): return MenuManager( Action(name='Recall', action='recall_unknowns'), Action(name='Group Selected', action='unknowns_group_by_selected'), Action(name='Clear Group', action='unknowns_clear_grouping'), Action(name='Clear All Group', action='unknowns_clear_all_grouping'), )
def _quick_drag_menu(self, object): """ Displays the quick drag menu for a specified drag object. """ # Get all the features it could be dropped on: feature_lists = [] if isinstance(object, IFeatureTool): msg = "Apply to" for dc in self.dock_control.dock_controls: if dc.visible and ( object.feature_can_drop_on(dc.object) or object.feature_can_drop_on_dock_control(dc)): from .feature_tool import FeatureTool feature_lists.append([FeatureTool(dock_control=dc)]) else: msg = "Send to" for dc in self.dock_control.dock_controls: if dc.visible: allowed = [ f for f in dc.features if (f.feature_name != "") and f.can_drop(object) ] if len(allowed) > 0: feature_lists.append(allowed) # If there are any compatible features: if len(feature_lists) > 0: # Create the pop-up menu: features = [] actions = [] for list in feature_lists: if len(list) > 1: sub_actions = [] for feature in list: sub_actions.append( Action( name="%s Feature" % feature.feature_name, action="self._drop_on(%d)" % len(features), )) features.append(feature) actions.append( Menu(name="%s the %s" % (msg, feature.dock_control.name), *sub_actions)) else: actions.append( Action( name="%s %s" % (msg, list[0].dock_control.name), action="self._drop_on(%d)" % len(features), )) features.append(list[0]) # Display the pop-up menu: self._object = object self._features = features self.popup_menu(Menu(name="popup", *actions)) self._object = self._features = None
def contextual_menu_contents(self): """ """ actions = (Action(name='Recall', on_perform=self._recall_analysis), Action(name='Set tag', on_perform=self._set_tag), Action(name='Set INVALID', on_perform=self._set_invalid)) # menu = MenuManager(name='recall', *actions) # contents = [menu, ] return actions
def get_menu(self, obj, trait, row, column): if obj.selected_samples: # psenabled = obj.current_task_name in ('Ideogram', 'Spectrum') # psenabled = isinstance(obj, FigureTask) return MenuManager( Action(name='Unselect', action='unselect_samples'), # Action(name='Chronological View', action='on_chrono_view'), Action(name='Configure', action='configure_sample_table'), )
def default_menubar(self): return MenuBar( Menu(Action(name="&Open", action="load_run"), Action(name="&Save", action="save_run"), Action(name="&Exit", action="exit"), name="&File"), Menu(Action(name="About PStudy", action="about_pstudy"), HelpAction, name="Help"))
def traits_view(self): nodes = [ TreeNode(node_for=[InitializationModel], children='trees', icon_open='', label='name'), PackageTreeNode(node_for=[PluginTree], auto_open=True, children='plugins', label='name', menu=MenuManager( Action(name='Enable All', visible_when='not object.all_enabled', action='set_all_enabled'), Action(name='Disable All', visible_when='object.all_enabled', action='set_all_disabled'))), PluginTreeNode(node_for=[Plugin, GlobalValue], menu=MenuManager( Action(name='Enable', action='set_enabled', visible_when='not object.enabled'), Action(name='Disable', visible_when='object.enabled', action='set_disabled'), ), label='name'), GlobalsTreeNode(node_for=[GlobalTree], label='name', auto_open=True, children='values') ] v = View(VGroup( HGroup( Item('default', label='Predefined Initialiation', editor=EnumEditor(name='defaults'))), UItem('model', editor=TreeEditor(nodes=nodes, editable=False, selection_mode='extended', selected='selected', dclick='dclicked', show_disabled=True, refresh_all_icons='refresh_all_needed', refresh_icons='refresh_needed')), VGroup(UItem('description', style='readonly'), show_border=True), VGroup(UItem('help_str', style='readonly'), show_border=True)), title='Edit Initialization - {}'.format(self.model.path_name), handler=PEVHandler(), height=600, width=400, kind='livemodal', buttons=['OK', 'Cancel'], resizable=True) return v
def traits_view(self): cols = [ ObjectColumn(name='name', label='', editable=False), ObjectColumn(name='counts'), ObjectColumn(name='settle', label='Settle (s)'), ObjectColumn(name='isotopes_label', editable=False, width=175, label='Isotopes') ] hgrp = VGroup( UItem('object.hop_sequence.hops', editor=myTableEditor(columns=cols, clear_selection_on_dclicked=True, sortable=False, selected='selected')), HGroup( icon_button_editor('add_hop_button', 'add', tooltip='Add peak hop'), icon_button_editor('remove_hop_button', 'delete', tooltip='Delete selected peak hop', enabled_when='selected'))) sgrp = UItem('selected', style='custom', editor=InstanceEditor()) grp = HSplit(hgrp, sgrp) save_action = Action(name='Save', image=icon('document-save'), enabled_when='object.saveable', action='save') save_as_acion = Action( name='Save As', image=icon('document-save-as'), action='save_as', enabled_when='object.saveasable', ) teditor = myTextEditor(bgcolor='#F7F6D0', fontsize=12, fontsize_name='fontsize', wrap=False, tab_width=15) v = View( VGroup( VGroup(grp, label='Editor'), VGroup(UItem('object.text', editor=teditor, style='custom'), label='Text')), # toolbar=ToolBar(), width=690, title=self.title, buttons=['OK', save_action, save_as_acion], resizable=True) return v
def get_menu(self, object, trait, row, column): column_name = self.column_map[column] if column_name not in ['name', 'average']: menu = Menu( Action(name='Add', action='editor.adapter.add(item, column)'), Action(name='Sub', action='editor.adapter.sub(item, column)')) return menu else: return super(PlayerAdapter, self).get_menu(object, trait, row, column)
def add_menu_factory(): return MenuManager(Action(name='Add Grouping', action='add_grouping'), Action(name='Add Filter', action='add_filter'), Action(name='Add Ideogram', action='add_ideogram'), Action(name='Add Spectrum', action='add_spectrum'), Action(name='Add Series', action='add_series'), name='Add')
def save_menu_factory(): return MenuManager(Action(name='Save PDF Figure', action='add_pdf_figure'), Action(name='Save Iso Evo', action='add_iso_evo_persist'), Action(name='Save Blanks', action='add_blanks_persist'), Action(name='Save ICFactor', action='add_icfactor_persist'), name='Save')
def _get_AutomatedRunSpec_menu(self): item = self.item if item.state in ('success', 'truncated'): evo_actions = [ Action(name='Show All', action='show_evolutions'), Action(name='Show All w/Equilibration', action='show_evolutions_w_eq'), Action(name='Show All w/Equilibration+Baseline', action='show_evolutions_w_eq_bs'), Action(name='Show All w/Baseline', action='show_evolutions_w_bs') ] for iso in item.result.isotope_group.iter_isotopes(): actions = [ Action(name='Signal', action='show_evolution_{}'.format(iso.name)), Action(name='Equilibration/Signal', action='show_evolution_eq_{}'.format(iso.name)), Action(name='Equilibration/Signal/Baseline', action='show_evolution_eq_bs_{}'.format(iso.name)), Action(name='Signal/Baseline', action='show_evolution_bs_{}'.format(iso.name)) ] m = MenuManager(*actions, name=iso.name) evo_actions.append(m) evo = MenuManager(*evo_actions, name='Evolutions') success = MenuManager( Action(name='Summary', action='show_summary'), evo) return success
def chain_menu_factory(): return MenuManager(Action(name='Chain Ideogram', action='chain_ideogram'), Action(name='Chain Isotope Evolution', action='chain_isotope_evolution'), Action(name='Chain Spectrum', action='chain_spectrum'), Action(name='Chain Blanks', action='chain_blanks'), Action(name='Chain ICFactors', action='chain_icfactors'), name='Chain')
def get_menu(self, obj, trait, row, column): if obj.context_menu_enabled: e = obj.append_replace_enabled actions = [ Action(name='Unselect', action='unselect_analyses'), Action(name='Replace', action='replace_items', enabled=e), Action(name='Append', action='append_items', enabled=e), Action(name='Open', action='recall_items'), Action(name='Open Copy', action='recall_copies') ] return MenuManager(*actions)
def contextual_menu_contents(self): """ """ actions = (Action(name='Recall', on_perform=self._recall_analysis), Action(name='Set tag', on_perform=self._set_tag), Action(name='Set Omit', on_perform=self._set_omit), Action(name='Set Invalid', on_perform=self._set_invalid)) return actions
def fit_menu_factory(): return MenuManager(Action(name='Isotope Evolution', action='add_isotope_evolution'), Action(name='Blanks', action='add_blanks'), Action(name='IC Factor', action='add_icfactor'), Action(name='Detector IC', enabled=False, action='add_detector_ic'), Action(name='Flux', enabled=False, action='add_flux'), name='Fit')
def enable_disable_menu_factory(): return MenuManager( Action(name='Enable', action='enable', visible_when='not object.enabled'), Action(name='Disable', action='disable', visible_when='object.enabled'), Action(name='Enable Permanent', action='enable_permanent', visible_when='not object.enabled'), Action(name='Disable Permanent', action='disable_permanent', visible_when='object.enabled'))
def __init__(self, all_roles, **traits): """Initialise the object.""" buttons = [Action(name="Search"), Action(name="Save"), CancelButton] roles_editor = SetEditor(values=list(all_roles.values()), left_column_title="Available Roles", right_column_title="Assigned Roles") roles_group = Group(Item(name='roles', editor=roles_editor), label='Roles', show_border=True, show_labels=False) super(_AssignmentView, self).__init__(Item(name='user_name'), Item(name='description', style='readonly'), roles_group, buttons=buttons, **traits)
def connect_actions(self, actions): """ Returns a list of Actions for a list of potential connections. """ force = (len(actions) == 1) result = [] for ui_name1, ui_name2, dc_name, index in actions: if (not force) and (ui_name2 != ''): result.append( Action(name='to the %s in the %s' % (ui_name2, dc_name), action="self.connect(%d)" % index)) else: result.append( Action(name='to the %s' % dc_name, action="self.connect(%d)" % index)) return result
def default_toolbar(self): return ToolBar(Action(name="Save", tooltip='Save run', enabled_when='unsaved', image=ImageResource('save'), action="save_run"), Action(name="Reset", tooltip='Reset run', enabled_when='unsaved', image=ImageResource('reset'), action="reset_run"), image_size=(22, 22), show_tool_names=False, show_divider=True, name='exrun_toolbar')
def get_menu(self, obj, trait, row, column): e = obj.append_replace_enabled actions = [ Action(name='Configure', action='configure_analysis_table'), Action(name='Unselect', action='unselect_analyses'), # Action(name='Replace', action='replace_items', enabled=e), # Action(name='Append', action='append_items', enabled=e), Action(name='Open', action='recall_items'), Action(name='Review Status Details', action='review_status_details') # Action(name='Open Copy', action='recall_copies'), # Action(name='Find References', action='find_refs') ] return MenuManager(*actions)
def coerce_button(self, action): """ Coerces a string to an Action if necessary. """ if isinstance(action, str): return Action(name=action, action="" if action in SystemButtons else "?") return action
def coerce_button(self, action): """ Coerces a string to an Action if necessary. """ if isinstance(action, basestring): return Action(name=action, action='?'[(not action in SystemButtons):]) return action
def traits_view(self): """ Default traits view for this class. """ help_action = Action(name="Info", action="preferences_help") buttons = ["OK", "Cancel"] if self.show_apply: buttons = ["Apply"] + buttons if self.show_help: buttons = [help_action] + buttons # A tree editor for preferences nodes. tree_editor = TreeEditor( nodes=[ TreeNode( node_for=[PreferencesNode], auto_open=False, children="children", label="name", rename=False, copy=False, delete=False, insert=False, menu=None, ), ], on_select=self._selection_changed, editable=False, hide_root=True, selected="selected_node", show_icons=False, ) view = View( HSplit( Item( name="root", editor=tree_editor, show_label=False, width=250, ), Item( name="selected_page", # editor = WidgetEditor(), show_label=False, width=450, style="custom", ), ), buttons=buttons, handler=PreferencesManagerHandler(model=self), resizable=True, title="Preferences", width=0.3, height=0.3, kind="modal", ) self.selected_page = self.pages[0] return view
def _actions_default(self): add_scene = \ Action( image=ImageResource('add_scene.png', search_path=self._image_path), tooltip="Create a new scene", defined_when='True', enabled_when='True', perform=self._perform_new_scene, ) add_source = \ Action( image=ImageResource('add_source.png', search_path=self._image_path), tooltip="Add a data source", defined_when='True', enabled_when='len(scenes) > 0', perform=self._perform_add_source, ) add_module = \ Action( image=ImageResource('add_module.png', search_path=self._image_path), tooltip="Add a visualization module", defined_when='True', # isinstance doesn't work in enabled_when enabled_when=\ 'current_selection is not None and' '( hasattr(current_selection, "output_info")' 'or current_selection.__class__.__name__ ==' '"ModuleFilterAdderNode")', perform=self._perform_add_module, ) add_filter = \ Action( image=ImageResource('add_filter.png', search_path=self._image_path), tooltip="Add a processing filter", defined_when='True', enabled_when=\ 'current_selection is not None and' '( ( hasattr(current_selection, "output_info")' ' and not current_selection.type in (" module", ' ' " module manager"))' 'or current_selection.__class__.__name__ ==' '"ModuleFilterAdderNode")', perform=self._perform_add_filter, ) help = \ Action( image=ImageResource('help-action.png', search_path=self._image_path), tooltip="Help on the Mayavi pipeline", defined_when='True', enabled_when='True', perform=open_help_index, ) tvtk_docs = \ Action( image=ImageResource('reader.png', search_path=self._image_path), tooltip="Search the VTK class browser", defined_when='True', enabled_when='True', perform=open_tvtk_docs, ) record = \ Action( image=ImageResource('record.png', search_path=self._image_path), tooltip="Start/Stop script recording", style='toggle', checked=False, defined_when='True', enabled_when='engine is not None', perform=self._perform_record, ) # Check the record icon if the engine already has a recorder # set. if self.engine is not None and self.engine.recorder is not None: record.checked = True return [tvtk_docs, Separator(), add_scene, add_source, add_module, add_filter, Separator(), help, record]