Exemplo n.º 1
0
    def __init__(self):
        super().__init__()

        self.setGeometry(350, 350, 700, 250)
        self.setWindowTitle('Speicherdialog')

        self.textBrowser = QLabel(self)
        self.textBrowser.setGeometry(QtCore.QRect(60, 30, 551, 51))
        self.textBrowser.setObjectName("textBrowser")
        self.textBrowser_2 = QTextBrowser(self)
        self.textBrowser.setText('Wo möchten Sie die Dateien speichern?')
        self.textBrowser_2.setGeometry(QtCore.QRect(160, 140, 451, 31))
        self.textBrowser_2.setObjectName("textBrowser_2")
        self.textBrowser_2.textChanged.connect(self.weiter)
        self.label = QLabel(self)
        self.label.setText("Speicherort:")
        self.label.setGeometry(QtCore.QRect(60, 140, 101, 31))
        self.label.setObjectName("label")
        self.button = QPushButton(" Fertig", self)
        self.button.setGeometry(QtCore.QRect(540, 180, 75, 23))
        self.button.setDisabled(True)
        self.button.clicked.connect(self.close)
        button2 = QPushButton('Datei Speichern', self)
        button2.setGeometry(QtCore.QRect(160, 180, 121, 23))

        button2.clicked.connect(self.speichern)  #

        self.show()
Exemplo n.º 2
0
class TextShowDialog(QDialog):
    def __init__(self, title: str, parent=None):
        super(TextShowDialog, self).__init__(parent=parent)
        self.setLayout(QVBoxLayout())
        self.setWindowTitle(title)
        self.text_widget = QTextBrowser()
        self.layout().addWidget(self.text_widget)

    def set_markdown(self, markdown: str):
        self.text_widget.setMarkdown(markdown)

    def sizeHint(self) -> QSize:
        return QSize(800, 600)
Exemplo n.º 3
0
    def __init__(self, parent: QWidget = None):
        super(ReportWidget, self).__init__(parent)
        self.setLayout(QVBoxLayout())
        self.label_brief = QLabel()
        self.label_brief.setWordWrap(True)
        self.layout().addWidget(self.label_brief)
        self.detailed_info_show = QTextBrowser()
        self.layout().addWidget(self.detailed_info_show)
        self.ok_button = QPushButton()
        self.ok_button.setText(self.tr('Ok'))
        self.layout().addWidget(self.ok_button)

        self.ok_button.clicked.connect(self.close)
        self.setMinimumWidth(400)
Exemplo n.º 4
0
    def _build_GUI(self, linelist, table_view):
        panel_layout = QVBoxLayout()
        panel_layout.setSizeConstraint(QLayout.SetMaximumSize)
        self.setLayout(panel_layout)

        # GUI cannot be completely defined in a .ui file.
        # It has to be built on-the-fly here.
        self.button_pane = QWidget()
        loadUi(
            os.path.join(os.path.dirname(__file__), "ui",
                         "linelists_panel_buttons.ui"), self.button_pane)
        self.button_pane.create_set_button.clicked.connect(self._createSet)
        self.button_pane.deselect_button.clicked.connect(
            table_view.clearSelection)

        # header with line list metadata.
        info = QTextBrowser()
        info.setMaximumHeight(100)
        info.setAutoFillBackground(True)
        info.setStyleSheet("background-color: rgb(230,230,230);")
        for comment in linelist.meta['comments']:
            info.append(comment)

        # populate color picker
        model = self.button_pane.combo_box_color.model()
        for cname in ID_COLORS:
            item = QStandardItem(cname)
            item.setForeground(ID_COLORS[cname])
            item.setData(QColor(ID_COLORS[cname]), role=Qt.UserRole)
            model.appendRow(item)

        # set validators
        validator = QDoubleValidator()
        validator.setRange(0.05, 0.95, decimals=2)
        self.button_pane.height_textbox.setValidator(validator)
        validator = QDoubleValidator()
        validator.setRange(-1.e5, 1.e10, decimals=4)
        self.button_pane.redshift_textbox.setValidator(validator)

        model = self.button_pane.combo_box_z_units.model()
        for uname in ['z', 'km/s']:
            item = QStandardItem(uname)
            model.appendRow(item)

        # put it all together
        panel_layout.addWidget(info)
        panel_layout.addWidget(table_view)
        panel_layout.addWidget(self.button_pane)
Exemplo n.º 5
0
    def _buildLinelistPane(self, table, comments):
        pane = QWidget()

        layout = QVBoxLayout()
        layout.setSizeConstraint(QLayout.SetMaximumSize)
        info = QTextBrowser()
        info.setMaximumHeight(100)
        info.setAutoFillBackground(True)
        info.setStyleSheet("background-color: rgb(230,230,230);")

        for comment in comments:
            info.append(comment)

        layout.addWidget(info)
        layout.addWidget(table)
        pane.setLayout(layout)

        return pane
Exemplo n.º 6
0
    def _build_GUI(self, linelist, table_view):
        panel_layout = QGridLayout()
        panel_layout.setSizeConstraint(QLayout.SetMaximumSize)
        self.setLayout(panel_layout)

        # GUI cannot be completely defined in a .ui file.
        # It has to be built on-the-fly here.
        self.button_pane = QWidget()
        loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_panel_buttons.ui"), self.button_pane)

        # internal signals do not use Hub infrastructure.
        self.button_pane.create_set_button.clicked.connect(self._create_set)
        self.button_pane.deselect_button.clicked.connect(table_view.clearSelection)

        # header with line list metadata.
        info = QTextBrowser()
        info.setMaximumHeight(100)
        info.setAutoFillBackground(True)
        info.setStyleSheet("background-color: rgb(230,230,230);")
        for comment in linelist.meta['comments']:
            info.append(comment)

        # populate color picker
        model = self.button_pane.combo_box_color.model()
        for cname in ID_COLORS:
            item = QStandardItem(cname)
            item.setForeground(ID_COLORS[cname])
            item.setData(QColor(ID_COLORS[cname]), role=Qt.UserRole)
            model.appendRow(item)

        # set validators
        validator = QDoubleValidator()
        validator.setRange(0.05, 0.95, decimals=2)
        self.button_pane.height_textbox.setValidator(validator)
        validator = QDoubleValidator()
        validator.setRange(-1.e5, 1.e10, decimals=4)
        self.button_pane.redshift_textbox.setValidator(validator)

        model = self.button_pane.combo_box_z_units.model()
        for uname in ['z', 'km/s']:
            item = QStandardItem(uname)
            model.appendRow(item)

        # put it all together
        panel_layout.addWidget(info,0,0)
        panel_layout.addWidget(table_view,1,0)
        panel_layout.addWidget(self.button_pane,2,0)
Exemplo n.º 7
0
class PropertiesPane(QDockWidget):
    """ Simple text widget to display molecule properties. """
    def __init__(self, parent):
        super(PropertiesPane, self).__init__(parent)
        self.setWindowTitle('Properties')
        self._text_widget = QTextBrowser(self)
        self.setWidget(self._text_widget)

    def set_mol(self, mol):
        """ Set the Mol to display properties for. """
        properties = self._get_properties(mol)
        prop_rows = [
            '<tr><td>{}: </td><td>{}</td></tr>'.format(*p)
            for p in properties.items()
        ]
        html = '<table>' + '\n'.join(prop_rows) + '</table>'
        self._text_widget.setHtml(html)

    def _get_properties(self, mol):
        properties = OrderedDict()
        properties['Name'] = mol.name
        properties['Number of atoms'] = len(mol.atoms)

        atom_counts = Counter(mol.atoms)
        chem_formula = ''
        for atom, count in sorted(atom_counts.items()):
            chem_formula += atom
            if count > 1:
                chem_formula += str(count)
        properties['Chemical Formula'] = chem_formula

        mol_formula = formula(chem_formula)
        properties['Molecular Mass'] = mol_formula.mass
        mass_composition = {
            str(a): mass
            for a, mass in mol_formula.mass_fraction.items()
        }
        properties['Mass Composition'] = '<br>'.join([
            '{0}: {1:.2f}%'.format(p[0], p[1] * 100)
            for p in sorted(mass_composition.items())
        ])
        return properties
Exemplo n.º 8
0
    def setup_layout(self):
        self.instantiated = False
        layout = QGridLayout()

        self.load_atlas_button = add_button(
            "Load atlas",
            layout,
            self.load_atlas,
            0,
            0,
            minimum_width=200,
        )
        self.load_reference_button = add_button(
            "Load reference image",
            layout,
            self.load_reference,
            1,
            0,
            visibility=False,
        )
        self.load_annotated_button = add_button(
            "Load annotated image",
            layout,
            self.load_annotated,
            2,
            0,
            visibility=False,
        )

        layout.setAlignment(QtCore.Qt.AlignTop)
        layout.setSpacing(4)
        self.status_label = QLabel()

        self.status_label.setText("Ready")

        layout.addWidget(self.status_label, 4, 0)

        self.info_box = QTextBrowser()
        self.info_box.setVisible(False)
        layout.addWidget(self.info_box)
        self.setLayout(layout)
Exemplo n.º 9
0
class SpeicherFenster(QWidget):
    def __init__(self):
        super().__init__()

        self.setGeometry(350, 350, 700, 250)
        self.setWindowTitle('Speicherdialog')

        self.textBrowser = QLabel(self)
        self.textBrowser.setGeometry(QtCore.QRect(60, 30, 551, 51))
        self.textBrowser.setObjectName("textBrowser")
        self.textBrowser_2 = QTextBrowser(self)
        self.textBrowser.setText('Wo möchten Sie die Dateien speichern?')
        self.textBrowser_2.setGeometry(QtCore.QRect(160, 140, 451, 31))
        self.textBrowser_2.setObjectName("textBrowser_2")
        self.textBrowser_2.textChanged.connect(self.weiter)
        self.label = QLabel(self)
        self.label.setText("Speicherort:")
        self.label.setGeometry(QtCore.QRect(60, 140, 101, 31))
        self.label.setObjectName("label")
        self.button = QPushButton(" Fertig", self)
        self.button.setGeometry(QtCore.QRect(540, 180, 75, 23))
        self.button.setDisabled(True)
        self.button.clicked.connect(self.close)
        button2 = QPushButton('Datei Speichern', self)
        button2.setGeometry(QtCore.QRect(160, 180, 121, 23))

        button2.clicked.connect(self.speichern)  #

        self.show()

    def speichern(
        self
    ):  #schreibt ausgewählten Dateiname - und Pfad in Textfenster und auf die Variable self.ausgabename(zur späteren verwendung)
        pfad = ''
        if path.exists(
                'G:/TS-X1/Studenten/2020_SGuenther_NVH/Umwandler/Vorlagen/'
        ) == True:
            pfad = 'G:/TS-X1/Studenten/2020_SGuenther_NVH/Umwandler/Vorlagen/'
        self.ausgabename = QFileDialog.getSaveFileName(self,
                                                       'Vorlage speichern',
                                                       pfad)[0]
        self.textBrowser_2.clear()

        if '.' in self.ausgabename[
                -5:]:  # in dieser Verzweigung werden evtl. angefügt Dateiendungen(wie .xlsx) wieder entfernt, da diese später automatisch angehangen werden
            ind = -self.ausgabename.rfind('.')
            self.ausgabename = self.ausgabenamen[:ind - 1]
        self.textBrowser_2.setText(str(self.ausgabename))

    def weiter(self):
        self.button.setDisabled(False)
Exemplo n.º 10
0
class QLogger(logging.Handler):
    """
    Logger handler
    """
    def __init__(self, parent):
        super().__init__()
        self.widget = QTextBrowser(parent)
        self.widget.setReadOnly(True)

    def clear(self):
        """Clear widget."""
        self.widget.setText("")

    def emit(self, record):
        """
        Append logger record to text browser.

        Parameters
        ----------
        record : str
            logger record

        """
        record = self.format(record)
        self.widget.append(record)
Exemplo n.º 11
0
class ReportWidget(QDialog):
    def __init__(self, parent: QWidget = None):
        super(ReportWidget, self).__init__(parent)
        self.setLayout(QVBoxLayout())
        self.label_brief = QLabel()
        self.label_brief.setWordWrap(True)
        self.layout().addWidget(self.label_brief)
        self.detailed_info_show = QTextBrowser()
        self.layout().addWidget(self.detailed_info_show)
        self.ok_button = QPushButton()
        self.ok_button.setText(self.tr('Ok'))
        self.layout().addWidget(self.ok_button)

        self.ok_button.clicked.connect(self.close)
        self.setMinimumWidth(400)

    def show_info(self, brief: str, detailed: str, title=''):
        if title == '':
            title = self.tr('Info')
        self.label_brief.setText(brief)
        self.detailed_info_show.setText(detailed)
        self.setWindowTitle(title)
Exemplo n.º 12
0
def make_build_popup(gui, cwd):
    """ Dialog box for running build_mfixsolver to build the solver """

    build_popup = get_ui('build_popup.ui')

    # override sizeHint
    build_popup.sizeHint = lambda: _size_hint(build_popup)

    # add output widget
    tb = build_popup.textBrowser_output = QTextBrowser()
    build_popup.verticalLayout_run_dialog.addWidget(tb)
    tb.setVisible(False)

    build_popup.cwd = cwd
    build_popup.build_proc = None
    build_popup.min_height = None
    build_popup.setModal(False)
    build_popup.setWindowTitle('Build Solver')

    # don't show options on windows
    visible = os.name != 'nt'

    build_popup.gui_comments = gui.project.mfix_gui_comments

    if not visible:
        build_popup.compiler_groupbox.setVisible(False)
    else:
        _init_compiler(build_popup, build_popup.comboBox_compiler, visible)
        _init_flags(build_popup, visible)

    _init_crow(build_popup, build_popup.checkBox_crow)
    _init_dmp(build_popup, build_popup.checkBox_dmp, visible)
    _init_parallel(build_popup)
    _init_smp(build_popup, build_popup.checkBox_smp, visible)

    build_popup.pushButton_build.clicked.connect(lambda: _build(build_popup))
    build_popup.pushButton_clean.clicked.connect(lambda: _clean(build_popup))
    build_popup.pushButton_cancel.clicked.connect(lambda: _cancel(build_popup))
    build_popup.pushButton_show_out.clicked.connect(lambda: _toggle_output(build_popup))

    _resize_widgets(build_popup, visible)
    _set_output_visible(build_popup, False)
    _update_build_cmd(build_popup)

    fortran_compilers = ['gfortran', 'ifort', 'mpifort', 'mpiifort', 'mpif90']
    build_popup.comboBox_compiler.addItems([compiler for compiler in fortran_compilers if shutil.which(compiler)])

    return build_popup
Exemplo n.º 13
0
    def __init__(self, parent=None, options_button=None):
        QWidget.__init__(self, parent)

        # central widget
        self.textBrowser = QTextBrowser(self)
        # self.textBrowser = TextBrowserBase(self)

        btn_layout = QHBoxLayout()
        for btn in self.setup_buttons():
            btn.setIconSize(QSize(16, 16))
            btn_layout.addWidget(btn)
        if options_button:
            btn_layout.addStretch()
            btn_layout.addWidget(options_button, Qt.AlignRight)

        layout = create_plugin_layout(btn_layout, self.textBrowser)
        self.setLayout(layout)
Exemplo n.º 14
0
 def __init__(self, parent):
     super().__init__()
     self.widget = QTextBrowser(parent)
     self.widget.setReadOnly(True)
Exemplo n.º 15
0
    def __init__(self, content=None, description=None):
        super(InfoDialog, self).__init__()

        self.wikiLink = "https://github.com/eliranwong/UniqueBible/wiki"

        self.setMinimumWidth(500)
        self.setMinimumHeight(500)
        self.setWindowTitle(config.thisTranslation["info"])
        self.layout = QVBoxLayout()

        self.appName = QLabel("UniqueBible.app - {:.2f}".format(
            config.version))
        self.appName.setStyleSheet("QLabel {font-size: 30px;}")
        self.appName.mouseReleaseEvent = self.openWiki
        self.layout.addWidget(self.appName)

        filesHBox = QHBoxLayout()

        filesVBox1 = QVBoxLayout()
        count = len(
            FileUtil.getAllFilesWithExtension(config.marvelData + "/bibles",
                                              ".bible"))
        filesVBox1.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu5_bible"],
                                     count)))
        count = len(
            FileUtil.getAllFilesWithExtension(config.marvelData + "/lexicons",
                                              ".lexicon"))
        filesVBox1.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["lexicons"],
                                     count)))
        count = len(
            FileUtil.getAllFilesWithExtension(
                config.marvelData + "/devotionals", ".devotional"))
        filesVBox1.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["devotionals"],
                                     count)))
        count = len(FileUtil.getAllFilesWithExtension("music", ".mp3"))
        filesVBox1.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu11_music"],
                                     count)))
        filesVBox1.addWidget(
            QLabel("{0}: {1}".format(
                config.thisTranslation["menu1_menuLayout"],
                config.menuLayout)))
        filesHBox.addLayout(filesVBox1)

        filesVBox2 = QVBoxLayout()
        count = len(
            FileUtil.getAllFilesWithExtension(
                config.marvelData + "/commentaries", ".commentary"))
        filesVBox2.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["commentaries"],
                                     count)))
        count = len(
            FileUtil.getAllFilesWithExtension(config.marvelData + "/books",
                                              ".book"))
        filesVBox2.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu10_books"],
                                     count)))
        count = len(FileUtil.getAllFilesWithExtension("video", ".mp4"))
        filesVBox2.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu11_video"],
                                     count)))
        filesVBox2.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu_language"],
                                     config.displayLanguage)))
        filesVBox2.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu_shortcuts"],
                                     config.menuShortcuts)))
        filesHBox.addLayout(filesVBox2)

        filesVBox3 = QVBoxLayout()
        count = len(
            FileUtil.getAllFilesWithExtension(config.marvelData + "/pdf",
                                              ".pdf"))
        filesVBox3.addWidget(QLabel("{0}: {1}".format("PDF", count)))
        count = len(
            FileUtil.getAllFilesWithExtension(config.marvelData + "/epub",
                                              ".epub"))
        filesVBox3.addWidget(QLabel("{0}: {1}".format("EPUB", count)))
        count = len(
            FileUtil.getAllFilesWithExtension(config.marvelData + "/docx",
                                              ".docx"))
        filesVBox3.addWidget(QLabel("{0}: {1}".format("DOCX", count)))
        filesVBox3.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu_window"],
                                     config.windowStyle)))
        filesVBox3.addWidget(
            QLabel("{0}: {1}".format(config.thisTranslation["menu_theme"],
                                     config.theme)))
        filesHBox.addLayout(filesVBox3)

        self.layout.addLayout(filesHBox)

        if content is None:
            with open("latest_changes.txt", "r",
                      encoding="utf-8") as fileObject:
                text = fileObject.read()
        else:
            text = content
        html = text
        urls = re.compile(
            r"((https?):((//)|(\\\\))+[\w\d:#@%/;$~_?\+-=\\\.&]*)",
            re.MULTILINE | re.UNICODE)
        html = urls.sub(r'<a href="\1" >\1</a>', html)
        html = html.replace("\n", "<br>")
        latest = QLabel("{0}:".format(config.thisTranslation["latest_changes"]
                                      if description is None else description))
        latest.setStyleSheet("QLabel {font-size: 20px;}")
        self.layout.addWidget(latest)
        self.latestChanges = QTextBrowser()
        self.latestChanges.setOpenExternalLinks(True)
        self.latestChanges.insertHtml(html)
        self.latestChanges.setReadOnly(True)
        cursor = self.latestChanges.textCursor()
        cursor.setPosition(0)
        self.latestChanges.setTextCursor(cursor)
        self.layout.addWidget(self.latestChanges)

        buttons = QDialogButtonBox.Ok
        self.buttonBox = QDialogButtonBox(buttons)
        self.buttonBox.accepted.connect(self.accept)
        self.layout.addWidget(self.buttonBox)
        self.setLayout(self.layout)
Exemplo n.º 16
0
 def __init__(self, parent):
     super(PropertiesPane, self).__init__(parent)
     self.setWindowTitle('Properties')
     self._text_widget = QTextBrowser(self)
     self.setWidget(self._text_widget)
Exemplo n.º 17
0
class ViewerWidget(QWidget):
    def __init__(self, viewer, annotations_opacity=0.3):
        super(ViewerWidget, self).__init__()
        self.viewer = viewer
        self.annotations_opacity = annotations_opacity
        self.setup_layout()

    def setup_layout(self):
        self.instantiated = False
        layout = QGridLayout()

        self.load_atlas_button = add_button(
            "Load atlas",
            layout,
            self.load_atlas,
            0,
            0,
            minimum_width=200,
        )
        self.load_reference_button = add_button(
            "Load reference image",
            layout,
            self.load_reference,
            1,
            0,
            visibility=False,
        )
        self.load_annotated_button = add_button(
            "Load annotated image",
            layout,
            self.load_annotated,
            2,
            0,
            visibility=False,
        )

        layout.setAlignment(QtCore.Qt.AlignTop)
        layout.setSpacing(4)
        self.status_label = QLabel()

        self.status_label.setText("Ready")

        layout.addWidget(self.status_label, 4, 0)

        self.info_box = QTextBrowser()
        self.info_box.setVisible(False)
        layout.addWidget(self.info_box)
        self.setLayout(layout)

    def load_atlas(self):
        self.status_label.setText("Loading...")
        directory = choose_directory_dialog(parent=self,
                                            prompt="Select atlas directory")

        # deal with existing dialog
        if directory != "":
            self.atlas_directory = Path(directory)
            self.initialise_atlas_paths()
            self.load_structures()
            self.load_atlas_button.setText("Load new atlas")
            self.load_reference_button.setVisible(True)
            self.load_annotated_button.setVisible(True)
            self.fill_info_box()

        self.status_label.setText("Ready")

    def initialise_atlas_paths(self):
        self.metadata_path = self.atlas_directory / "metadata.json"
        self.structures_path = self.atlas_directory / "structures.json"
        self.annotated_path = self.atlas_directory / "annotation.tiff"
        self.reference_path = self.atlas_directory / "reference.tiff"
        self.meshes_dir = self.atlas_directory / "meshes"

    def load_structures(self):
        self.structures = pd.read_json(self.structures_path)

    def fill_info_box(self):
        metadata_formatted = self.load_metadata()
        self.info_box.setVisible(True)
        self.info_box.setText(metadata_formatted)

    def load_metadata(self):
        metadata_formatted = ""
        with open(self.metadata_path) as json_file:
            self.metadata = json.load(json_file)
        for item in self.metadata:
            metadata_formatted = (metadata_formatted +
                                  f"{item}: {self.metadata[item]}\n")

        return metadata_formatted

    def load_reference(self):
        self.load_image(self.reference_path, name="Reference")

    def load_annotated(self):
        self.annotation_labels = self.load_labels(
            self.annotated_path,
            name="Annotations",
            opacity=self.annotations_opacity,
        )

        @self.annotation_labels.mouse_move_callbacks.append
        def display_region_name(layer, event):
            display_brain_region_name(layer, self.structures)

    def load_image(self,
                   image_path,
                   use_dask=True,
                   stack=True,
                   name=None,
                   opacity=1):
        image = self.viewer.add_image(
            magic_imread(image_path, use_dask=use_dask, stack=stack),
            name=name,
            opacity=opacity,
        )
        return image

    def load_labels(self,
                    image_path,
                    use_dask=True,
                    stack=True,
                    name=None,
                    opacity=1):
        labels = self.viewer.add_labels(
            magic_imread(image_path, use_dask=use_dask, stack=stack),
            name=name,
            opacity=opacity,
        )
        return labels
Exemplo n.º 18
0
    def _build_GUI(self, linelist, table_view):
        panel_layout = QVBoxLayout()
        panel_layout.setSizeConstraint(QLayout.SetMaximumSize)
        self.setLayout(panel_layout)
        # header with line list metadata.
        info = QTextBrowser()
        info.setMaximumHeight(100)
        info.setAutoFillBackground(True)
        info.setStyleSheet("background-color: rgb(230,230,230);")
        for comment in linelist.meta['comments']:
            info.append(comment)

        # buttons and selectors dedicated to the specific list
        # displayed in this pane.
        button_pane = QWidget()
        hlayout = QGridLayout()

        # 'add set' button
        self.create_set_button = QPushButton(self)
        self.create_set_button.setObjectName("add_set_button")
        _translate = QCoreApplication.translate
        self.create_set_button.setText(_translate("MainWindow", "Create set"))
        self.create_set_button.setToolTip(
            "Create new line set from selected lines.")
        self.create_set_button.setSizePolicy(QSizePolicy.Minimum,
                                             QSizePolicy.Minimum)
        hlayout.addWidget(self.create_set_button, 1, 0)

        # the create_set button is enabled/disabled by logic elsewhere
        self.create_set_button.setEnabled(False)
        self.create_set_button.clicked.connect(lambda: self._createSet())

        # 'deselect all' button
        deselect_button = QPushButton(self)
        deselect_button.setObjectName("deselect_button")
        _translate = QCoreApplication.translate
        deselect_button.setText(_translate("MainWindow", "Deselect"))
        deselect_button.setToolTip("Un-select everything on this set.")
        deselect_button.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        hlayout.addWidget(deselect_button, 1, 1)
        deselect_button.clicked.connect(lambda: table_view.clearSelection())

        # color picker
        self.combo_box_color = QComboBox(self)
        self.combo_box_color.setObjectName("color_selector")
        self.combo_box_color.setToolTip(
            "Color for selected lines in this set.")
        model = self.combo_box_color.model()
        for cname in ID_COLORS:
            item = QStandardItem(cname)
            item.setForeground(ID_COLORS[cname])
            item.setData(QColor(ID_COLORS[cname]), role=Qt.UserRole)
            model.appendRow(item)
        hlayout.addWidget(self.combo_box_color, 1, 2)
        hlayout.addWidget(QLabel("Color"), 0, 2)

        # plotting height
        self.height_textbox = QLineEdit(str(DEFAULT_HEIGHT))
        validator = QDoubleValidator()
        validator.setRange(0.05, 0.95, decimals=2)
        self.height_textbox.setValidator(validator)
        self.height_textbox.setFixedWidth(50)
        self.height_textbox.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.height_textbox.setToolTip("Relative height to plot.")
        hlayout.addWidget(self.height_textbox, 1, 3)
        hlayout.addWidget(QLabel("Height"), 0, 3)

        # redshift
        self.redshift_textbox = QLineEdit(str(0.0))
        validator = QDoubleValidator()
        validator.setRange(-1.e5, 1.e10, decimals=4)
        self.redshift_textbox.setValidator(validator)
        self.redshift_textbox.setFixedWidth(70)
        self.redshift_textbox.setSizePolicy(QSizePolicy.Fixed,
                                            QSizePolicy.Fixed)
        self.redshift_textbox.setToolTip("Redshift lines by")
        hlayout.addWidget(self.redshift_textbox, 1, 4)
        hlayout.addWidget(QLabel("Redshift"), 0, 4)

        # redshift units
        self.combo_box_z_units = QComboBox(self)
        self.combo_box_z_units.setObjectName("redshift_units")
        self.combo_box_z_units.setToolTip("Redshift units.")
        model = self.combo_box_z_units.model()
        for uname in ['z', 'km/s']:
            item = QStandardItem(uname)
            model.appendRow(item)
        hlayout.addWidget(self.combo_box_z_units, 1, 5)

        # put it all together.
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        hlayout.addItem(spacerItem, 1, 6)
        button_pane.setLayout(hlayout)

        panel_layout.addWidget(info)
        panel_layout.addWidget(table_view)
        panel_layout.addWidget(button_pane)
Exemplo n.º 19
0
 def __init__(self, title: str, parent=None):
     super(TextShowDialog, self).__init__(parent=parent)
     self.setLayout(QVBoxLayout())
     self.setWindowTitle(title)
     self.text_widget = QTextBrowser()
     self.layout().addWidget(self.text_widget)