コード例 #1
0
            def show_tb(parent):
                tbdialog = QDialog(parent=parent.parent())
                tbdialog.setModal(True)
                # this is about the minimum width to not get rewrap
                # and the minimum height to not have scrollbar
                tbdialog.resize(650, 270)
                tbdialog.setLayout(QVBoxLayout())

                text = QTextEdit()
                text.setHtml(notification.as_html())
                text.setReadOnly(True)
                btn = QPushButton('Enter Debugger')

                def _enter_debug_mode():
                    btn.setText(
                        'Now Debugging. Please quit debugger in console '
                        'to continue'
                    )
                    _debug_tb(notification.exception.__traceback__)
                    btn.setText('Enter Debugger')

                btn.clicked.connect(_enter_debug_mode)
                tbdialog.layout().addWidget(text)
                tbdialog.layout().addWidget(btn, 0, Qt.AlignRight)
                tbdialog.show()
コード例 #2
0
    def __init__(self, theme='dark', emphasized=False):
        super().__init__(None)
        self.setProperty('emphasized', emphasized)
        self.setStyleSheet(template(raw_stylesheet, **palettes[theme]))
        lay = QVBoxLayout()
        self.setLayout(lay)
        lay.addWidget(QPushButton('push button'))
        box = QComboBox()
        box.addItems(['a', 'b', 'c', 'cd'])
        lay.addWidget(box)
        lay.addWidget(QFontComboBox())

        hbox = QHBoxLayout()
        chk = QCheckBox('tristate')
        chk.setToolTip('I am a tooltip')
        chk.setTristate(True)
        chk.setCheckState(Qt.PartiallyChecked)
        chk3 = QCheckBox('checked')
        chk3.setChecked(True)
        hbox.addWidget(QCheckBox('unchecked'))
        hbox.addWidget(chk)
        hbox.addWidget(chk3)
        lay.addLayout(hbox)

        lay.addWidget(TabDemo(emphasized=emphasized))

        sld = QSlider(Qt.Horizontal)
        sld.setValue(50)
        lay.addWidget(sld)
        scroll = QScrollBar(Qt.Horizontal)
        scroll.setValue(50)
        lay.addWidget(scroll)
        lay.addWidget(QHRangeSlider(parent=self))
        text = QTextEdit()
        text.setMaximumHeight(100)
        text.setHtml(blurb)
        lay.addWidget(text)
        lay.addWidget(QTimeEdit())
        edit = QLineEdit()
        edit.setPlaceholderText('LineEdit placeholder...')
        lay.addWidget(edit)
        lay.addWidget(QLabel('label'))
        prog = QProgressBar()
        prog.setValue(50)
        lay.addWidget(prog)
        groupBox = QGroupBox("Exclusive Radio Buttons")
        radio1 = QRadioButton("&Radio button 1")
        radio2 = QRadioButton("R&adio button 2")
        radio3 = QRadioButton("Ra&dio button 3")
        radio1.setChecked(True)
        hbox = QHBoxLayout()
        hbox.addWidget(radio1)
        hbox.addWidget(radio2)
        hbox.addWidget(radio3)
        hbox.addStretch(1)
        groupBox.setLayout(hbox)
        lay.addWidget(groupBox)
コード例 #3
0
            def show_tb(parent):
                tbdialog = QDialog(parent=parent.parent())
                tbdialog.setModal(True)
                # this is about the minimum width to not get rewrap
                # and the minimum height to not have scrollbar
                tbdialog.resize(650, 270)
                tbdialog.setLayout(QVBoxLayout())

                text = QTextEdit()
                text.setHtml(notification.as_html())
                text.setReadOnly(True)
                tbdialog.layout().addWidget(text)
                tbdialog.show()
コード例 #4
0
ファイル: EditSrcCodeInfoDialog.py プロジェクト: xxoolm/Ryven
    def __init__(self, parent):
        super(EditSrcCodeInfoDialog, self).__init__(parent)

        self.setLayout(QGridLayout())

        # info text edit
        info_text_edit = QTextEdit()
        info_text_edit.setHtml('''
            <h2 style="font-family: Poppins; font-size: xx-large; color: #a9d5ef;">Some info before you delete the
            universe</h2>
            <div style="font-family: Corbel; font-size: x-large;">
                <p>
                    Yes, you can change method implementations of objects.
                    This can be quite useful but since changing an instance's implementation at runtime is kinda sketchy, 
                    you should be a bit careful, it's not exactly bulletproof, and doesnt <i>always</i> work.
                    When you override a method implementation, a new function object will be created using python's ast 
                    module, which then gets bound to the object as method, which essentially shadows the old implementation. 
                    Therefore, you might need to add imports etc. you node uses in the original nodes package. 
                    All changes are temporary and only apply on a single 
                    object.
                </p>
                <p>
                    Have fun.
                </p>
            </div>
        ''')
        info_text_edit.setReadOnly(True)
        self.layout().addWidget(info_text_edit, 0, 0, 1, 2)

        dont_show_again_button = QPushButton('Stop being annoying')
        dont_show_again_button.clicked.connect(self.close_and_dont_show_again)
        self.layout().addWidget(dont_show_again_button, 1, 0)

        ok_button = QPushButton('Got it')
        ok_button.clicked.connect(self.accept)
        self.layout().addWidget(ok_button, 1, 1)

        ok_button.setFocus()

        self.setWindowTitle('Editing Source Code Info')
        self.resize(560, 366)
コード例 #5
0
    def fill_scans(self):
        o_step2_handler = Step2Utilities(parent=self.parent.parent)

        # table status
        self.parent.ui.table_status.insertRow(0)
        self.parent.ui.table_status.setRowHeight(0, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Empty?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_table_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(0, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_table_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(0, 1, _widget_2)

        # at least one row checked
        self.parent.ui.table_status.insertRow(1)
        self.parent.ui.table_status.setRowHeight(1, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Row Selected?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.at_least_one_row_checked():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(1, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(not o_step2_handler.at_least_one_row_checked())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(1, 1, _widget_2)

        # output file name
        self.parent.ui.table_status.insertRow(2)
        self.parent.ui.table_status.setRowHeight(2, self.row_height)
        _widget = QTextEdit()
        _text = "Output File Name?<br/><b>Post Processing>Output File Name</b>"
        _widget.setHtml(_text)
        if not o_step2_handler.is_scans_output_file_name_empty():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(2, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_scans_output_file_name_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_scans_output_file_name)
        self.parent.ui.table_status.setCellWidget(2, 1, _widget_2)
コード例 #6
0
    def fill_scans(self):
        o_step2_handler = Step2Utilities(parent=self.parent.parent)

        # table status
        self.parent.ui.table_status.insertRow(0)
        self.parent.ui.table_status.setRowHeight(0, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Empty?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_table_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(0, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_table_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(0, 1, _widget_2)

        # at least one row checked
        self.parent.ui.table_status.insertRow(1)
        self.parent.ui.table_status.setRowHeight(1, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Row Selected?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.at_least_one_row_checked():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(1, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(not o_step2_handler.at_least_one_row_checked())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(1, 1, _widget_2)

        # output file name
        self.parent.ui.table_status.insertRow(2)
        self.parent.ui.table_status.setRowHeight(2, self.row_height)
        _widget = QTextEdit()
        _text = "Output File Name?<br/><b>Post Processing>Output File Name</b>"
        _widget.setHtml(_text)
        if not o_step2_handler.is_scans_output_file_name_empty():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(2, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_scans_output_file_name_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_scans_output_file_name)
        self.parent.ui.table_status.setCellWidget(2, 1, _widget_2)
コード例 #7
0
    def fill_autonom(self):
        o_step1_handler = Step1Utilities(parent=self.parent.parent)

        # diamond
        self.parent.ui.table_status.insertRow(0)
        self.parent.ui.table_status.setRowHeight(0, self.row_height)
        _widget = QTextEdit()
        _text = "Diamond Field Empty?<br/><b>AutoNom>Diamond</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_diamond_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(0, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_diamond_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_diamond)
        self.parent.ui.table_status.setCellWidget(0, 1, _widget_2)

        # diamond background
        self.parent.ui.table_status.insertRow(1)
        self.parent.ui.table_status.setRowHeight(1, self.row_height)
        _widget = QTextEdit()
        _text = "Diamond Background Field Empty?<br/><b>AutoNom>Diamond Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_diamond_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(1, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step1_handler.is_diamond_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_diamond_background)
        self.parent.ui.table_status.setCellWidget(1, 1, _widget_2)

        # vanadium
        self.parent.ui.table_status.insertRow(2)
        self.parent.ui.table_status.setRowHeight(2, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Field Empty?<br/><b>AutoNom>Vanadium</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(2, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_vanadium_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium)
        self.parent.ui.table_status.setCellWidget(2, 1, _widget_2)

        # vanadium background
        self.parent.ui.table_status.insertRow(3)
        self.parent.ui.table_status.setRowHeight(3, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Background Field Empty?<br/><b>AutoNom>Vanadium Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(3, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step1_handler.is_vanadium_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium_background)
        self.parent.ui.table_status.setCellWidget(3, 1, _widget_2)

        # sample background
        self.parent.ui.table_status.insertRow(4)
        self.parent.ui.table_status.setRowHeight(4, self.row_height)
        _widget = QTextEdit()
        _text = "Sample Background Field Empty?<br/><b>AutoNom>Sample Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_sample_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(4, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_sample_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_sample_background)
        self.parent.ui.table_status.setCellWidget(4, 1, _widget_2)

        # create folder button
        self.parent.ui.table_status.insertRow(5)
        self.parent.ui.table_status.setRowHeight(5, self.row_height + 20)
        _widget = QTextEdit()
        _text = "Create Folder Button Status?<br/><b>AutoNom>Create New AutoNom Folder</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_create_folder_button_status_ok():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(5, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            not o_step1_handler.is_create_folder_button_status_ok())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_create_folder)
        self.parent.ui.table_status.setCellWidget(5, 1, _widget_2)
コード例 #8
0
    def fill_mantid(self):
        self.row_height = 62

        o_step1_handler = Step1Utilities(parent=self.parent.parent)
        o_step2_handler = Step2Utilities(parent=self.parent.parent)

        # vanadium
        _row = 0
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Field Empty?<br/><b>AutoNom>Vanadium</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_vanadium_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # vanadium background
        _row = 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Background Field Empty?<br/><b>AutoNom>Vanadium Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step1_handler.is_vanadium_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium_background)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # table status
        _row = 2
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Empty?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_table_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_table_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # at least one row checked
        _row = 3
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Row Selected?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.at_least_one_row_checked():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(not o_step2_handler.at_least_one_row_checked())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # calibration
        _row = 4
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Calibration File Selected?<br/><b>Post Processing>Rietveld>Calibration</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_calibration_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_calibration_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_browse_calibration)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # characterization
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Characterization File Selected?<br/><b>Post Processing>Rietveld>Characterization</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_characterization_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step2_handler.is_mantid_characterization_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(
            self.jump_to_step2_mantid_browse_characterization)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # number of bins int
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is Number of Bins an Int?<br/><b>Post Processing>Rietveld>Number of Bins</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_number_of_bins_no_int():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_number_of_bins_no_int())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_number_of_bins)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # min crop wavelegenth
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is min Crop Wavelength a float?<br/><b>Post Processing>Rietveld>Crop Wavelength Min</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_min_crop_wavelength_no_float():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step2_handler.is_mantid_min_crop_wavelength_no_float())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(
            self.jump_to_step2_mantid_min_crop_wavelength)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # max crop wavelegenth
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is max Crop Wavelength a float?<br/><b>Post Processing>Rietveld>Crop Wavelength Max</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_max_crop_wavelength_no_float():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step2_handler.is_mantid_max_crop_wavelength_no_float())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(
            self.jump_to_step2_mantid_max_crop_wavelength)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # vanadium radius
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is Vanadium Radius a float?<br/><b>Post Processing>Rietveld>Vanadium Radius</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_vanadium_radius_not_float():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step2_handler.is_mantid_vanadium_radius_not_float())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_vanadium_radius)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # output directory
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is Output Directory Empty?<br/><b>Post Processing>Rietveld>Output Directory</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_output_directory_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step2_handler.is_mantid_output_directory_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(
            self.jump_to_step2_mantid_output_directory_button)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)
コード例 #9
0
    def fill_ndabs(self):
        o_step2_handler = Step2Utilities(parent=self.parent.parent)

        # table status
        self.parent.ui.table_status.insertRow(0)
        self.parent.ui.table_status.setRowHeight(0, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Empty?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_table_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(0, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_table_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(0, 1, _widget_2)

        # at least one row checked
        self.parent.ui.table_status.insertRow(1)
        self.parent.ui.table_status.setRowHeight(1, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Row Selected?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.at_least_one_row_checked():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(1, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(not o_step2_handler.at_least_one_row_checked())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(1, 1, _widget_2)

        # missing fields in row checked
        self.parent.ui.table_status.insertRow(2)
        self.parent.ui.table_status.setRowHeight(2, self.row_height)
        _widget = QTextEdit()
        _text = "Is missing metadata in row checked?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.are_row_checked_have_missing_fields():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(2, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(
            o_step2_handler.are_row_checked_have_missing_fields())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(2, 1, _widget_2)

        # fourier filter from
        self.parent.ui.table_status.insertRow(3)
        self.parent.ui.table_status.setRowHeight(3, self.row_height)
        _widget = QTextEdit()
        _text = "Is Fourier From Widgets Empty?<br/><b>Post Processing>Fourier Filter From</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_fourier_filter_from_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(3, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_fourier_filter_from_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_fourier_from)
        self.parent.ui.table_status.setCellWidget(3, 1, _widget_2)

        # fourier filter to
        self.parent.ui.table_status.insertRow(4)
        self.parent.ui.table_status.setRowHeight(4, self.row_height)
        _widget = QTextEdit()
        _text = "Is Fourier To Widgets Empty?<br/><b>Post Processing>Fourier Filter To</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_fourier_filter_to_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(4, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_fourier_filter_to_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_fourier_to)
        self.parent.ui.table_status.setCellWidget(4, 1, _widget_2)

        # plazcek filter from
        self.parent.ui.table_status.insertRow(5)
        self.parent.ui.table_status.setRowHeight(5, self.row_height)
        _widget = QTextEdit()
        _text = "Is Plazcek From Widgets Empty?<br/><b>Post Processing>Plazcek Filter From</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_plazcek_from_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(5, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_plazcek_from_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_plazcek_from)
        self.parent.ui.table_status.setCellWidget(5, 1, _widget_2)

        #  plazcek filter to
        self.parent.ui.table_status.insertRow(6)
        self.parent.ui.table_status.setRowHeight(6, self.row_height)
        _widget = QTextEdit()
        _text = "Is Plazcek To Widgets Empty?<br/><b>Post Processing>Plazcek Filter To</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_plazcek_to_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(6, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_plazcek_to_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_plazcek_to)
        self.parent.ui.table_status.setCellWidget(6, 1, _widget_2)

        # q min
        self.parent.ui.table_status.insertRow(7)
        self.parent.ui.table_status.setRowHeight(7, self.row_height)
        _widget = QTextEdit()
        _text = "Is Q min Widgets Empty?<br/><b>Post Processing>Q min</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_q_min_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(7, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_q_min_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_q_min)
        self.parent.ui.table_status.setCellWidget(7, 1, _widget_2)

        #  q max
        self.parent.ui.table_status.insertRow(8)
        self.parent.ui.table_status.setRowHeight(8, self.row_height)
        _widget = QTextEdit()
        _text = "Is Q max Widgets Empty?<br/><b>Post Processing>Q max</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_q_max_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(8, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_q_max_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_q_max)
        self.parent.ui.table_status.setCellWidget(8, 1, _widget_2)

        #  output file name
        self.parent.ui.table_status.insertRow(9)
        self.parent.ui.table_status.setRowHeight(9, self.row_height)
        _widget = QTextEdit()
        _text = "Is Output File Name Empty?<br/><b>Post Processing>Output File Name</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_ndabs_output_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(9, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_ndabs_output_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_output_empty)
        self.parent.ui.table_status.setCellWidget(9, 1, _widget_2)
コード例 #10
0
class CaseInitializationConfigurationPanel(QTabWidget):
    @showWaitCursorWhileWaiting
    def __init__(self):
        QTabWidget.__init__(self)
        self.setWindowTitle("Case Management")
        self.setMinimumWidth(600)

        self.addCreateNewCaseTab()
        self.addInitializeFromScratchTab()
        self.addInitializeFromExistingTab()
        self.addShowCaseInfo()

    def addCreateNewCaseTab(self):
        panel = QWidget()
        layout = QVBoxLayout()
        case_list = CaseList()
        case_list.setMaximumWidth(250)

        layout.addWidget(case_list)
        layout.addStretch()

        panel.setLayout(layout)

        self.addTab(panel, "Create new case")

    def addInitializeFromScratchTab(self):
        panel = QWidget()
        layout = QVBoxLayout()

        row1 = createRow(QLabel("Target case:"), CaseSelector())
        layout.addLayout(row1)

        check_list_layout, parameter_model, members_model = createCheckLists()
        layout.addLayout(check_list_layout)

        layout.addSpacing(10)

        initialize_button = QPushButton("Initialize")
        addHelpToWidget(initialize_button, "init/initialize_from_scratch")
        initialize_button.setMinimumWidth(75)
        initialize_button.setMaximumWidth(150)

        def initializeFromScratch():
            parameters = parameter_model.getSelectedItems()
            members = members_model.getSelectedItems()
            initializeCurrentCaseFromScratch(parameters, members)

        initialize_button.clicked.connect(initializeFromScratch)
        layout.addWidget(initialize_button, 0, Qt.AlignCenter)

        layout.addSpacing(10)

        panel.setLayout(layout)
        self.addTab(panel, "Initialize from scratch")

    def addInitializeFromExistingTab(self):
        widget = QWidget()
        layout = QVBoxLayout()

        target_case = CaseSelector()
        row = createRow(QLabel("Target case:"), target_case)
        layout.addLayout(row)

        source_case = CaseSelector(update_ert=False,
                                   show_only_initialized=True,
                                   ignore_current=True)
        row = createRow(QLabel("Source case:"), source_case)
        layout.addLayout(row)

        row, history_length_spinner = self.createTimeStepRow()
        layout.addLayout(row)

        layout.addSpacing(10)
        check_list_layout, parameter_model, members_model = createCheckLists()
        layout.addLayout(check_list_layout)
        layout.addSpacing(10)

        initialize_button = QPushButton("Initialize")
        addHelpToWidget(initialize_button, "init/initialize_from_existing")
        initialize_button.setMinimumWidth(75)
        initialize_button.setMaximumWidth(150)

        def initializeFromExisting():
            source_case_name = str(source_case.currentText())
            target_case_name = str(target_case.currentText())
            report_step = history_length_spinner.value()
            parameters = parameter_model.getSelectedItems()
            members = members_model.getSelectedItems()
            initializeCurrentCaseFromExisting(source_case_name,
                                              target_case_name, report_step,
                                              parameters, members)

        initialize_button.clicked.connect(initializeFromExisting)
        layout.addWidget(initialize_button, 0, Qt.AlignCenter)

        layout.addSpacing(10)

        layout.addStretch()
        widget.setLayout(layout)
        self.addTab(widget, "Initialize from existing")

    def createTimeStepRow(self):
        history_length_spinner = QSpinBox()
        addHelpToWidget(history_length_spinner, "config/init/history_length")
        history_length_spinner.setMinimum(0)
        history_length_spinner.setMaximum(getHistoryLength())

        initial = QToolButton()
        initial.setText("Initial")
        addHelpToWidget(initial, "config/init/history_length")

        def setToMin():
            history_length_spinner.setValue(0)

        initial.clicked.connect(setToMin)

        end_of_time = QToolButton()
        end_of_time.setText("End of time")
        addHelpToWidget(end_of_time, "config/init/history_length")

        def setToMax():
            history_length_spinner.setValue(getHistoryLength())

        end_of_time.clicked.connect(setToMax)

        row = createRow(QLabel("Timestep:"), history_length_spinner, initial,
                        end_of_time)

        return row, history_length_spinner

    def addShowCaseInfo(self):
        case_widget = QWidget()
        layout = QVBoxLayout()

        case_selector = CaseSelector(update_ert=False,
                                     help_link="init/selected_case_info")
        row1 = createRow(QLabel("Select case:"), case_selector)

        layout.addLayout(row1)

        self._case_info_area = QTextEdit()
        self._case_info_area.setReadOnly(True)
        self._case_info_area.setMinimumHeight(300)

        row2 = createRow(QLabel("Case info:"), self._case_info_area)

        layout.addLayout(row2)

        case_widget.setLayout(layout)

        case_selector.currentIndexChanged[str].connect(self._showInfoForCase)
        ERT.ertChanged.connect(self._showInfoForCase)

        self.addTab(case_widget, "Case Info")

        self._showInfoForCase()

    def _showInfoForCase(self, case_name=None):
        if case_name is None:
            case_name = getCurrentCaseName()

        states = getCaseRealizationStates(str(case_name))

        html = "<table>"
        for index in range(len(states)):
            html += "<tr><td width=30>%d.</td><td>%s</td></tr>" % (
                index, str(states[index]))

        html += "</table>"

        self._case_info_area.setHtml(html)
コード例 #11
0
    def fill_autonom(self):
        o_step1_handler = Step1Utilities(main_window=self.parent.parent)

        # diamond
        self.parent.ui.table_status.insertRow(0)
        self.parent.ui.table_status.setRowHeight(0, self.row_height)
        _widget = QTextEdit()
        _text = "Diamond Field Empty?<br/><b>AutoNom>Diamond</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_diamond_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(0, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_diamond_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_diamond)
        self.parent.ui.table_status.setCellWidget(0, 1, _widget_2)

        # diamond background
        self.parent.ui.table_status.insertRow(1)
        self.parent.ui.table_status.setRowHeight(1, self.row_height)
        _widget = QTextEdit()
        _text = "Diamond Background Field Empty?<br/><b>AutoNom>Diamond Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_diamond_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(1, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_diamond_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_diamond_background)
        self.parent.ui.table_status.setCellWidget(1, 1, _widget_2)

        # vanadium
        self.parent.ui.table_status.insertRow(2)
        self.parent.ui.table_status.setRowHeight(2, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Field Empty?<br/><b>AutoNom>Vanadium</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(2, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_vanadium_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium)
        self.parent.ui.table_status.setCellWidget(2, 1, _widget_2)

        # vanadium background
        self.parent.ui.table_status.insertRow(3)
        self.parent.ui.table_status.setRowHeight(3, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Background Field Empty?<br/><b>AutoNom>Vanadium Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(3, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_vanadium_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium_background)
        self.parent.ui.table_status.setCellWidget(3, 1, _widget_2)

        # sample background
        self.parent.ui.table_status.insertRow(4)
        self.parent.ui.table_status.setRowHeight(4, self.row_height)
        _widget = QTextEdit()
        _text = "Sample Background Field Empty?<br/><b>AutoNom>Sample Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_sample_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(4, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_sample_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_sample_background)
        self.parent.ui.table_status.setCellWidget(4, 1, _widget_2)

        # create folder button
        self.parent.ui.table_status.insertRow(5)
        self.parent.ui.table_status.setRowHeight(5, self.row_height + 20)
        _widget = QTextEdit()
        _text = "Create Folder Button Status?<br/><b>AutoNom>Create New AutoNom Folder</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_create_folder_button_status_ok():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(5, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(not o_step1_handler.is_create_folder_button_status_ok())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_create_folder)
        self.parent.ui.table_status.setCellWidget(5, 1, _widget_2)
コード例 #12
0
    def fill_mantid(self):
        self.row_height = 62

        o_step1_handler = Step1Utilities(main_window=self.parent.parent)
        o_step2_handler = Step2Utilities(parent=self.parent.parent)

        # vanadium
        _row = 0
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Field Empty?<br/><b>AutoNom>Vanadium</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_vanadium_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # vanadium background
        _row = 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Vanadium Background Field Empty?<br/><b>AutoNom>Vanadium Background</b>"
        _widget.setHtml(_text)
        if o_step1_handler.is_vanadium_background_text_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step1_handler.is_vanadium_background_text_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step1_vanadium_background)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # table status
        _row = 2
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Empty?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_table_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_table_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # at least one row checked
        _row = 3
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Row Selected?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.at_least_one_row_checked():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(not o_step2_handler.at_least_one_row_checked())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # calibration
        _row = 4
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Calibration File Selected?<br/><b>Post Processing>Rietveld>Calibration</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_calibration_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_calibration_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_browse_calibration)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # characterization
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Characterization File Selected?<br/><b>Post Processing>Rietveld>Characterization</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_characterization_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_characterization_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_browse_characterization)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # number of bins int
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is Number of Bins an Int?<br/><b>Post Processing>Rietveld>Number of Bins</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_number_of_bins_no_int():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_number_of_bins_no_int())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_number_of_bins)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # min crop wavelegenth
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is min Crop Wavelength a float?<br/><b>Post Processing>Rietveld>Crop Wavelength Min</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_min_crop_wavelength_no_float():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_min_crop_wavelength_no_float())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_min_crop_wavelength)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # max crop wavelegenth
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is max Crop Wavelength a float?<br/><b>Post Processing>Rietveld>Crop Wavelength Max</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_max_crop_wavelength_no_float():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_max_crop_wavelength_no_float())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_max_crop_wavelength)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # vanadium radius
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is Vanadium Radius a float?<br/><b>Post Processing>Rietveld>Vanadium Radius</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_vanadium_radius_not_float():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_vanadium_radius_not_float())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_vanadium_radius)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)

        # output directory
        _row += 1
        self.parent.ui.table_status.insertRow(_row)
        self.parent.ui.table_status.setRowHeight(_row, self.row_height)
        _widget = QTextEdit()
        _text = "Is Output Directory Empty?<br/><b>Post Processing>Rietveld>Output Directory</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_mantid_output_directory_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(_row, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_mantid_output_directory_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_mantid_output_directory_button)
        self.parent.ui.table_status.setCellWidget(_row, 1, _widget_2)
コード例 #13
0
    def fill_ndabs(self):
        o_step2_handler = Step2Utilities(parent=self.parent.parent)

        # table status
        self.parent.ui.table_status.insertRow(0)
        self.parent.ui.table_status.setRowHeight(0, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Empty?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_table_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(0, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_table_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(0, 1, _widget_2)

        # at least one row checked
        self.parent.ui.table_status.insertRow(1)
        self.parent.ui.table_status.setRowHeight(1, self.row_height)
        _widget = QTextEdit()
        _text = "Main Table Row Selected?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.at_least_one_row_checked():
            _widget.setStyleSheet(self.widget_ok)
        else:
            _widget.setStyleSheet(self.widget_bad)
        self.parent.ui.table_status.setCellWidget(1, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(not o_step2_handler.at_least_one_row_checked())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(1, 1, _widget_2)

        # missing fields in row checked
        self.parent.ui.table_status.insertRow(2)
        self.parent.ui.table_status.setRowHeight(2, self.row_height)
        _widget = QTextEdit()
        _text = "Is missing metadata in row checked?<br/><b>Post Processing>Table</b>"
        _widget.setHtml(_text)
        if o_step2_handler.are_row_checked_have_missing_fields():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(2, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.are_row_checked_have_missing_fields())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_table)
        self.parent.ui.table_status.setCellWidget(2, 1, _widget_2)

        # fourier filter from
        self.parent.ui.table_status.insertRow(3)
        self.parent.ui.table_status.setRowHeight(3, self.row_height)
        _widget = QTextEdit()
        _text = "Is Fourier From Widgets Empty?<br/><b>Post Processing>Fourier Filter From</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_fourier_filter_from_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(3, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_fourier_filter_from_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_fourier_from)
        self.parent.ui.table_status.setCellWidget(3, 1, _widget_2)

        # fourier filter to
        self.parent.ui.table_status.insertRow(4)
        self.parent.ui.table_status.setRowHeight(4, self.row_height)
        _widget = QTextEdit()
        _text = "Is Fourier To Widgets Empty?<br/><b>Post Processing>Fourier Filter To</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_fourier_filter_to_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(4, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_fourier_filter_to_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_fourier_to)
        self.parent.ui.table_status.setCellWidget(4, 1, _widget_2)

        # plazcek filter from
        self.parent.ui.table_status.insertRow(5)
        self.parent.ui.table_status.setRowHeight(5, self.row_height)
        _widget = QTextEdit()
        _text = "Is Plazcek From Widgets Empty?<br/><b>Post Processing>Plazcek Filter From</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_plazcek_from_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(5, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_plazcek_from_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_plazcek_from)
        self.parent.ui.table_status.setCellWidget(5, 1, _widget_2)

        #  plazcek filter to
        self.parent.ui.table_status.insertRow(6)
        self.parent.ui.table_status.setRowHeight(6, self.row_height)
        _widget = QTextEdit()
        _text = "Is Plazcek To Widgets Empty?<br/><b>Post Processing>Plazcek Filter To</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_plazcek_to_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(6, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_plazcek_to_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_plazcek_to)
        self.parent.ui.table_status.setCellWidget(6, 1, _widget_2)

        # q min
        self.parent.ui.table_status.insertRow(7)
        self.parent.ui.table_status.setRowHeight(7, self.row_height)
        _widget = QTextEdit()
        _text = "Is Q min Widgets Empty?<br/><b>Post Processing>Q min</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_q_min_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(7, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_q_min_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_q_min)
        self.parent.ui.table_status.setCellWidget(7, 1, _widget_2)

        #  q max
        self.parent.ui.table_status.insertRow(8)
        self.parent.ui.table_status.setRowHeight(8, self.row_height)
        _widget = QTextEdit()
        _text = "Is Q max Widgets Empty?<br/><b>Post Processing>Q max</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_q_max_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(8, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_q_max_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_q_max)
        self.parent.ui.table_status.setCellWidget(8, 1, _widget_2)

        #  output file name
        self.parent.ui.table_status.insertRow(9)
        self.parent.ui.table_status.setRowHeight(9, self.row_height)
        _widget = QTextEdit()
        _text = "Is Output File Name Empty?<br/><b>Post Processing>Output File Name</b>"
        _widget.setHtml(_text)
        if o_step2_handler.is_ndabs_output_empty():
            _widget.setStyleSheet(self.widget_bad)
        else:
            _widget.setStyleSheet(self.widget_ok)
        self.parent.ui.table_status.setCellWidget(9, 0, _widget)
        _widget_2 = QPushButton()
        _widget_2.setEnabled(o_step2_handler.is_ndabs_output_empty())
        _widget_2.setText(self.jump_message)
        _widget_2.clicked.connect(self.jump_to_step2_output_empty)
        self.parent.ui.table_status.setCellWidget(9, 1, _widget_2)
コード例 #14
0
ファイル: NoteEditor.py プロジェクト: mwatts/UniqueBible
class NoteEditor(QMainWindow):

    def __init__(self, parent, noteType, noteFileName="", b=None, c=None, v=None):
        super().__init__()
        self.parent, self.noteType = parent, noteType
        self.noteFileName = noteFileName
        if not self.noteType == "file":
            if v:
                self.b, self.c, self.v = b, c, v
            else:
                self.b, self.c, self.v = config.studyB, config.studyC, config.studyV

        # default - "Rich" mode for editing
        self.html = True
        # default - text is not modified; no need for saving new content
        self.parent.noteSaved = True
        config.noteOpened = True
        config.lastOpenedNote = (noteType, b, c, v)

        # specify window size
        self.resizeWindow(2/3, 2/3)

        # setup interface
        self.setupMenuBar()
        self.addToolBarBreak()
        self.setupToolBar()
        if config.hideNoteEditorStyleToolbar:
            self.toolBar.hide()
        self.addToolBarBreak()
        self.setupTextUtility()
        if config.hideNoteEditorTextUtility:
            self.ttsToolbar.hide()
            self.translateToolbar.hide()
        self.setupLayout()

        # display content when first launched
        self.displayInitialContent()
        self.editor.setFocus()

        # specify window title
        self.updateWindowTitle()

    # re-implementing close event, when users close this widget
    def closeEvent(self, event):
        if self.parent.noteSaved:
            config.noteOpened = False
            event.accept()
            if config.lastOpenedNote and config.openBibleNoteAfterEditorClosed:
                #if config.lastOpenedNote[0] == "file":
                #    self.parent.externalFileButtonClicked()
                if config.lastOpenedNote[0] == "book":
                    self.parent.openStudyBookNote()
                elif config.lastOpenedNote[0] == "chapter":
                    self.parent.openStudyChapterNote()
                elif config.lastOpenedNote[0] == "verse":
                    self.parent.openStudyVerseNote()
        else:
            if self.parent.warningNotSaved():
                self.parent.noteSaved = True
                config.noteOpened = False
                event.accept()
            else:
                self.parent.bringToForeground(self)
                event.ignore()

    # re-implement keyPressEvent, control+S for saving file
    def keyPressEvent(self, event):
        keys = {
            Qt.Key_O: self.openFileDialog,
            Qt.Key_S: self.saveNote,
            Qt.Key_B: self.format_bold,
            Qt.Key_I: self.format_italic,
            Qt.Key_U: self.format_underline,
            Qt.Key_M: self.format_custom,
            Qt.Key_D: self.format_clear,
            Qt.Key_F: self.focusSearchField,
        }
        key = event.key()
        if event.modifiers() == Qt.ControlModifier and key in keys:
            keys[key]()

    # window appearance
    def resizeWindow(self, widthFactor, heightFactor):
        availableGeometry = QGuiApplication.instance().desktop().availableGeometry()
        self.resize(availableGeometry.width() * widthFactor, availableGeometry.height() * heightFactor)

    def updateWindowTitle(self):
        if self.noteType == "file":
            if self.noteFileName:
                *_, title = os.path.split(self.noteFileName)
            else:
                title = "NEW"
        else:
            title = self.parent.bcvToVerseReference(self.b, self.c, self.v)
            if self.noteType == "book":
                title, *_ = title.split(" ")            
            elif self.noteType == "chapter":
                title, *_ = title.split(":")
        mode = {True: "rich", False: "plain"}
        notModified = {True: "", False: " [modified]"}
        self.setWindowTitle("Note Editor ({1} mode) - {0}{2}".format(title, mode[self.html], notModified[self.parent.noteSaved]))

    # switching between "rich" & "plain" mode
    def switchMode(self):
        if self.html:
            note = self.editor.toHtml()
            note = re.sub("<body style={0}[ ]*?font-family:[ ]*?'[^']*?';[ ]*?font-size:[ ]*?[0-9]+?pt;".format('"'), "<body style={0}font-family:'{1}'; font-size:{2}pt;".format('"', config.font, config.fontSize), note)
            self.editor.setPlainText(note)
            self.html = False
            self.updateWindowTitle()
        else:
            note = self.editor.toPlainText()
            self.editor.setHtml(note)
            self.html = True
            self.updateWindowTitle()
        # without this hide / show command below, QTextEdit does not update the text in some devices
        self.hide()
        self.show()

    def setupMenuBar(self):
        if config.toolBarIconFullSize:
            self.setupMenuBarFullIconSize()
        else:
            self.setupMenuBarStandardIconSize()

    def setupMenuBarStandardIconSize(self):

        self.menuBar = QToolBar()
        self.menuBar.setWindowTitle(config.thisTranslation["note_title"])
        self.menuBar.setContextMenuPolicy(Qt.PreventContextMenu)
        # In QWidget, self.menuBar is treated as the menubar without the following line
        # In QMainWindow, the following line adds the configured QToolBar as part of the toolbar of the main window
        self.addToolBar(self.menuBar)

        newButton = QPushButton()
        newButton.setToolTip("{0}\n[Ctrl/Cmd + N]".format(config.thisTranslation["menu7_create"]))
        newButtonFile = os.path.join("htmlResources", "newfile.png")
        newButton.setIcon(QIcon(newButtonFile))
        newButton.clicked.connect(self.newNoteFile)
        self.menuBar.addWidget(newButton)

        openButton = QPushButton()
        openButton.setToolTip("{0}\n[Ctrl/Cmd + O]".format(config.thisTranslation["menu7_open"]))
        openButtonFile = os.path.join("htmlResources", "open.png")
        openButton.setIcon(QIcon(openButtonFile))
        openButton.clicked.connect(self.openFileDialog)
        self.menuBar.addWidget(openButton)

        self.menuBar.addSeparator()

        saveButton = QPushButton()
        saveButton.setToolTip("{0}\n[Ctrl/Cmd + S]".format(config.thisTranslation["note_save"]))
        saveButtonFile = os.path.join("htmlResources", "save.png")
        saveButton.setIcon(QIcon(saveButtonFile))
        saveButton.clicked.connect(self.saveNote)
        self.menuBar.addWidget(saveButton)

        saveAsButton = QPushButton()
        saveAsButton.setToolTip(config.thisTranslation["note_saveAs"])
        saveAsButtonFile = os.path.join("htmlResources", "saveas.png")
        saveAsButton.setIcon(QIcon(saveAsButtonFile))
        saveAsButton.clicked.connect(self.openSaveAsDialog)
        self.menuBar.addWidget(saveAsButton)

        self.menuBar.addSeparator()

        toolBarButton = QPushButton()
        toolBarButton.setToolTip(config.thisTranslation["note_print"])
        toolBarButtonFile = os.path.join("htmlResources", "print.png")
        toolBarButton.setIcon(QIcon(toolBarButtonFile))
        toolBarButton.clicked.connect(self.printNote)
        self.menuBar.addWidget(toolBarButton)

        self.menuBar.addSeparator()

        switchButton = QPushButton()
        switchButton.setToolTip(config.thisTranslation["note_mode"])
        switchButtonFile = os.path.join("htmlResources", "switch.png")
        switchButton.setIcon(QIcon(switchButtonFile))
        switchButton.clicked.connect(self.switchMode)
        self.menuBar.addWidget(switchButton)

        self.menuBar.addSeparator()

#        decreaseFontSizeButton = QPushButton()
#        decreaseFontSizeButton.setToolTip(config.thisTranslation["menu2_smaller"])
#        decreaseFontSizeButtonFile = os.path.join("htmlResources", "fontMinus.png")
#        decreaseFontSizeButton.setIcon(QIcon(decreaseFontSizeButtonFile))
#        decreaseFontSizeButton.clicked.connect(self.decreaseNoteEditorFontSize)
#        self.menuBar.addWidget(decreaseFontSizeButton)
#
#        increaseFontSizeButton = QPushButton()
#        increaseFontSizeButton.setToolTip(config.thisTranslation["menu2_larger"])
#        increaseFontSizeButtonFile = os.path.join("htmlResources", "fontPlus.png")
#        increaseFontSizeButton.setIcon(QIcon(increaseFontSizeButtonFile))
#        increaseFontSizeButton.clicked.connect(self.increaseNoteEditorFontSize)
#        self.menuBar.addWidget(increaseFontSizeButton)

#        self.menuBar.addSeparator()

        self.searchLineEdit = QLineEdit()
        self.searchLineEdit.setClearButtonEnabled(True)
        self.searchLineEdit.setToolTip(config.thisTranslation["menu5_search"])
        self.searchLineEdit.setMaximumWidth(400)
        self.searchLineEdit.returnPressed.connect(self.searchLineEntered)
        self.menuBar.addWidget(self.searchLineEdit)

        self.menuBar.addSeparator()

        toolBarButton = QPushButton()
        toolBarButton.setToolTip(config.thisTranslation["note_toolbar"])
        toolBarButtonFile = os.path.join("htmlResources", "toolbar.png")
        toolBarButton.setIcon(QIcon(toolBarButtonFile))
        toolBarButton.clicked.connect(self.toggleToolbar)
        self.menuBar.addWidget(toolBarButton)

        toolBarButton = QPushButton()
        toolBarButton.setToolTip(config.thisTranslation["note_textUtility"])
        toolBarButtonFile = os.path.join("htmlResources", "textUtility.png")
        toolBarButton.setIcon(QIcon(toolBarButtonFile))
        toolBarButton.clicked.connect(self.toggleTextUtility)
        self.menuBar.addWidget(toolBarButton)

        self.menuBar.addSeparator()

    def setupMenuBarFullIconSize(self):

        self.menuBar = QToolBar()
        self.menuBar.setWindowTitle(config.thisTranslation["note_title"])
        self.menuBar.setContextMenuPolicy(Qt.PreventContextMenu)
        # In QWidget, self.menuBar is treated as the menubar without the following line
        # In QMainWindow, the following line adds the configured QToolBar as part of the toolbar of the main window
        self.addToolBar(self.menuBar)

        iconFile = os.path.join("htmlResources", "newfile.png")
        self.menuBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + N]".format(config.thisTranslation["menu7_create"]), self.newNoteFile)

        iconFile = os.path.join("htmlResources", "open.png")
        self.menuBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + O]".format(config.thisTranslation["menu7_open"]), self.openFileDialog)

        self.menuBar.addSeparator()

        iconFile = os.path.join("htmlResources", "save.png")
        self.menuBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + S]".format(config.thisTranslation["note_save"]), self.saveNote)

        iconFile = os.path.join("htmlResources", "saveas.png")
        self.menuBar.addAction(QIcon(iconFile), config.thisTranslation["note_saveAs"], self.openSaveAsDialog)

        self.menuBar.addSeparator()

        iconFile = os.path.join("htmlResources", "print.png")
        self.menuBar.addAction(QIcon(iconFile), config.thisTranslation["note_print"], self.printNote)

        self.menuBar.addSeparator()

        iconFile = os.path.join("htmlResources", "switch.png")
        self.menuBar.addAction(QIcon(iconFile), config.thisTranslation["note_mode"], self.switchMode)

        self.menuBar.addSeparator()

#        iconFile = os.path.join("htmlResources", "fontMinus.png")
#        self.menuBar.addAction(QIcon(iconFile), config.thisTranslation["menu2_smaller"], self.decreaseNoteEditorFontSize)
#
#        iconFile = os.path.join("htmlResources", "fontPlus.png")
#        self.menuBar.addAction(QIcon(iconFile), config.thisTranslation["menu2_larger"], self.increaseNoteEditorFontSize)

#        self.menuBar.addSeparator()

        self.searchLineEdit = QLineEdit()
        self.searchLineEdit.setToolTip("{0}\n[Ctrl/Cmd + F]".format(config.thisTranslation["menu5_search"]))
        self.searchLineEdit.setMaximumWidth(400)
        self.searchLineEdit.returnPressed.connect(self.searchLineEntered)
        self.menuBar.addWidget(self.searchLineEdit)

        self.menuBar.addSeparator()

        iconFile = os.path.join("htmlResources", "toolbar.png")
        self.menuBar.addAction(QIcon(iconFile), config.thisTranslation["note_toolbar"], self.toggleToolbar)

        iconFile = os.path.join("htmlResources", "textUtility.png")
        self.menuBar.addAction(QIcon(iconFile), config.thisTranslation["note_textUtility"], self.toggleTextUtility)

        self.menuBar.addSeparator()

    def toggleToolbar(self):
        if config.hideNoteEditorStyleToolbar:
            self.toolBar.show()
            config.hideNoteEditorStyleToolbar = False
        else:
            self.toolBar.hide()
            config.hideNoteEditorStyleToolbar = True

    def toggleTextUtility(self):
        if config.hideNoteEditorTextUtility:
            self.ttsToolbar.show()
            self.translateToolbar.show()
            config.hideNoteEditorTextUtility = False
        else:
            self.ttsToolbar.hide()
            self.translateToolbar.hide()
            config.hideNoteEditorTextUtility = True

    def printNote(self):
        #document = QTextDocument("Sample Page")
        document = self.editor.document()
        printer = QPrinter()

        myPrintDialog = QPrintDialog(printer, self)
        if myPrintDialog.exec_() == QDialog.Accepted:
            return document.print_(printer)

    def setupToolBar(self):
        if config.toolBarIconFullSize:
            self.setupToolBarFullIconSize()
        else:
            self.setupToolBarStandardIconSize()

    def setupToolBarStandardIconSize(self):

        self.toolBar = QToolBar()
        self.toolBar.setWindowTitle(config.thisTranslation["noteTool_title"])
        self.toolBar.setContextMenuPolicy(Qt.PreventContextMenu)
        # self.toolBar can be treated as an individual widget and positioned with a specified layout
        # In QMainWindow, the following line adds the configured QToolBar as part of the toolbar of the main window
        self.addToolBar(self.toolBar)
        
        items = (
            ("noteTool_textFont", "font.png", self.format_font),
            ("noteTool_textColor", "textColor.png", self.format_textColor),
            ("noteTool_textBackgroundColor", "textBgColor.png", self.format_textBackgroundColor),
        )
        for item in items:
            toolTip, icon, action = item
            self.parent.addStandardIconButton(toolTip, icon, action, self.toolBar)

        self.toolBar.addSeparator()

        items = (
            ("noteTool_header1", "header1.png", self.format_header1),
            ("noteTool_header2", "header2.png", self.format_header2),
            ("noteTool_header3", "header3.png", self.format_header3),
        )
        for item in items:
            toolTip, icon, action = item
            self.parent.addStandardIconButton(toolTip, icon, action, self.toolBar)

        self.toolBar.addSeparator()
        
        items = (
            ("{0}\n[Ctrl/Cmd + B]".format(config.thisTranslation["noteTool_bold"]), "bold.png", self.format_bold),
            ("{0}\n[Ctrl/Cmd + I]".format(config.thisTranslation["noteTool_italic"]), "italic.png", self.format_italic),
            ("{0}\n[Ctrl/Cmd + U]".format(config.thisTranslation["noteTool_underline"]), "underline.png", self.format_underline),
        )
        for item in items:
            toolTip, icon, action = item
            self.parent.addStandardIconButton(toolTip, icon, action, self.toolBar, translation=False)

        self.toolBar.addSeparator()

        items = (
            ("noteTool_superscript", "superscript.png", self.format_superscript),
            ("noteTool_subscript", "subscript.png", self.format_subscript),
        )
        for item in items:
            toolTip, icon, action = item
            self.parent.addStandardIconButton(toolTip, icon, action, self.toolBar)

        self.toolBar.addSeparator()

        self.parent.addStandardIconButton("{0}\n[Ctrl/Cmd + M]\n\n{1}\n* {4}\n* {5}\n* {6}\n\n{2}\n*1 {4}\n*2 {5}\n*3 {6}\n\n{3}\n{10}{4}|{5}|{6}{11}\n{10}{7}|{8}|{9}{11}".format(config.thisTranslation["noteTool_trans0"], config.thisTranslation["noteTool_trans1"], config.thisTranslation["noteTool_trans2"], config.thisTranslation["noteTool_trans3"], config.thisTranslation["noteTool_no1"], config.thisTranslation["noteTool_no2"], config.thisTranslation["noteTool_no3"], config.thisTranslation["noteTool_no4"], config.thisTranslation["noteTool_no5"], config.thisTranslation["noteTool_no6"], "{", "}"), "custom.png", self.format_custom, self.toolBar, translation=False)

        self.toolBar.addSeparator()

        items = (
            ("noteTool_left", "align_left.png", self.format_left),
            ("noteTool_centre", "align_center.png", self.format_center),
            ("noteTool_right", "align_right.png", self.format_right),
            ("noteTool_justify", "align_justify.png", self.format_justify),
        )
        for item in items:
            toolTip, icon, action = item
            self.parent.addStandardIconButton(toolTip, icon, action, self.toolBar)

        self.toolBar.addSeparator()

        self.parent.addStandardIconButton("{0}\n[Ctrl/Cmd + D]".format(config.thisTranslation["noteTool_delete"]), "clearFormat.png", self.format_clear, self.toolBar, translation=False)

        self.toolBar.addSeparator()

        items = (
            ("noteTool_hyperlink", "hyperlink.png", self.openHyperlinkDialog),
            ("noteTool_externalImage", "gallery.png", self.openImageDialog),
        )
        for item in items:
            toolTip, icon, action = item
            self.parent.addStandardIconButton(toolTip, icon, action, self.toolBar)

        self.toolBar.addSeparator()

        items = (
            ("noteTool_image", "addImage.png", self.addInternalImage),
            ("noteTool_exportImage", "export.png", self.exportNoteImages),
        )
        for item in items:
            toolTip, icon, action = item
            self.parent.addStandardIconButton(toolTip, icon, action, self.toolBar)

        self.toolBar.addSeparator()

    def setupToolBarFullIconSize(self):

        self.toolBar = QToolBar()
        self.toolBar.setWindowTitle(config.thisTranslation["noteTool_title"])
        self.toolBar.setContextMenuPolicy(Qt.PreventContextMenu)
        # self.toolBar can be treated as an individual widget and positioned with a specified layout
        # In QMainWindow, the following line adds the configured QToolBar as part of the toolbar of the main window
        self.addToolBar(self.toolBar)

        iconFile = os.path.join("htmlResources", "font.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_textFont"], self.format_font)

        iconFile = os.path.join("htmlResources", "textColor.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_textColor"], self.format_textColor)

        iconFile = os.path.join("htmlResources", "textBgColor.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_textBackgroundColor"], self.format_textBackgroundColor)

        self.toolBar.addSeparator()

        iconFile = os.path.join("htmlResources", "header1.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_header1"], self.format_header1)

        iconFile = os.path.join("htmlResources", "header2.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_header2"], self.format_header2)

        iconFile = os.path.join("htmlResources", "header3.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_header3"], self.format_header3)

        self.toolBar.addSeparator()

        iconFile = os.path.join("htmlResources", "bold.png")
        self.toolBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + B]".format(config.thisTranslation["noteTool_bold"]), self.format_bold)

        iconFile = os.path.join("htmlResources", "italic.png")
        self.toolBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + I]".format(config.thisTranslation["noteTool_italic"]), self.format_italic)

        iconFile = os.path.join("htmlResources", "underline.png")
        self.toolBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + U]".format(config.thisTranslation["noteTool_underline"]), self.format_underline)

        self.toolBar.addSeparator()

        iconFile = os.path.join("htmlResources", "custom.png")
        self.toolBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + M]\n\n{1}\n* {4}\n* {5}\n* {6}\n\n{2}\n*1 {4}\n*2 {5}\n*3 {6}\n\n{3}\n{10}{4}|{5}|{6}{11}\n{10}{7}|{8}|{9}{11}".format(config.thisTranslation["noteTool_trans0"], config.thisTranslation["noteTool_trans1"], config.thisTranslation["noteTool_trans2"], config.thisTranslation["noteTool_trans3"], config.thisTranslation["noteTool_no1"], config.thisTranslation["noteTool_no2"], config.thisTranslation["noteTool_no3"], config.thisTranslation["noteTool_no4"], config.thisTranslation["noteTool_no5"], config.thisTranslation["noteTool_no6"], "{", "}"), self.format_custom)

        self.toolBar.addSeparator()

        iconFile = os.path.join("htmlResources", "align_left.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_left"], self.format_left)

        iconFile = os.path.join("htmlResources", "align_center.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_centre"], self.format_center)

        iconFile = os.path.join("htmlResources", "align_right.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_right"], self.format_right)

        iconFile = os.path.join("htmlResources", "align_justify.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_justify"], self.format_justify)

        self.toolBar.addSeparator()

        iconFile = os.path.join("htmlResources", "clearFormat.png")
        self.toolBar.addAction(QIcon(iconFile), "{0}\n[Ctrl/Cmd + D]".format(config.thisTranslation["noteTool_delete"]), self.format_clear)

        self.toolBar.addSeparator()

        iconFile = os.path.join("htmlResources", "hyperlink.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_hyperlink"], self.openHyperlinkDialog)

        iconFile = os.path.join("htmlResources", "gallery.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_externalImage"], self.openImageDialog)

        self.toolBar.addSeparator()

        iconFile = os.path.join("htmlResources", "addImage.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_image"], self.addInternalImage)

        iconFile = os.path.join("htmlResources", "export.png")
        self.toolBar.addAction(QIcon(iconFile), config.thisTranslation["noteTool_exportImage"], self.exportNoteImages)

        self.toolBar.addSeparator()

    def setupLayout(self):
        self.editor = QTextEdit()  
        self.editor.setStyleSheet("font-family:'{0}'; font-size:{1}pt;".format(config.font, config.fontSize));
        self.editor.textChanged.connect(self.textChanged)
        self.setCentralWidget(self.editor)

        #self.layout = QGridLayout()
        #self.layout.setMenuBar(self.menuBar)
        #self.layout.addWidget(self.toolBar, 0, 0)
        #self.layout.addWidget(self.editor, 1, 0)
        #self.setLayout(self.layout)

    # adjustment of note editor font size
    def increaseNoteEditorFontSize(self):
        if self.html:
            self.editor.selectAll()
            config.noteEditorFontSize += 1
            self.editor.setFontPointSize(config.noteEditorFontSize)
            self.hide()
            self.show()

    def decreaseNoteEditorFontSize(self):
        if self.html and not config.noteEditorFontSize == 0:
            self.editor.selectAll()
            config.noteEditorFontSize -= 1
            self.editor.setFontPointSize(config.noteEditorFontSize)
            self.hide()
            self.show()

    # search field entered
    def searchLineEntered(self):
        searchString = self.searchLineEdit.text()
        if searchString:
            cursor = self.editor.document().find(searchString, self.editor.textCursor())
        if cursor:
            self.editor.setTextCursor(cursor)
        self.hide()
        self.show()

    def focusSearchField(self):
        self.searchLineEdit.setFocus()

    # track if the text being modified
    def textChanged(self):
        if self.parent.noteSaved:
            self.parent.noteSaved = False
            self.updateWindowTitle()

    # display content when first launched
    def displayInitialContent(self):
        if self.noteType == "file":
            if self.noteFileName:
                self.openNoteFile(self.noteFileName)
            else:
                self.newNoteFile()
        else:
            self.openBibleNote()

        self.editor.selectAll()
        self.editor.setFontPointSize(config.noteEditorFontSize)
        self.editor.moveCursor(QTextCursor.Start, QTextCursor.MoveAnchor)

        self.parent.noteSaved = True

    def getEmptyPage(self):
        strict = ''
        if config.includeStrictDocTypeInNote:
            strict = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">'
        return """{4}<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li {0} white-space: pre-wrap; {1}
</style></head><body style="font-family:'{2}'; font-size:{3}pt; font-weight:400; font-style:normal;">
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>"""\
            .format("{", "}", config.font, config.fontSize, strict)

    # load chapter / verse notes from sqlite database
    def openBibleNote(self):
        if self.noteType == "book":
            note = NoteService.getBookNote(self.b)
        elif self.noteType == "chapter":
            note = NoteService.getChapterNote(self.b, self.c)
        elif self.noteType == "verse":
            note = NoteService.getVerseNote(self.b, self.c, self.v)
        if note == config.thisTranslation["empty"]:
            note = self.getEmptyPage()
        else:
            note = self.fixNoteFont(note)
        if self.html:
            self.editor.setHtml(note)
        else:
            self.editor.setPlainText(note)

    # File I / O
    def newNoteFile(self):
        if self.parent.noteSaved:
            self.newNoteFileAction()
        elif self.parent.warningNotSaved():
            self.newNoteFileAction()

    def newNoteFileAction(self):
        self.noteType = "file"
        self.noteFileName = ""
        #self.editor.clear()
        defaultText = self.getEmptyPage()
        if self.html:
            self.editor.setHtml(defaultText)
        else:
            self.editor.setPlainText(defaultText)
        self.parent.noteSaved = True
        self.updateWindowTitle()
        self.hide()
        self.show()

    def openFileDialog(self):
        if self.parent.noteSaved:
            self.openFileDialogAction()
        elif self.parent.warningNotSaved():
            self.openFileDialogAction()

    def openFileDialogAction(self):
        options = QFileDialog.Options()
        fileName, filtr = QFileDialog.getOpenFileName(self,
                config.thisTranslation["menu7_open"],
                "notes",
                "UniqueBible.app Note Files (*.uba);;HTML Files (*.html);;HTM Files (*.htm);;All Files (*)", "", options)
        if fileName:
            self.openNoteFile(fileName)

    def openNoteFile(self, fileName):
        try:
            f = open(fileName, "r", encoding="utf-8")
        except:
            print("Failed to open '{0}'".format(fileName))
        note = f.read()
        f.close()
        self.noteType = "file"
        self.noteFileName = fileName
        note = self.fixNoteFont(note)
        if self.html:
            self.editor.setHtml(note)
        else:
            self.editor.setPlainText(note)
        self.parent.noteSaved = True
        self.updateWindowTitle()
        self.hide()
        self.show()

    def saveNote(self):
        if self.html:
            note = self.editor.toHtml()
        else:
            note = self.editor.toPlainText()
        note = self.fixNoteFont(note)
        if self.noteType == "book":
            NoteService.saveBookNote(self.b, note)
            if config.openBibleNoteAfterSave:
                self.parent.openBookNote(self.b,)
            self.parent.noteSaved = True
            self.updateWindowTitle()
        elif self.noteType == "chapter":
            NoteService.saveChapterNote(self.b, self.c, note)
            if config.openBibleNoteAfterSave:
                self.parent.openChapterNote(self.b, self.c)
            self.parent.noteSaved = True
            self.updateWindowTitle()
        elif self.noteType == "verse":
            NoteService.saveVerseNote(self.b, self.c, self.v, note)
            if config.openBibleNoteAfterSave:
                self.parent.openVerseNote(self.b, self.c, self.v)
            self.parent.noteSaved = True
            self.updateWindowTitle()
        elif self.noteType == "file":
            if self.noteFileName == "":
                self.openSaveAsDialog()
            else:
                self.saveAsNote(self.noteFileName)

    def openSaveAsDialog(self):
        if self.noteFileName:
            *_, defaultName = os.path.split(self.noteFileName)
        else:
            defaultName = "new.uba"
        options = QFileDialog.Options()
        fileName, filtr = QFileDialog.getSaveFileName(self,
                config.thisTranslation["note_saveAs"],
                os.path.join("notes", defaultName),
                "UniqueBible.app Note Files (*.uba);;HTML Files (*.html);;HTM Files (*.htm);;All Files (*)", "", options)
        if fileName:
            if not "." in os.path.basename(fileName):
                fileName = fileName + ".uba"
            self.saveAsNote(fileName)

    def saveAsNote(self, fileName):
        if self.html:
            note = self.editor.toHtml()
        else:
            note = self.editor.toPlainText()
        note = self.fixNoteFont(note)
        f = open(fileName, "w", encoding="utf-8")
        f.write(note)
        f.close()
        self.noteFileName = fileName
        self.parent.addExternalFileHistory(fileName)
        self.parent.setExternalFileButton()
        self.parent.noteSaved = True
        self.updateWindowTitle()

    def fixNoteFont(self, note):
        note = re.sub("<body style={0}[ ]*?font-family:[ ]*?'[^']*?';[ ]*?font-size:[ ]*?[0-9]+?pt;".format('"'), "<body style={0}font-family:'{1}'; font-size:{2}pt;".format('"', config.font, config.fontSize), note)
        if not config.includeStrictDocTypeInNote:
            note = re.sub("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">\n""", "", note)
        return note


    # formatting styles
    def format_clear(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                selectedText = """<span style="font-family:'{0}'; font-size:{1}pt;">{2}</span>""".format(config.font, config.fontSize, selectedText)
                self.editor.insertHtml(selectedText)
            else:
                selectedText = re.sub("<[^\n<>]*?>", "", selectedText)
                self.editor.insertPlainText(selectedText)
        else:
            self.selectTextFirst()

    def format_header1(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.insertHtml("<h1>{0}</h1>".format(selectedText))
            else:
                self.editor.insertPlainText("<h1>{0}</h1>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_header2(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.insertHtml("<h2>{0}</h2>".format(selectedText))
            else:
                self.editor.insertPlainText("<h2>{0}</h2>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_header3(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.insertHtml("<h3>{0}</h3>".format(selectedText))
            else:
                self.editor.insertPlainText("<h3>{0}</h3>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_font(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            ok, font = QFontDialog.getFont(QFont(config.font, config.fontSize), self)
            if ok:
                if self.html:
                    self.editor.setCurrentFont(font)
                else:
                    fontFamily, fontSize, i1, i2, fontWeight, italic, underline, strikeout, *_ = font.key().split(",")
                    spanTag = """<span style="font-family:'{0}'; font-size:{1}pt;""".format(fontFamily, fontSize)
                    # add font weight
                    if fontWeight == "25":
                        spanTag += " font-weight:200;"
                    elif fontWeight == "75":
                        spanTag += " font-weight:600;"
                    # add italic style
                    if italic == "1":
                        spanTag += " font-style:italic;"
                    # add both underline and strikeout style
                    if underline == "1" and strikeout == "1":
                        spanTag += " text-decoration: underline line-through;"
                    # add underline style
                    elif underline == "1":
                        spanTag += " text-decoration: underline;"
                    # add strikeout style
                    elif strikeout == "1":
                        spanTag += " text-decoration: line-through;"
                    # close tag
                    spanTag += '">'
                    self.editor.insertPlainText("{0}{1}</span>".format(spanTag, selectedText))
        else:
            self.selectTextFirst()
        
    def format_textColor(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            color = QColorDialog.getColor(Qt.darkRed, self)
            if color.isValid():
                if self.html:
                    self.editor.setTextColor(color)
                else:
                    self.editor.insertPlainText('<span style="color:{0};">{1}</span>'.format(color.name(), self.editor.textCursor().selectedText()))
        else:
            self.selectTextFirst()

    def format_textBackgroundColor(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            color = QColorDialog.getColor(Qt.yellow, self)
            if color.isValid():
                if self.html:
                    self.editor.setTextBackgroundColor(color)
                else:
                    self.editor.insertPlainText('<span style="background-color:{0};">{1}</span>'.format(color.name(), selectedText))
        else:
            self.selectTextFirst()

    def format_bold(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                # Reference: https://doc.qt.io/qt-5/qfont.html#Weight-enum
                # Bold = 75
                self.editor.setFontWeight(75)
            else:
                self.editor.insertPlainText("<b>{0}</b>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_italic(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.setFontItalic(True)
            else:
                self.editor.insertPlainText("<i>{0}</i>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_underline(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.setFontUnderline(True)
            else:
                self.editor.insertPlainText("<u>{0}</u>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_superscript(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.insertHtml("<sup>{0}</sup>".format(selectedText))
            else:
                self.editor.insertPlainText("<sup>{0}</sup>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_subscript(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.insertHtml("<sub>{0}</sub>".format(selectedText))
            else:
                self.editor.insertPlainText("<sub>{0}</sub>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_center(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.setAlignment(Qt.AlignCenter)
            else:
                self.editor.insertPlainText("<div style='text-align:center;'>{0}</div>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_justify(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.setAlignment(Qt.AlignJustify)
            else:
                self.editor.insertPlainText("<div style='text-align:justify;'>{0}</div>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_left(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.setAlignment(Qt.AlignLeft)
            else:
                self.editor.insertPlainText("<div style='text-align:left;'>{0}</div>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_right(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            if self.html:
                self.editor.setAlignment(Qt.AlignRight)
            else:
                self.editor.insertPlainText("<div style='text-align:right;'>{0}</div>".format(selectedText))
        else:
            self.selectTextFirst()

    def format_custom(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            selectedText = self.customFormat(selectedText)
            if self.html:
                self.editor.insertHtml(selectedText)
            else:
                self.editor.insertPlainText(selectedText)
        else:
            self.selectTextFirst()

    def customFormat(self, text):
        # QTextEdit's line break character by pressing ENTER in plain & html mode "
"
        # please note that "
" is not an empty string
        text = text.replace("
", "\n")

        text = re.sub("^\*[0-9]+? (.*?)$", r"<ol><li>\1</li></ol>", text, flags=re.M)
        text = text.replace("</ol>\n<ol>", "\n")
        text = re.sub("^\* (.*?)$", r"<ul><li>\1</li></ul>", text, flags=re.M)
        text = text.replace("</ul>\n<ul>", "\n")
        text = re.sub("^{.*?}$", self.formatHTMLTable, text, flags=re.M)
        text = text.replace("</table>\n<table>", "\n")

        # add style to table here
        # please note that QTextEdit supports HTML 4, rather than HTML 5
        # take this old reference: https://www.w3schools.com/tags/tag_table.asp
        text = text.replace('<table>', '<table border="1" cellpadding="5">')

        # convert back to QTextEdit linebreak
        text = text.replace("\n", "
")

        # wrap with default font and font-size
        text = """<span style="font-family:'{0}'; font-size:{1}pt;">{2}</span>""".format(config.font, config.fontSize, text)
        return text

    def formatHTMLTable(self, match):
        row = match.group()[1:-1]
        row = "".join(["<td>{0}</td>".format(cell) for cell in row.split("|")])
        return "<table><tr>{0}</tr></table>".format(row)

    def addInternalImage(self):
        self.openImageDialog(external=False)

    def openImageDialog(self, external=True):
        options = QFileDialog.Options()
        fileName, filtr = QFileDialog.getOpenFileName(self,
                config.thisTranslation["html_open"],
                self.parent.openFileNameLabel.text(),
                "JPG Files (*.jpg);;JPEG Files (*.jpeg);;PNG Files (*.png);;GIF Files (*.gif);;BMP Files (*.bmp);;All Files (*)", "", options)
        if fileName:
            if external:
                self.linkExternalImage(fileName)
            else:
                self.embedImage(fileName)

    def embedImage(self, fileName):
        name, extension = os.path.splitext(os.path.basename(fileName))
        with open(fileName, "rb") as fileObject:
            binaryData = fileObject.read()
            encodedData = base64.b64encode(binaryData)
            asciiString = encodedData.decode('ascii')
            imageTag = '<img src="data:image/{2};base64,{0}" alt="{1}">'.format(asciiString, name, extension[1:])
            if self.html:
                self.editor.insertHtml(imageTag)
            else:
                self.editor.insertPlainText(imageTag)

    def exportNoteImages(self):
        options = QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly
        directory = QFileDialog.getExistingDirectory(self,
                config.thisTranslation["select_a_folder"],
                self.parent.directoryLabel.text(), options)
        if directory:
            if self.html:
                htmlText = self.editor.toHtml()
            else:
                htmlText = self.editor.toPlainText()
            searchPattern = r'src=(["{0}])data:image/([^<>]+?);[ ]*?base64,[ ]*?([^ <>]+?)\1'.format("'")
            for counter, value in enumerate(re.findall(searchPattern, htmlText)):
                *_, ext, asciiString = value
                binaryString = asciiString.encode("ascii")
                binaryData = base64.b64decode(binaryString)
                imageFilePath = os.path.join(directory, "image{0}.{1}".format(counter + 1, ext))
                with open(imageFilePath, "wb") as fileObject:
                    fileObject.write(binaryData)

    def linkExternalImage(self, fileName):
        imageTag = '<img src="{0}" alt="UniqueBible.app">'.format(fileName)
        if self.html:
            self.editor.insertHtml(imageTag)
        else:
            self.editor.insertPlainText(imageTag)

    def openHyperlinkDialog(self):
        selectedText = self.editor.textCursor().selectedText()
        if selectedText:
            text, ok = QInputDialog.getText(self, "UniqueBible.app",
                    config.thisTranslation["noteTool_hyperlink"], QLineEdit.Normal,
                    selectedText)
            if ok and text != '':
                hyperlink = '<a href="{0}">{1}</a>'.format(text, selectedText)
                hyperlink = """<span style="font-family:'{0}'; font-size:{1}pt;">{2}</span>""".format(config.font, config.fontSize, hyperlink)
                if self.html:
                    self.editor.insertHtml(hyperlink)
                else:
                    self.editor.insertPlainText(hyperlink)
        else:
            self.selectTextFirst()

    def setupTextUtility(self):

        self.ttsToolbar = QToolBar()
        self.ttsToolbar.setWindowTitle(config.thisTranslation["noteTool_title"])
        self.ttsToolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        # self.toolBar can be treated as an individual widget and positioned with a specified layout
        # In QMainWindow, the following line adds the configured QToolBar as part of the toolbar of the main window
        self.addToolBar(self.ttsToolbar)

        self.languageCombo = QComboBox()
        self.ttsToolbar.addWidget(self.languageCombo)
        if config.espeak:
            languages = TtsLanguages().isoLang2epeakLang
        else:
            languages = TtsLanguages().isoLang2qlocaleLang
        self.languageCodes = list(languages.keys())
        for code in self.languageCodes:
            self.languageCombo.addItem(languages[code][1])
        # Check if selected tts engine has the language user specify.
        if not (config.ttsDefaultLangauge in self.languageCodes):
            config.ttsDefaultLangauge = "en"
        # Set initial item
        initialIndex = self.languageCodes.index(config.ttsDefaultLangauge)
        self.languageCombo.setCurrentIndex(initialIndex)

        button = QPushButton(config.thisTranslation["speak"])
        button.setToolTip(config.thisTranslation["speak"])
        button.clicked.connect(self.speakText)
        self.ttsToolbar.addWidget(button)
        button = QPushButton(config.thisTranslation["stop"])
        button.setToolTip(config.thisTranslation["stop"])
        button.clicked.connect(self.parent.textCommandParser.stopTtsAudio)
        self.ttsToolbar.addWidget(button)

        self.translateToolbar = QToolBar()
        self.translateToolbar.setWindowTitle(config.thisTranslation["noteTool_title"])
        self.translateToolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        # self.toolBar can be treated as an individual widget and positioned with a specified layout
        # In QMainWindow, the following line adds the configured QToolBar as part of the toolbar of the main window
        self.addToolBar(self.translateToolbar)

        self.fromLanguageCombo = QComboBox()
        self.translateToolbar.addWidget(self.fromLanguageCombo)
        self.fromLanguageCombo.addItems(["[Auto]"] +Translator.fromLanguageNames)
        initialIndex = 0
        self.fromLanguageCombo.setCurrentIndex(initialIndex)

        button = QPushButton(config.thisTranslation["context1_translate"])
        button.setToolTip(config.thisTranslation["context1_translate"])
        button.clicked.connect(self.translateText)
        self.translateToolbar.addWidget(button)

        self.toLanguageCombo = QComboBox()
        self.translateToolbar.addWidget(self.toLanguageCombo)
        self.toLanguageCombo.addItems(Translator.toLanguageNames)
        initialIndex = Translator.toLanguageNames.index(config.userLanguage)
        self.toLanguageCombo.setCurrentIndex(initialIndex)

    def speakText(self):
        text = self.editor.textCursor().selectedText()
        if text:
            if config.isTtsInstalled:
                if ":::" in text:
                    text = text.split(":::")[-1]
                command = "SPEAK:::{0}:::{1}".format(self.languageCodes[self.languageCombo.currentIndex()], text)
                self.parent.runTextCommand(command)
            else:
                self.displayMessage(config.thisTranslation["message_noSupport"])
        else:
            self.selectTextFirst()

    def translateText(self):
        text = self.editor.textCursor().selectedText()
        if text:
            translator = Translator()
            if translator.language_translator is not None:
                fromLanguage = Translator.fromLanguageCodes[self.fromLanguageCombo.currentIndex() - 1] if self.fromLanguageCombo.currentIndex() != 0 else translator.identify(text)
                toLanguage = Translator.toLanguageCodes[self.toLanguageCombo.currentIndex()]
                result = translator.translate(text, fromLanguage, toLanguage)
                self.editor.insertPlainText(result)
            else:
                self.displayMessage(config.thisTranslation["ibmWatsonNotEnalbed"])
                webbrowser.open("https://github.com/eliranwong/UniqueBible/wiki/IBM-Watson-Language-Translator")
        else:
            self.selectTextFirst()

    def selectTextFirst(self):
        self.displayMessage(config.thisTranslation["selectTextFirst"])

    def displayMessage(self, message="", title="UniqueBible"):
        reply = QMessageBox.information(self, title, message)
コード例 #15
0
class QtAboutKeybindings(QDialog):

    ALL_ACTIVE_KEYBINDINGS = 'All active keybindings'

    def __init__(self, viewer):
        super().__init__()

        self.viewer = viewer
        self.layout = QVBoxLayout()

        self.setWindowTitle('Keybindings')
        self.setWindowModality(Qt.NonModal)
        self.setLayout(self.layout)

        # stacked keybindings widgets
        self.textEditBox = QTextEdit()
        self.textEditBox.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.textEditBox.setMinimumWidth(360)
        # Can switch to a normal dict when our minimum Python is 3.7
        self.keybindings_strs = OrderedDict()
        self.keybindings_strs[self.ALL_ACTIVE_KEYBINDINGS] = ''
        col = self.viewer.palette['secondary']
        layers = [
            napari.layers.Image,
            napari.layers.Labels,
            napari.layers.Points,
            napari.layers.Shapes,
            napari.layers.Surface,
            napari.layers.Vectors,
        ]
        for layer in layers:
            if len(layer.class_keymap) == 0:
                text = 'No keybindings'
            else:
                text = get_keybindings_summary(layer.class_keymap, col=col)
            self.keybindings_strs[f"{layer.__name__} layer"] = text

        # layer type selection
        self.layerTypeComboBox = QComboBox()
        self.layerTypeComboBox.addItems(list(self.keybindings_strs))
        self.layerTypeComboBox.activated[str].connect(self.change_layer_type)
        self.layerTypeComboBox.setCurrentText(self.ALL_ACTIVE_KEYBINDINGS)
        # self.change_layer_type(current_layer)
        layer_type_layout = QHBoxLayout()
        layer_type_layout.setContentsMargins(10, 5, 0, 0)
        layer_type_layout.addWidget(self.layerTypeComboBox)
        layer_type_layout.addStretch(1)
        layer_type_layout.setSpacing(0)
        self.layout.addLayout(layer_type_layout)
        self.layout.addWidget(self.textEditBox, 1)

        self.viewer.events.active_layer.connect(self.update_active_layer)
        self.viewer.events.palette.connect(self.update_active_layer)
        self.update_active_layer()

    def change_layer_type(self, text):
        self.textEditBox.setHtml(self.keybindings_strs[text])

    def update_active_layer(self, event=None):
        col = self.viewer.palette['secondary']
        text = ''
        # Add class and instance viewer keybindings
        text += get_keybindings_summary(self.viewer.class_keymap, col=col)
        text += get_keybindings_summary(self.viewer.keymap, col=col)

        layer = self.viewer.active_layer
        if layer is not None:
            # Add class and instance layer keybindings for the active layer
            text += get_keybindings_summary(layer.class_keymap, col=col)
            text += get_keybindings_summary(layer.keymap, col=col)

        # Update layer speficic keybindings if all active are displayed
        self.keybindings_strs[self.ALL_ACTIVE_KEYBINDINGS] = text
        if self.layerTypeComboBox.currentText() == self.ALL_ACTIVE_KEYBINDINGS:
            self.textEditBox.setHtml(text)

    def toggle_visible(self, event):
        if self.isVisible():
            self.hide()
        else:
            self.show()
            self.raise_()
コード例 #16
0
class QtAboutKeyBindings(QDialog):
    """Qt dialog window for displaying keybinding information.

    Parameters
    ----------
    viewer : napari.components.ViewerModel
        Napari viewer containing the rendered scene, layers, and controls.

    Attributes
    ----------
    key_bindings_strs : collections.OrderedDict
        Ordered dictionary of hotkey shortcuts and associated key bindings.
        Dictionary keys include:
        - 'All active key bindings'
        - 'Image layer'
        - 'Labels layer'
        - 'Points layer'
        - 'Shapes layer'
        - 'Surface layer'
        - 'Vectors layer'
    layout : qtpy.QtWidgets.QVBoxLayout
        Layout of the widget.
    layerTypeComboBox : qtpy.QtWidgets.QComboBox
        Dropdown menu to select layer type.
    textEditBox : qtpy.QtWidgets.QTextEdit
        Text box widget containing table of key bindings information.
    viewer : napari.components.ViewerModel
        Napari viewer containing the rendered scene, layers, and controls.
    """

    ALL_ACTIVE_KEYBINDINGS = 'All active key bindings'

    def __init__(self, viewer, parent=None):
        super().__init__(parent=parent)

        self.viewer = viewer
        self.layout = QVBoxLayout()

        self.setWindowTitle('Keybindings')
        self.setWindowModality(Qt.NonModal)
        self.setLayout(self.layout)

        # stacked key bindings widgets
        self.textEditBox = QTextEdit()
        self.textEditBox.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.textEditBox.setMinimumWidth(360)
        # Can switch to a normal dict when our minimum Python is 3.7
        self.key_bindings_strs = OrderedDict()
        self.key_bindings_strs[self.ALL_ACTIVE_KEYBINDINGS] = ''
        theme = get_theme(self.qt_viewer.viewer.theme)
        col = theme['secondary']
        layers = [
            napari.layers.Image,
            napari.layers.Labels,
            napari.layers.Points,
            napari.layers.Shapes,
            napari.layers.Surface,
            napari.layers.Vectors,
        ]
        for layer in layers:
            if len(layer.class_keymap) == 0:
                text = 'No key bindings'
            else:
                text = get_key_bindings_summary(layer.class_keymap, col=col)
            self.key_bindings_strs[f"{layer.__name__} layer"] = text

        # layer type selection
        self.layerTypeComboBox = QComboBox()
        self.layerTypeComboBox.addItems(list(self.key_bindings_strs))
        self.layerTypeComboBox.activated[str].connect(self.change_layer_type)
        self.layerTypeComboBox.setCurrentText(self.ALL_ACTIVE_KEYBINDINGS)
        # self.change_layer_type(current_layer)
        layer_type_layout = QHBoxLayout()
        layer_type_layout.setContentsMargins(10, 5, 0, 0)
        layer_type_layout.addWidget(self.layerTypeComboBox)
        layer_type_layout.addStretch(1)
        layer_type_layout.setSpacing(0)
        self.layout.addLayout(layer_type_layout)
        self.layout.addWidget(self.textEditBox, 1)

        self.viewer.events.active_layer.connect(self.update_active_layer)
        self.viewer.events.theme.connect(self.update_active_layer)
        self.update_active_layer()

    def change_layer_type(self, text):
        """Change layer type selected in dropdown menu.

        Parameters
        ----------
        text : str
            Dictionary key to access key bindings associated with the layer.
            Available keys include:
            - 'All active key bindings'
            - 'Image layer'
            - 'Labels layer'
            - 'Points layer'
            - 'Shapes layer'
            - 'Surface layer'
            - 'Vectors layer'
        """
        self.textEditBox.setHtml(self.key_bindings_strs[text])

    def update_active_layer(self, event=None):
        """Update the active layer and display key bindings for that layer type.

        Parameters
        ----------
        event : napari.utils.event.Event, optional
            The napari event that triggered this method, by default None.
        """
        theme = get_theme(self.qt_viewer.viewer.theme)
        col = theme['secondary']
        # Add class and instance viewer key bindings
        text = get_key_bindings_summary(self.viewer.active_keymap, col=col)

        # Update layer speficic key bindings if all active are displayed
        self.key_bindings_strs[self.ALL_ACTIVE_KEYBINDINGS] = text
        if self.layerTypeComboBox.currentText() == self.ALL_ACTIVE_KEYBINDINGS:
            self.textEditBox.setHtml(text)
コード例 #17
0
ファイル: qt_plugin_report.py プロジェクト: wwymak/napari
class QtPluginErrReporter(QDialog):
    """Dialog that allows users to review and report PluginError tracebacks.

    Parameters
    ----------
    parent : QWidget, optional
        Optional parent widget for this widget.
    initial_plugin : str, optional
        If provided, errors from ``initial_plugin`` will be shown when the
        dialog is created, by default None

    Attributes
    ----------
    text_area : qtpy.QtWidgets.QTextEdit
        The text area where traceback information will be shown.
    plugin_combo : qtpy.QtWidgets.QComboBox
        The dropdown menu used to select the current plugin
    github_button : qtpy.QtWidgets.QPushButton
        A button that, when pressed, will open an issue at the current plugin's
        github issue tracker, prepopulated with a formatted traceback.  Button
        is only visible if a github URL is detected in the package metadata for
        the current plugin.
    clipboard_button : qtpy.QtWidgets.QPushButton
        A button that, when pressed, copies the current traceback information
        to the clipboard.  (HTML tags are removed in the copied text.)
    plugin_meta : qtpy.QtWidgets.QLabel
        A label that will show available plugin metadata (such as home page).
    """

    NULL_OPTION = 'select plugin... '

    def __init__(
        self,
        plugin_manager: Optional[PluginManager] = None,
        *,
        parent: Optional[QWidget] = None,
        initial_plugin: Optional[str] = None,
    ) -> None:
        super().__init__(parent)
        if not plugin_manager:
            from ..plugins import plugin_manager as _pm

            self.plugin_manager = _pm
        else:
            self.plugin_manager = plugin_manager

        self.setWindowTitle('Recorded Plugin Exceptions')
        self.setWindowModality(Qt.NonModal)
        self.layout = QVBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(10, 10, 10, 10)
        self.setLayout(self.layout)

        self.text_area = QTextEdit()
        self.text_area.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.text_area.setMinimumWidth(360)

        # Create plugin dropdown menu
        self.plugin_combo = QComboBox()
        self.plugin_combo.addItem(self.NULL_OPTION)
        bad_plugins = [e.plugin_name for e in self.plugin_manager.get_errors()]
        self.plugin_combo.addItems(list(sorted(set(bad_plugins))))
        self.plugin_combo.currentTextChanged.connect(self.set_plugin)
        self.plugin_combo.setCurrentText(self.NULL_OPTION)

        # create github button (gets connected in self.set_plugin)
        self.github_button = QPushButton('Open issue on GitHub', self)
        self.github_button.setToolTip(
            "Open a web browser to submit this error log\n"
            "to the developer's GitHub issue tracker")
        self.github_button.hide()

        # create copy to clipboard button
        self.clipboard_button = QPushButton()
        self.clipboard_button.hide()
        self.clipboard_button.setObjectName("QtCopyToClipboardButton")
        self.clipboard_button.setToolTip("Copy error log to clipboard")
        self.clipboard_button.clicked.connect(self.copyToClipboard)

        # plugin_meta contains a URL to the home page, (and/or other details)
        self.plugin_meta = QLabel('', parent=self)
        self.plugin_meta.setObjectName("pluginInfo")
        self.plugin_meta.setTextFormat(Qt.RichText)
        self.plugin_meta.setTextInteractionFlags(Qt.TextBrowserInteraction)
        self.plugin_meta.setOpenExternalLinks(True)
        self.plugin_meta.setAlignment(Qt.AlignRight)

        # make layout
        row_1_layout = QHBoxLayout()
        row_1_layout.setContentsMargins(11, 5, 10, 0)
        row_1_layout.addStretch(1)
        row_1_layout.addWidget(self.plugin_meta)
        row_2_layout = QHBoxLayout()
        row_2_layout.setContentsMargins(11, 5, 10, 0)
        row_2_layout.addWidget(self.plugin_combo)
        row_2_layout.addStretch(1)
        row_2_layout.addWidget(self.github_button)
        row_2_layout.addWidget(self.clipboard_button)
        row_2_layout.setSpacing(5)
        self.layout.addLayout(row_1_layout)
        self.layout.addLayout(row_2_layout)
        self.layout.addWidget(self.text_area, 1)
        self.setMinimumWidth(750)
        self.setMinimumHeight(600)

        if initial_plugin:
            self.set_plugin(initial_plugin)

    def set_plugin(self, plugin: str) -> None:
        """Set the current plugin shown in the dropdown and text area.

        Parameters
        ----------
        plugin : str
            name of a plugin that has created an error this session.
        """
        self.github_button.hide()
        self.clipboard_button.hide()
        try:
            self.github_button.clicked.disconnect()
        # when disconnecting a non-existent signal
        # PySide2 raises runtimeError, PyQt5 raises TypeError
        except (RuntimeError, TypeError):
            pass

        if not plugin or (plugin == self.NULL_OPTION):
            self.plugin_meta.setText('')
            self.text_area.setHtml('')
            return

        if not self.plugin_manager.get_errors(plugin):
            raise ValueError(f"No errors reported for plugin '{plugin}'")
        self.plugin_combo.setCurrentText(plugin)

        err_string = format_exceptions(plugin, as_html=True)
        self.text_area.setHtml(err_string)
        self.clipboard_button.show()

        # set metadata and outbound links/buttons
        err0 = self.plugin_manager.get_errors(plugin)[0]
        meta = standard_metadata(err0.plugin) if err0.plugin else {}
        meta_text = ''
        if not meta:
            self.plugin_meta.setText(meta_text)
            return

        url = meta.get('url')
        if url:
            meta_text += (
                '<span style="color:#999;">plugin home page:&nbsp;&nbsp;'
                f'</span><a href="{url}" style="color:#999">{url}</a>')
            if 'github.com' in url:

                def onclick():
                    import webbrowser

                    err = format_exceptions(plugin, as_html=False)
                    err = (
                        "<!--Provide detail on the error here-->\n\n\n\n"
                        "<details>\n<summary>Traceback from napari</summary>"
                        f"\n\n```\n{err}\n```\n</details>")
                    url = f'{meta.get("url")}/issues/new?&body={err}'
                    webbrowser.open(url, new=2)

                self.github_button.clicked.connect(onclick)
                self.github_button.show()
        self.plugin_meta.setText(meta_text)

    def copyToClipboard(self) -> None:
        """Copy current plugin traceback info to clipboard as plain text."""
        plugin = self.plugin_combo.currentText()
        err_string = format_exceptions(plugin, as_html=False)
        cb = QGuiApplication.clipboard()
        cb.setText(err_string)
コード例 #18
0
ファイル: StartupDialog.py プロジェクト: xxoolm/Ryven
    def __init__(self):
        super(StartupDialog, self).__init__()

        layout = QVBoxLayout()

        # info text edit
        info_text_edit = QTextEdit()
        info_text_edit.setHtml('''
            <center>
                <h2 style="font-family: Segoe UI; font-size: xx-large; font-weight: 400; color: #a9d5ef;">
                    Welcome to Ryven
                </h2>
            </center>
            <div style="font-family: Corbel; font-size: x-large;">
            
                <p>
                    <img style="float:right;" height=120 src="../resources/pics/Ryven_icon_blurred.png">Hey,
                    it's Leon, the creator of Ryven. Keep in mind that this
                    is not a professional piece of software. Don\'t forget to save!
                    There are always some bugs and issues but as long as you keep behaving
                    as intended, you shouldn\'t get into too much trouble. Have fun!
                </p>
            </div>
        ''')
        info_text_edit.setReadOnly(True)
        layout.addWidget(info_text_edit)

        # buttons
        plain_project_push_button = QPushButton('create new project')
        plain_project_push_button.setFocus()
        plain_project_push_button.clicked.connect(
            self.plain_project_button_clicked)
        load_project_push_button = QPushButton('load project')
        load_project_push_button.clicked.connect(
            self.load_project_button_clicked)

        buttons_layout = QHBoxLayout()
        buttons_layout.addWidget(plain_project_push_button)
        buttons_layout.addWidget(load_project_push_button)

        layout.addLayout(buttons_layout)

        self.window_theme = apply_stylesheet('dark')

        choose_theme_layout = QHBoxLayout()
        self.dark_theme_rb = QRadioButton('dark')
        self.dark_theme_rb.setChecked(True)
        self.dark_theme_rb.toggled.connect(self.theme_toggled)
        self.light_theme_rb = QRadioButton('light')
        self.light_theme_rb.toggled.connect(self.theme_toggled)
        choose_theme_layout.addWidget(self.dark_theme_rb)
        choose_theme_layout.addWidget(self.light_theme_rb)
        layout.addLayout(choose_theme_layout)

        self.setLayout(layout)

        self.setWindowTitle('Ryven')
        self.setWindowIcon(QIcon('../resources/pics/Ryven_icon.png'))
        self.setFixedSize(500, 280)

        self.editor_startup_configuration = {}