Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from traitsui.menu import Menu, Action, Separator
from clipboard import clipboard, PyMimeData
from editor import Editor
from helper import pixmap_cache
logger = logging.getLogger(__name__)
#-------------------------------------------------------------------------
# The core tree node menu actions:
#-------------------------------------------------------------------------
from traitsui.ui_traits import SequenceTypes
NewAction = 'NewAction'
CopyAction = Action(name='Copy',
action='editor._menu_copy_node',
enabled_when='editor._is_copyable(object)')
CutAction = Action(name='Cut',
action='editor._menu_cut_node',
enabled_when='editor._is_cutable(object)')
PasteAction = Action(name='Paste',
action='editor._menu_paste_node',
enabled_when='editor._is_pasteable(object)')
DeleteAction = Action(name='Delete',
action='editor._menu_delete_node',
enabled_when='editor._is_deletable(object)')
RenameAction = Action(name='Rename',
action='editor._menu_rename_node',
enabled_when='editor._is_renameable(object)')
#-------------------------------------------------------------------------
object = self._data[1]
items = []
add = node.get_add(object)
if len(add) > 0:
for klass in add:
prompt = False
if isinstance(klass, tuple):
klass, prompt = klass
add_node = self._node_for_class(klass)
if add_node is not None:
class_name = klass.__name__
name = add_node.get_name(object)
if name == '':
name = class_name
items.append(
Action(name=name,
action="editor._menu_new_node('%s',%s)" %
(class_name, prompt)))
return items
from pychron.canvas.canvas2D.overlays.extraction_line_overlay import ExtractionLineInfoTool, ExtractionLineInfoOverlay
from pychron.canvas.canvas2D.scene.extraction_line_scene import ExtractionLineScene
from pychron.canvas.canvas2D.scene.primitives.connections import Elbow
from pychron.canvas.canvas2D.scene.primitives.lasers import Laser
from pychron.canvas.canvas2D.scene.primitives.primitives import BorderLine
from pychron.canvas.canvas2D.scene.primitives.valves import RoughValve, \
BaseValve, Switch, ManualSwitch
from pychron.canvas.scene_viewer import SceneCanvas
from pychron.globals import globalv
W = 2
H = 2
class ExtractionLineAction(Action):
chamber = Str
class ExtractionLineCanvas2D(SceneCanvas):
"""
"""
scene_klass = ExtractionLineScene
use_backbuffer = True
border_visible = False
active_item = Any
selected_id = Str
show_axes = False
show_grids = False
use_zoom = False
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 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')
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# ===============================================================================
from __future__ import absolute_import
from __future__ import print_function
from traitsui.menu import Action
from pychron.classifier.isotope_trainer import IsotopeTrainer
class TrainIsotopeClassifierAction(Action):
name = 'Train'
def perform(self, event):
app = event.task.application
dvc = app.get_service('pychron.dvc.dvc.DVC')
print('asdfasd', dvc)
trainer = IsotopeTrainer(dvc=dvc)
trainer.train()
# trainer.edit_traits(view=View('test'))
def traits_view(self):
v = View(UItem('canvas', editor=ComponentEditor()),
resizable=True,
toolbar=ToolBar(Action(name='Save State',
action='save_state'),
Action(name='Assemble',
action='assemble'),
),
width=500)
return v
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 action_factory(self, name, func, **kw):
"""
"""
a = Action(name=name, on_perform=getattr(self, func),
# visible_when='0',
**kw)
return a
###
# Private Traits
# activate / deactivate logic
# if the node is activated, this means that there exists a
# corresponding RenderManager instance
_TracksRender = Instance(Action,
kw={'name': 'Show Tracks (fos)',
'action': 'object.render_tracks',
'tooltip':'Show the rendered tracks',
'enabled_when':'object.loaded == True'
}, )
_TrackVisLaunchAction = Instance(Action,
kw={'name': 'Launch TrackVis',
'action': 'object.launch_trackvis',
'tooltip':'Launch TrackVis',
'enabled_when':'object.loaded == True'}, )
# the menu shown after right-click
menu = Instance(Menu, transient=True)
def get_children(self, object):
""" Get the object's children. """
pass
######################################################################
# Non-public interface
######################################################################