コード例 #1
0
ファイル: project_widget.py プロジェクト: GuLinux/PySpectrum
    def __init__(self, project, settings):
        QWidget.__init__(self)
        self.ui = Ui_ProjectWidget()
        self.ui.setupUi(self)
        self.project = project
        self.project.filesChanged.connect(self.refresh)
        self.toolbar = QToolBar()
        import_image = lambda: ImportImage.pick(lambda f: self.import_image.emit(f[0]), settings)
        self.toolbar.addAction(ImportImage.icon(), ImportImage.ACTION_TEXT, import_image)
        self.ui.import_image.clicked.connect(import_image)
        self.raw_spectra_model = QStandardItemModel()
        self.calibrated_spectra_model = QStandardItemModel()
        self.finished_spectra_model = QStandardItemModel()

        def button_action(button, signal, widget, model):
            button.clicked.connect(lambda: signal.emit(model.item(widget.selectionModel().selectedRows()[0].row()).data() ) )
            widget.selectionModel().selectionChanged.connect(lambda sel, unsel: button.setEnabled(len(sel.indexes())>0))
            
        for model, widget in [(self.raw_spectra_model, self.ui.raw_spectra), (self.calibrated_spectra_model, self.ui.calibrated_spectra), (self.finished_spectra_model, self.ui.finished_spectra)]:
            widget.setModel(model)
            widget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
            
        button_action(self.ui.calibrate, self.calibrate, self.ui.raw_spectra, self.raw_spectra_model)
        button_action(self.ui.math, self.math, self.ui.calibrated_spectra, self.calibrated_spectra_model)
        button_action(self.ui.finish, self.finish, self.ui.calibrated_spectra, self.calibrated_spectra_model)
        button_action(self.ui.open_finished, self.finish, self.ui.finished_spectra, self.finished_spectra_model)
        open_finished_menu = QMenu()
        self.ui.open_finished_dirs.setMenu(open_finished_menu)
        open_finished_menu.addAction(QIcon(':/image_20'), 'Exported Images folder', lambda: QDesktopServices.openUrl(QUrl.fromLocalFile(project.directory_path(Project.EXPORTED_IMAGES))))
        open_finished_menu.addAction(QIcon(':/done_20'), 'Finished Spectra folder', lambda: QDesktopServices.openUrl(QUrl.fromLocalFile(project.directory_path(Project.FINISHED_PROFILES))))
        

            
        self.refresh()
コード例 #2
0
    def __init__(self, project, settings):
        QWidget.__init__(self)
        self.ui = Ui_ProjectWidget()
        self.ui.setupUi(self)
        self.project = project
        self.project.filesChanged.connect(self.refresh)
        self.toolbar = QToolBar()
        import_image = lambda: ImportImage.pick(
            lambda f: self.import_image.emit(f[0]), settings)
        self.toolbar.addAction(ImportImage.icon(), ImportImage.ACTION_TEXT,
                               import_image)
        self.ui.import_image.clicked.connect(import_image)
        self.raw_spectra_model = QStandardItemModel()
        self.calibrated_spectra_model = QStandardItemModel()
        self.finished_spectra_model = QStandardItemModel()

        def button_action(button, signal, widget, model):
            button.clicked.connect(lambda: signal.emit(
                model.item(widget.selectionModel().selectedRows()[0].row()).
                data()))
            widget.selectionModel().selectionChanged.connect(
                lambda sel, unsel: button.setEnabled(len(sel.indexes()) > 0))

        for model, widget in [
            (self.raw_spectra_model, self.ui.raw_spectra),
            (self.calibrated_spectra_model, self.ui.calibrated_spectra),
            (self.finished_spectra_model, self.ui.finished_spectra)
        ]:
            widget.setModel(model)
            widget.horizontalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)

        button_action(self.ui.calibrate, self.calibrate, self.ui.raw_spectra,
                      self.raw_spectra_model)
        button_action(self.ui.math, self.math, self.ui.calibrated_spectra,
                      self.calibrated_spectra_model)
        button_action(self.ui.finish, self.finish, self.ui.calibrated_spectra,
                      self.calibrated_spectra_model)
        button_action(self.ui.open_finished, self.finish,
                      self.ui.finished_spectra, self.finished_spectra_model)
        open_finished_menu = QMenu()
        self.ui.open_finished_dirs.setMenu(open_finished_menu)
        open_finished_menu.addAction(
            QIcon(':/image_20'), 'Exported Images folder',
            lambda: QDesktopServices.openUrl(
                QUrl.fromLocalFile(
                    project.directory_path(Project.EXPORTED_IMAGES))))
        open_finished_menu.addAction(
            QIcon(':/done_20'), 'Finished Spectra folder',
            lambda: QDesktopServices.openUrl(
                QUrl.fromLocalFile(
                    project.directory_path(Project.FINISHED_PROFILES))))

        self.refresh()
コード例 #3
0
ファイル: homepage.py プロジェクト: GuLinux/PySpectrum
 def __init__(self, settings, database):
     QWidget.__init__(self)
     last_files_list = LastFilesList(settings)
     self.settings = settings
     self.database = database
     self.ui = Ui_HomePage()
     self.ui.setupUi(self)
     self.toolbar = QToolBar()
     welcome_text = "{} {}".format(QApplication.instance().applicationName(), QApplication.instance().applicationVersion())
     self.ui.welcome_label.setText(self.ui.welcome_label.text().format(welcome_text))
     file_action = QtCommons.addToolbarPopup(self.toolbar, 'File', icon_file=':/file_20')
     project_action = QtCommons.addToolbarPopup(self.toolbar, 'Project', icon_file=':/project_20')
     #file_action.menu().addAction(QIcon(':/stack_20'), 'Stack Images', lambda: open_file_sticky('Open Reference FITS Image',FITS_IMG_EXTS, lambda f: self.stack_images.emit(f[0]), settings, IMPORT_IMG ))
     import_image_action = lambda: ImportImage.pick(lambda f: self.import_image.emit(f[0]), settings)
     file_action.menu().addAction(ImportImage.icon(), ImportImage.ACTION_TEXT, import_image_action)
     self.ui.import_image.clicked.connect(import_image_action)
     file_action.menu().addAction(QIcon(':/plot_20'), 'Calibrate Spectrum', lambda: open_file_sticky('Open raw FITS Spectrum',FITS_EXTS, lambda f: self.calibrate.emit(f[0]), settings, RAW_PROFILE, [IMPORT_IMG] ))
     file_action.menu().addAction(QIcon(':/math_20'), 'Spectra Math', lambda: self.math.emit(None) )
     file_action.menu().addAction(QIcon(':/done_20'), 'Finish Spectrum', lambda: open_file_sticky('Open FITS Spectrum',FITS_EXTS, lambda f: self.finish.emit(f[0]), settings, CALIBRATED_PROFILE, [RAW_PROFILE,IMPORT_IMG] ))
     
     project_action.menu().addAction(QIcon(':/project_new_20'), 'New', lambda: self.new_project.emit())
     
     pick_project = lambda: open_directory_sticky('Open Project', self.__project_picked, settings, PROJECTS)
     self.ui.pick_project.clicked.connect(pick_project)
     project_action.menu().addAction(QIcon(':/new_open_20'), 'Open...', pick_project)
     
     self.recent_raw_model = QStandardItemModel()
     self.recent_calibrated_model = QStandardItemModel()
     self.recent_projects_model = QStandardItemModel()
     self.ui.recent_raw_list.setModel(self.recent_raw_model)
     self.ui.recent_calibrated_list.setModel(self.recent_calibrated_model)
     self.ui.recent_projects.setModel(self.recent_projects_model)
     for widget in [self.ui.recent_raw_list, self.ui.recent_calibrated_list, self.ui.recent_projects]:
         widget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
         
     LastFilesList.instance().files_changed.connect(self.__populate_lists)
     selected_path = lambda model, view: model.item(view.selectionModel().selectedRows()[0].row()).data()
     button_enable = lambda view, button: view.selectionModel().selectionChanged.connect(lambda sel, desel: button.setEnabled(len(sel.indexes() )) )
     
     button_enable(self.ui.recent_raw_list, self.ui.calibrate)
     button_enable(self.ui.recent_calibrated_list, self.ui.math)
     button_enable(self.ui.recent_calibrated_list, self.ui.finish)
     button_enable(self.ui.recent_projects, self.ui.open_recent_project)
     self.ui.calibrate.clicked.connect(lambda: self.calibrate.emit(selected_path(self.recent_raw_model, self.ui.recent_raw_list)))
     self.ui.math.clicked.connect(lambda: self.math.emit(selected_path(self.recent_calibrated_model, self.ui.recent_calibrated_list)))
     self.ui.finish.clicked.connect(lambda: self.finish.emit(selected_path(self.recent_calibrated_model, self.ui.recent_calibrated_list)))
     self.ui.open_recent_project.clicked.connect(lambda: self.open_project.emit(selected_path(self.recent_projects_model, self.ui.recent_projects)))
     self.ui.new_project.clicked.connect(self.new_project.emit)
     self.reference_catalogues = ReferenceCatalogues(database)
     
     self.ui.download_catalogs.clicked.connect(self.download_catalogs)
     self.__populate_lists()
コード例 #4
0
ファイル: homepage.py プロジェクト: tstibor/PySpectrum
    def __init__(self, settings, database):
        QWidget.__init__(self)
        last_files_list = LastFilesList(settings)
        self.settings = settings
        self.database = database
        self.ui = Ui_HomePage()
        self.ui.setupUi(self)
        self.toolbar = QToolBar()
        welcome_text = "{} {}".format(
            QApplication.instance().applicationName(),
            QApplication.instance().applicationVersion())
        self.ui.welcome_label.setText(
            self.ui.welcome_label.text().format(welcome_text))
        file_action = QtCommons.addToolbarPopup(self.toolbar,
                                                'File',
                                                icon_file=':/file_20')
        project_action = QtCommons.addToolbarPopup(self.toolbar,
                                                   'Project',
                                                   icon_file=':/project_20')
        #file_action.menu().addAction(QIcon(':/stack_20'), 'Stack Images', lambda: open_file_sticky('Open Reference FITS Image',FITS_IMG_EXTS, lambda f: self.stack_images.emit(f[0]), settings, IMPORT_IMG ))
        import_image_action = lambda: ImportImage.pick(
            lambda f: self.import_image.emit(f[0]), settings)
        file_action.menu().addAction(ImportImage.icon(),
                                     ImportImage.ACTION_TEXT,
                                     import_image_action)
        self.ui.import_image.clicked.connect(import_image_action)
        file_action.menu().addAction(
            QIcon(':/plot_20'), 'Calibrate Spectrum', lambda: open_file_sticky(
                'Open raw FITS Spectrum', FITS_EXTS, lambda f: self.calibrate.
                emit(f[0]), settings, RAW_PROFILE, [IMPORT_IMG]))
        file_action.menu().addAction(QIcon(':/math_20'), 'Spectra Math',
                                     lambda: self.math.emit(None))
        file_action.menu().addAction(
            QIcon(':/done_20'), 'Finish Spectrum', lambda: open_file_sticky(
                'Open FITS Spectrum', FITS_EXTS, lambda f: self.finish.emit(f[
                    0]), settings, CALIBRATED_PROFILE,
                [RAW_PROFILE, IMPORT_IMG]))

        project_action.menu().addAction(QIcon(':/project_new_20'), 'New',
                                        lambda: self.new_project.emit())

        pick_project = lambda: open_directory_sticky(
            'Open Project', self.__project_picked, settings, PROJECTS)
        self.ui.pick_project.clicked.connect(pick_project)
        project_action.menu().addAction(QIcon(':/new_open_20'), 'Open...',
                                        pick_project)

        self.recent_raw_model = QStandardItemModel()
        self.recent_calibrated_model = QStandardItemModel()
        self.recent_projects_model = QStandardItemModel()
        self.ui.recent_raw_list.setModel(self.recent_raw_model)
        self.ui.recent_calibrated_list.setModel(self.recent_calibrated_model)
        self.ui.recent_projects.setModel(self.recent_projects_model)
        for widget in [
                self.ui.recent_raw_list, self.ui.recent_calibrated_list,
                self.ui.recent_projects
        ]:
            widget.horizontalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)

        LastFilesList.instance().files_changed.connect(self.__populate_lists)
        selected_path = lambda model, view: model.item(view.selectionModel(
        ).selectedRows()[0].row()).data()
        button_enable = lambda view, button: view.selectionModel(
        ).selectionChanged.connect(lambda sel, desel: button.setEnabled(
            len(sel.indexes())))

        button_enable(self.ui.recent_raw_list, self.ui.calibrate)
        button_enable(self.ui.recent_calibrated_list, self.ui.math)
        button_enable(self.ui.recent_calibrated_list, self.ui.finish)
        button_enable(self.ui.recent_projects, self.ui.open_recent_project)
        self.ui.calibrate.clicked.connect(lambda: self.calibrate.emit(
            selected_path(self.recent_raw_model, self.ui.recent_raw_list)))
        self.ui.math.clicked.connect(lambda: self.math.emit(
            selected_path(self.recent_calibrated_model, self.ui.
                          recent_calibrated_list)))
        self.ui.finish.clicked.connect(lambda: self.finish.emit(
            selected_path(self.recent_calibrated_model, self.ui.
                          recent_calibrated_list)))
        self.ui.open_recent_project.clicked.connect(
            lambda: self.open_project.emit(
                selected_path(self.recent_projects_model, self.ui.
                              recent_projects)))
        self.ui.new_project.clicked.connect(self.new_project.emit)
        self.reference_catalogues = ReferenceCatalogues(database)

        self.ui.download_catalogs.clicked.connect(self.download_catalogs)
        self.__populate_lists()