Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from pyface.workbench.api import TraitsUIView
from traits.api import Button, Instance, List, Property, Str, \
cached_property, on_trait_change
from traitsui.api import View, Group, Item, CodeEditor, \
TabularEditor, spring
from traitsui.tabular_adapter import TabularAdapter
# Local imports
from traits.logger.agent.quality_agent_view import QualityAgentView
from traits.logger.plugin import view
from traits.logger.plugin.logger_service import LoggerService
# Constants
_IMAGE_MAP = { logging.DEBUG: ImageResource('debug'),
logging.INFO: ImageResource('info'),
logging.WARNING: ImageResource('warning'),
logging.ERROR: ImageResource('error'),
logging.CRITICAL: ImageResource('crit_error') }
class LogRecordAdapter(TabularAdapter):
""" A TabularEditor adapter for logging.LogRecord objects.
"""
columns = [ ('Level', 'level'), ('Date', 'date'), ('Time', 'time'),
('Message', 'message') ]
column_widths = [ 80, 100, 120, -1 ]
level_image = Property
level_text = Property(Str)
date_text = Property(Str)
time_text = Property(Str)
search_path = [self._get_image_path()],
),
tooltip = "View along the +Z axis",
on_perform = self.z_plus_view,
),
Action(
image = ImageResource('16x16/isometric',
search_path = [self._get_image_path()],
),
tooltip = "Obtain an isometric view",
on_perform = self.isometric_view,
),
),
Group(
Action(
image = ImageResource('16x16/parallel',
search_path = [self._get_image_path()],
),
tooltip = 'Toggle parallel projection',
style="toggle",
on_perform = self._toggle_projection,
checked = self.parallel_projection,
),
Action(
image = ImageResource('16x16/origin_glyph',
search_path = [self._get_image_path()],
),
tooltip = 'Toggle axes indicator',
style="toggle",
enabled=(self.marker is not None),
on_perform = self._toggle_axes,
checked = self.show_axes,
# Turn this off if you don't want the workbench to start a GUI
# event loop.
start_gui_event_loop = Bool(True, desc='start a GUI event loop')
#### 'IApplication' interface #############################################
# The application's globally unique Id.
id = 'mayavi_e3'
#### 'WorkbenchApplication' interface #####################################
# Branding information.
#
# The icon used on window title bars etc.
icon = ImageResource('m2.ico', search_path=[IMG_DIR])
# The name of the application (also used on window title bars etc).
name = 'Mayavi2 - The 3D data visualizer'
###########################################################################
# 'WorkbenchApplication' interface.
###########################################################################
def run(self):
""" Run the application.
This does the following:
1) Starts the application
2) Creates and opens a workbench window
3) Starts the GUI event loop (only if start_gui_event_loop is
True)
tooltip = "Obtain an isometric view",
on_perform = self.isometric_view,
),
),
Group(
Action(
image = ImageResource('16x16/parallel',
search_path = [self._get_image_path()],
),
tooltip = 'Toggle parallel projection',
style="toggle",
on_perform = self._toggle_projection,
checked = self.parallel_projection,
),
Action(
image = ImageResource('16x16/origin_glyph',
search_path = [self._get_image_path()],
),
tooltip = 'Toggle axes indicator',
style="toggle",
enabled=(self.marker is not None),
on_perform = self._toggle_axes,
checked = self.show_axes,
),
Action(
image = ImageResource('16x16/fullscreen',
search_path = [self._get_image_path()],
),
tooltip = 'Full Screen (press "q" or "e" or ESC to exit fullscreen)',
style="push",
on_perform = self._full_screen_fired,
),
# Task interface -------------------------------------------------------
id = "example.second_task"
name = "Second Multi-Tab Editor"
tool_bars = [
SToolBar(
TaskAction(
method="new",
tooltip="New file",
image=ImageResource("document_new"),
),
TaskAction(
method="new",
tooltip="New file",
image=ImageResource("document_new"),
),
image_size=(32, 32),
)
]
# ------------------------------------------------------------------------
# 'Task' interface.
# ------------------------------------------------------------------------
def _default_layout_default(self):
return TaskLayout(
left=VSplitter(
HSplitter(PaneItem("steps.pane1"), PaneItem("steps.pane2"))
)
)
def get_actions_Menu_Help_DebugGroup(self):
return [
SMenu(TaskAction(name='Dynamic Menu Names', method='debug',
tooltip='Do some debug stuff',
image=ImageResource('debug')),
WidgetInspectorAction(),
id="Debug", name="Debug"),
]
SMenu(
TaskAction(name="New", method="new", accelerator="Ctrl+N"),
id="File",
name="&File",
),
SMenu(
DockPaneToggleGroup(), TaskToggleGroup(), id="View", name="&View"
),
)
tool_bars = [
SToolBar(
TaskAction(
method="new",
tooltip="New file",
image=ImageResource("document_new"),
),
image_size=(32, 32),
)
]
# ------------------------------------------------------------------------
# 'Task' interface.
# ------------------------------------------------------------------------
def _default_layout_default(self):
return TaskLayout(
top=Tabbed(
PaneItem("steps.first_pane"),
PaneItem("steps.second_pane"),
PaneItem("steps.third_pane"),
)
"<p>"]
ver_text = ["{0} {1}".format(key, value) for key, value in versions.items()]
text.extend(ver_text)
text.extend(["Icons from the <a href="http://tango.freedesktop.org">Tango Desktop Project</a>",
"<a href="https://thenounproject.com/search/?q=setup&i=14287">Settings icon</a> by Paulo Sa Ferreira from <a href="https://thenounproject.com">The Noun Project</a>",
"<a href="https://thenounproject.com/search/?q=processing&i=849831">Processing icon</a> by Gregor Cresnar from <a href="https://thenounproject.com">The Noun Project</a>",
"<a href="http://www.freepik.com/free-photos-vectors/background">App icon from Starline - Freepik.com</a>",
"Cuvette image from Wikimedia Commons user <a href="http://commons.wikimedia.org/wiki/File:Hellma_Large_cone_cytometry_cell.JPG">HellmaUSA</a>"])
dialog = AboutDialog(text = text,
parent = self.window.control,
title = "About",
image = ImageResource('cuvette'),
additions = text)
dialog.open()
</p>
preprocessing = Button('Preprocessing')
segmentation = Button('Segmentation')
parcellation = Button('Parcellation')
diffusion = Button('Diffusion')
registration = Button('Registration')
connectome = Button('Connectome')
config_file = Str
pipeline_group = VGroup(
HGroup(spring,Item('preprocessing',editor=ThemedButtonEditor(image=ImageResource('preprocessing'),theme='@G')),spring,show_labels=False),
HGroup(spring,Item('segmentation',editor=ThemedButtonEditor(image=ImageResource('segmentation'),theme='@G')),spring,show_labels=False),#Item('parcellation',editor=ThemedButtonEditor(image=ImageResource('parcellation'),theme='@G')),show_labels=False),
HGroup(spring,Item('parcellation',editor=ThemedButtonEditor(image=ImageResource('parcellation'),theme='@G')),spring,show_labels=False),
HGroup(spring,Item('registration',editor=ThemedButtonEditor(image=ImageResource('registration'),theme='@G')),spring,show_labels=False),
HGroup(spring,Item('diffusion',editor=ThemedButtonEditor(image=ImageResource('diffusion'),theme='@G')),spring,show_labels=False),
HGroup(spring,Item('connectome',editor=ThemedButtonEditor(image=ImageResource('connectome'),theme='@G')),spring,show_labels=False),
springy=True
)
def __init__(self,project_info):
self.stages = {'Preprocessing':PreprocessingStage(),
'Segmentation':SegmentationStage(),
'Parcellation':ParcellationStage(pipeline_mode = "Diffusion"),
'Registration':RegistrationStage(pipeline_mode = "Diffusion"),
'Diffusion':DiffusionStage(),
'Connectome':ConnectomeStage()}
Pipeline.__init__(self, project_info)
self.stages['Segmentation'].config.on_trait_change(self.update_parcellation,'seg_tool')
self.stages['Parcellation'].config.on_trait_change(self.update_segmentation,'parcellation_scheme')
# class attribute
activated_task_ids = set()
#### 'IAbout' interface ###################################################
about_title = Unicode('Omnivore XL')
about_version = Unicode
about_description = Unicode('Byte into the meat of 8-bit Software!\n\nSend feedback to: feedback@playermissile.com')
about_website = Str('http://playermissile.com/omnivore')
about_image = Instance(ImageResource, ImageResource('omnivore256'))
#### 'IErrorReporter' interface ###########################################
error_email_from = Str
error_email_passwd = Str
error_email_to = Str
# Regular ol' class attributes here
# description of menus
ui_layout_description = {
"menu": {
"order": ["File", "Edit", "View", "Documents", "Window", "Help"],
"File": ["NewGroup", "OpenGroup", "ImportGroup", "SaveGroup", "RevertGroup", "PrintGroup", "ExportGroup", "ExitGroup"],