コード例 #1
0
    def __init__(self, plot_window, parent=None):
        super(LineListsWindow, self).__init__(plot_window)

        self.plot_window = plot_window

        loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_window.ui"), self)
        self.setWindowTitle(str(self.plot_window._title))

        # QtDesigner can't add a combo box to a tool bar...
        self.line_list_selector = QComboBox()
        self.line_list_selector.setToolTip("Select line list from internal library")
        self.mainToolBar.addWidget(self.line_list_selector)

        # QtDesigner creates tabbed widgets with 2 tabs, and doesn't allow
        # removing then in the designer itself. Remove in here then.
        while self.tabWidget.count() > 0:
            self.tabWidget.removeTab(0)

        # Request that line lists be read from wherever are they sources.
        plot_window.request_linelists()

        # Populate line list selector with internal line lists
        model = self.line_list_selector.model()
        item = QStandardItem("Select line list")
        font = QFont("Monospace")
        font.setStyleHint(QFont.TypeWriter)
        font.setPointSize(12)
        item.setFont(font)
        model.appendRow(item)
        for description in linelist.descriptions():
            item = QStandardItem(str(description))
            item.setFont(font)
            model.appendRow(item)

        #------------ UNCOMMENT TO LOAD LISTS AUTOMATICALLY --------------
        #
        # Populate GUI.
        #
        # This is commented out for now to comply with the decision about
        # not showing any line list automatically upon startup. In case
        # we need that capability back, just uncomment this line.

        # self._buildViews(plot_window)

        #---------------------------------------------------------------

        # Connect controls to appropriate signals.
        #
        # Note that, for the Draw operation, we have to pass the table views to
        # the handler, even though it would be better to handle the row selections
        # all in here for the sake of encapsulation. This used to be necessary
        # because this class is not a QWidget or one of its subclasses, thus it
        # cannot implement a DispatchHandle signal handler. Once we gt rid of the
        # Dispatch facility, this design decision could likely be modified. We
        # decide to keep the same old design for now, to prevent breaks in logic.

        self.draw_button.clicked.connect(
            lambda:self.plot_window.line_labels_plotter.plot_linelists(
                table_views=self._getTableViews(),
                panes=self._getPanes(),
                units=self.plot_window.spectral_axis_unit,
                caller=self.plot_window))

        self.erase_button.clicked.connect(lambda:self.plot_window.erase_linelabels.emit(self.plot_window))
        self.dismiss_button.clicked.connect(lambda:self.plot_window.dismiss_linelists_window.emit(False))
        self.actionOpen.triggered.connect(lambda:self._open_linelist_file(file_name=None))
        self.actionExport.triggered.connect(lambda:self._export_to_file(file_name=None))
        self.line_list_selector.currentIndexChanged.connect(self._lineList_selection_change)
        self.tabWidget.tabCloseRequested.connect(self.tab_close)
コード例 #2
0
    def __init__(self, plot_window, parent=None):
        super(LineListsWindow, self).__init__()

        self.plot_window = plot_window

        # Builds GUI
        self._main_window = ClosableMainWindow()
        self.setupUi(self._main_window, str(plot_window))
        self.tabWidget.tabCloseRequested.connect(self.tab_close)

        # Request that line lists be read from wherever are they sources.
        dispatch.on_request_linelists.emit()

        # Populate line list selector with internal line lists
        model = self.line_list_selector.model()
        item = QStandardItem("Select line list")
        font = QFont("Monospace")
        font.setStyleHint(QFont.TypeWriter)
        font.setPointSize(12)
        item.setFont(font)
        model.appendRow(item)
        for description in linelist.descriptions():
            item = QStandardItem(str(description))
            item.setFont(font)
            model.appendRow(item)

        #------------ UNCOMMENT TO LOAD LISTS AUTOMATICALLY --------------
        #
        # Populate GUI.
        #
        # This is commented out for now to comply with the decision about
        # not showing any line list automatically upon startup. In case
        # we need that capability back, just uncomment this line.

        # self._buildViews(plot_window)

        #---------------------------------------------------------------

        # Connect controls to appropriate signals.
        #
        # Note that, for the Draw operation, we have to pass the table views to
        # the handler, even though it would be better to handle the row selections
        # all in here for the sake of encapsulation. This is so because this class
        # is not a QWidget or one of its subclasses, thus it cannot implement a
        # DispatchHandle signal handler.
        self.draw_button.clicked.connect(
            lambda: dispatch.on_plot_linelists.emit(
                table_views=self._getTableViews(),
                panes=self._getPanes(),
                units=plot_window.waverange[0].unit,
                caller=plot_window))

        self.erase_button.clicked.connect(
            lambda: dispatch.on_erase_linelabels.emit(caller=plot_window))
        self.dismiss_button.clicked.connect(
            lambda: dispatch.on_dismiss_linelists_window.emit(close=False))
        self.actionOpen.triggered.connect(
            lambda: self._open_linelist_file(file_name=None))
        self.actionExport.triggered.connect(
            lambda: self._export_to_file(file_name=None))
        self.line_list_selector.currentIndexChanged.connect(
            self._lineList_selection_change)
コード例 #3
0
    def __init__(self, hub, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.hub = hub

        self.wave_range = (None, None)

        loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_window.ui"), self)

        # QtDesigner can't add a combo box to a tool bar...
        self.line_list_selector = QComboBox()
        self.line_list_selector.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.line_list_selector.setMinimumWidth(230)
        self.line_list_selector.setToolTip("Select line list from internal library")
        self.main_toolbar.addWidget(self.line_list_selector)

        # QtDesigner creates tabbed widgets with 2 tabs, and doesn't allow
        # removing then in the designer itself. Remove in here then.
        while self.tab_widget.count() > 0:
            self.tab_widget.removeTab(0)

        # Local references for often used objects.
        self.plot_window = self.hub.plot_window

        # Request that line lists be read from wherever are they sources.
        if not hasattr(self, 'linelists'):
            self._request_linelists()

            # Populate line list selector with internal line lists
            model = self.line_list_selector.model()
            item = QStandardItem("Select line list")
            font = QFont("Monospace")
            font.setStyleHint(QFont.TypeWriter)
            font.setPointSize(12)
            item.setFont(font)
            model.appendRow(item)
            for description in linelist.descriptions():
                item = QStandardItem(str(description))
                item.setFont(font)
                model.appendRow(item)

        self.line_labels_plotter = LineLabelsPlotter(self)

        # Connect controls to appropriate signals.

        self.draw_button.clicked.connect(
            lambda:self.line_labels_plotter._plot_linelists(
            table_views=self._get_table_views(),
            panes=self._get_panes(),
            units=self.hub.plot_widget.spectral_axis_unit,
            caller=self.line_labels_plotter))

        self.erase_button.clicked.connect(lambda:self.erase_linelabels.emit(self.plot_window.plot_widget))
        self.dismiss_button.clicked.connect(self.dismiss_linelists_window.emit)

        self.actionOpen.triggered.connect(lambda:self._open_linelist_file(file_name=None))
        self.actionExport.triggered.connect(lambda:self._export_to_file(file_name=None))
        self.line_list_selector.currentIndexChanged.connect(self._lineList_selection_change)
        self.tab_widget.tabCloseRequested.connect(self._on_tab_close)

        self.hub.plot_window.window_removed.connect(self.dismiss_linelists_window.emit)