Exemplo n.º 1
0
    def _tool_bars_default(self):
        xls = True
        try:
            import xlwt
        except ImportError:
            xls = False

        pdf = True
        try:
            from reportlab import Version
        except ImportError:
            pdf = False

        tb1 = SToolBar(SGroup(ToggleStatusAction(), SummaryTableAction(),
                              AppendSummaryTableAction()),
                       SGroup(AppendTableAction()),
                       image_size=(16, 16))

        actions = []
        if pdf:
            actions.append(MakePDFTableAction())
        if xls:
            actions.append(MakeXLSTableAction())

        actions.append(MakeCSVTableAction())

        tb2 = SToolBar(*actions, image_size=(16, 16))
        #                     orientation='vertical'
        #                     )

        return [tb1, tb2]
Exemplo n.º 2
0
    def _menu_bar_factory(self, menus=None):
        if not menus:
            menus = []

        edit_menu = SMenu(GenericFindAction(), id='Edit', name='&Edit')

        # entry_menu = SMenu(
        #     id='entry.menu',
        #     name='&Entry')

        file_menu = SMenu(SGroup(id='Open'),
                          SGroup(id='New'),
                          SGroup(GenericSaveAsAction(),
                                 GenericSaveAction(),
                                 id='Save'),
                          SGroup(),
                          id='file.menu',
                          name='File')

        tools_menu = SMenu(CopyPreferencesAction(),
                           id='tools.menu',
                           name='Tools')

        window_menu = SMenu(
            WindowGroup(),
            Group(CloseAction(), CloseOthersAction(), id='Close'),
            OpenAdditionalWindow(),
            Group(MinimizeAction(), ResetLayoutAction(), PositionAction()),

            # SplitEditorAction(),
            id='window.menu',
            name='Window')
        help_menu = SMenu(
            IssueAction(),
            NoteAction(),
            AboutAction(),
            DocumentationAction(),
            ChangeLogAction(),
            RestartAction(),
            KeyBindingsAction(),
            SwitchUserAction(),
            StartupTestsAction(),
            # DemoAction(),
            id='help.menu',
            name='Help')

        grps = self._view_groups()
        view_menu = SMenu(*grps, id='view.menu', name='&View')

        mb = SMenuBar(file_menu, edit_menu, view_menu, tools_menu, window_menu,
                      help_menu)
        if menus:
            for mi in reversed(menus):
                mb.items.insert(4, mi)

        return mb
    def _scripts_ext(self):
        def script_action(name):
            def func():
                p = os.path.join(paths.spectrometer_scripts_dir, '{}.py'.format(name))
                return SpectrometerScriptAction(name=name, script_path=p)

            return func

        actions = []

        for f in glob_list_directory(paths.spectrometer_scripts_dir, extension='.py', remove_extension=True):
            actions.append(SchemaAddition(id='spectrometer_script.{}'.format(f),
                                          factory=script_action(f),
                                          path='MenuBar/procedures.menu/spectrometer_script.group'))
        if actions:
            m = SchemaAddition(id='procedures.menu',
                               before='window.menu',
                               after='tools.menu',
                               factory=lambda: SMenu(name='Procedures', id='procedures.menu'),
                               path='MenuBar')
            g = SchemaAddition(id='spectrometer_script.group',
                               factory=lambda: SGroup(name='Spectrometer',
                                                      id='spectrometer_script.group'),
                               path='MenuBar/procedures.menu')

            actions.insert(0, g)
            actions.insert(0, m)

            ext = TaskExtension(actions=actions)
            return ext
    def _hops_ext(self):
        def hop_action(name):
            def func():
                return HopsAction(name=name, hop_name=name)

            return func

        actions = []

        for f in glob_list_directory(paths.hops_dir, extension='.yaml', remove_extension=True):
            actions.append(SchemaAddition(id='procedure.{}'.format(f),
                                          factory=hop_action(f),
                                          path='MenuBar/procedures.menu/hops.group'))

        if actions:
            m = SchemaAddition(id='procedures.menu',
                               before='window.menu',
                               after='tools.menu',
                               factory=lambda: SMenu(name='Procedures', id='procedures.menu'),
                               path='MenuBar')
            g = SchemaAddition(id='hops.group',
                               factory=lambda: SGroup(name='Hops', id='hops.group'),
                               path='MenuBar/procedures.menu')
            actions.insert(0, g)
            actions.insert(0, m)

            ext = TaskExtension(actions=actions)
            return ext
Exemplo n.º 5
0
    def _task_extensions_default(self):
        exts = self._get_extensions()
        extensions = [
            TaskExtension(actions=actions, task_id=eid)
            for eid, actions in exts
        ]

        additions = []

        # eflag = False
        for eid, actions in exts:
            for ai in actions:
                # if not eflag and ai.id.startswith('pychron.experiment.edit'):
                if ai.id.startswith('pychron.experiment.edit'):
                    # eflag = True
                    additions.append(
                        SchemaAddition(
                            id='experiment.edit',
                            factory=lambda: SGroup(id='experiment.group'),
                            path='MenuBar/edit.menu'), )
                    break

        if additions:
            extensions.append(TaskExtension(actions=additions, task_id=''))

        sr_actions = [
            SchemaAddition(id='experiment.acquire_spectrometer',
                           factory=AcquireSpectrometerAction,
                           path='MenuBar/Tools'),
            SchemaAddition(id='experiment.release_spectrometer',
                           factory=ReleaseSpectrometerAction,
                           path='MenuBar/Tools')
        ]
        extensions.append(TaskExtension(actions=sr_actions, task_id=''))
        return extensions
Exemplo n.º 6
0
    def _task_extensions_default(self):
        extensions = [
            TaskExtension(actions=actions, task_id=eid)
            for eid, actions in self._get_extensions()
        ]
        additions = [
            SchemaAddition(
                id='entry',
                factory=lambda: SMenu(id='entry.menu', name='Entry'),
                path='MenuBar',
                before='tools.menu',
                after='view.menu')
        ]

        eflag = False
        eeflag = False
        for eid, actions in self._get_extensions():
            # print 'b', eid, len(actions)
            for ai in actions:
                # print 'c',ai,ai.id
                if not eflag and ai.id.startswith('pychron.entry1'):
                    eflag = True
                    additions.append(
                        SchemaAddition(
                            id='entry_group',
                            factory=lambda: SGroup(id='entry.group'),
                            path='MenuBar/entry.menu'))
                    additions.append(
                        SchemaAddition(
                            id='entry_sample_group',
                            absolute_position='first',
                            factory=lambda: SGroup(id='entry.sample.group'),
                            path='MenuBar/entry.menu'))
                elif not eeflag and ai.id.startswith('pychron.entry2'):
                    eeflag = True
                    additions.append(
                        SchemaAddition(
                            id='entry_group2',
                            factory=lambda: SGroup(id='entry.group2'),
                            after='entry_group',
                            path='MenuBar/entry.menu'), )

        extensions.append(TaskExtension(actions=additions))

        return extensions
Exemplo n.º 7
0
    def _file_menu(self):
        file_menu = SMenu(
            SGroup(id='Open'),
            SGroup(id='New'),
            SGroup(GenericSaveAsAction(), GenericSaveAction(), id='Save'),
            SGroup(),
            #                         SMenu(id='Open', name='Open',),
            #                         SMenu(id='New', name='New'),

            #                         Group(
            #                                GenericSaveAsAction(),
            #                                GenericSaveAction(),
            #                                id='Save'
            #                                ),
            #
            #                           SGroup(),
            #
            #                                 ),
            id='File',
            name='File')
        return file_menu
Exemplo n.º 8
0
    def _task_extensions_default(self):
        ex = [
            TaskExtension(actions=[
                SchemaAddition(id='refresh_canvas',
                               factory=RefreshCanvasAction,
                               path='MenuBar/tools.menu'),
                SchemaAddition(id='stopwatch',
                               factory=StopWatchAction,
                               path='MenuBar/tools.menu')
            ])
        ]

        if self.application.get_plugin('pychron.pyscript.plugin'):

            actions = []
            for f in glob_list_directory(paths.procedures_dir,
                                         extension='.py',
                                         remove_extension=True):
                actions.append(
                    SchemaAddition(
                        id='procedure.{}'.format(f),
                        factory=procedure_action(f, self.application),
                        path='MenuBar/procedures.menu/extraction_line.group'))

            if actions:
                actions.insert(
                    0,
                    SchemaAddition(id='procedures.menu',
                                   before='window.menu',
                                   after='tools.menu',
                                   factory=lambda: SMenu(name='Procedures',
                                                         id='procedures.menu'),
                                   path='MenuBar'))

                actions.insert(
                    1,
                    SchemaAddition(
                        id='extraction_line.group',
                        factory=lambda: SGroup(name='ExtractionLine',
                                               id='extraction_line.group'),
                        path='MenuBar/procedures.menu'))
                ex.append(TaskExtension(actions=actions))
            else:
                self.warning('no procedure scripts located in "{}"'.format(
                    paths.procedures_dir))
        return ex
Exemplo n.º 9
0
    def _task_extensions_default(self):
        extensions = [
            TaskExtension(actions=actions, task_id=eid)
            for eid, actions in self._get_extensions()
        ]
        # print 'a', len(extensions)
        additions = []

        eflag = False
        for eid, actions in self._get_extensions():
            # print 'b', eid, len(actions)
            for ai in actions:
                if not eflag and ai.id.startswith('pychron.experiment.edit'):
                    eflag = True
                    additions.append(
                        SchemaAddition(
                            id='experiment.edit',
                            factory=lambda: SGroup(id='experiment.group'),
                            path='MenuBar/Edit'), )
        if additions:
            extensions.append(TaskExtension(actions=additions, task_id=''))
        return extensions
Exemplo n.º 10
0
def grouping_group():
    return SMenu(SGroup(id='grouping'),
                 SGroup(id='graph.grouping'),
                 id='grouping.menu',
                 name='Grouping')
Exemplo n.º 11
0
def reduction_group():
    return SGroup(id='reduction.group', name='Reduction')
Exemplo n.º 12
0
def figure_group():
    return SGroup(id='figures.group', name='Figures')
Exemplo n.º 13
0
 def reduction_group():
     return SGroup(id='reduction.group')
Exemplo n.º 14
0
 def quick_series_group():
     return SGroup(id='quick_series.group')
Exemplo n.º 15
0
def misc_group():
    return SGroup(id='misc.group')
Exemplo n.º 16
0
def recall_group():
    return SGroup(id='recall.group')
Exemplo n.º 17
0
 def plot_group():
     return SGroup(id='plot.group')