コード例 #1
0
ファイル: gui.py プロジェクト: Maxibing/termerpature_box_demo
    def initLineEdit(self):
        data_reg = QRegExp('[-\.0-9]+')
        data_validator = QRegExpValidator(self)
        data_validator.setRegExp(data_reg)

        temp_control = []
        self.le_temp_set = QLineEdit(self)
        temp_control.append(self.le_temp_set)
        self.le_slope_set = QLineEdit(self)
        temp_control.append(self.le_slope_set)

        for le in temp_control:
            le.setFixedWidth(150)
            le.setFixedHeight(60)
            le.setFont(QFont("Roman times", 20, QFont.Bold))
            le.setAlignment(Qt.AlignCenter)
            le.setValidator(data_validator)

        cyclic = []
        self.le_cyclic_start_temp = QLineEdit(self)
        self.le_cyclic_start_temp.setPlaceholderText("最低温度")
        cyclic.append(self.le_cyclic_start_temp)
        self.le_cyclic_stop_temp = QLineEdit(self)
        self.le_cyclic_stop_temp.setPlaceholderText("最高温度")
        cyclic.append(self.le_cyclic_stop_temp)

        for le in cyclic:
            le.setFixedWidth(150)
            le.setFixedHeight(60)
            le.setFont(QFont("Roman times", 20, QFont.Bold))
            le.setAlignment(Qt.AlignCenter)
            le.setValidator(data_validator)
コード例 #2
0
 def __init__(self, parent=None):
     super(ValidatorQDialog, self).__init__(parent)
     self.setWindowTitle('Edit Dialog')
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setStyleSheet(settings.css_style)
     self.setWindowIcon(QIcon(settings.get_image('icon')))
     self.setObjectName('dialog')
     self.setFixedSize(250, 200)
     # Fields
     self.line_edit = QLineEdit()
     self.valid_text = QLabel()
     self.validator = QRegExpValidator()
     self.old_text = ''
コード例 #3
0
    def initGui(self):

        self.main_layout = QHBoxLayout()

        send_input, send_btn, file_dialog, file_select, refresh_btn, recv_btn, ntwk_details = self.send_recv_gui(
        )

        ipv4_input, port_input, conn_btn, disconn_btn, conn_label, conn_details = self.connect_to_addr_gui(
        )

        # Set Input Validators
        port_reg = QRegExp("\d{5}")
        port_vali = QRegExpValidator(port_reg, port_input)
        port_input.setValidator(port_vali)

        # Add Button Functions
        conn_btn.released.connect(lambda: self.connect(ipv4_input.text(
        ), port_input.text(), conn_details, conn_label))
        disconn_btn.released.connect(
            lambda: self.c.disconnect(conn_label, conn_details))
        file_dialog.released.connect(lambda: self.browse(send_input))
        refresh_btn.released.connect(
            lambda: self.c.request_file_names(file_select))
        recv_btn.released.connect(
            lambda: self.c.my_receive(file_select.currentText(), ntwk_details))
        send_btn.released.connect(
            lambda: self.c.my_send(send_input.text(), ntwk_details))

        self.setLayout(self.main_layout)
コード例 #4
0
    def __init__(self, *__args, _default_text: str = '0'):
        super(DisplayId, self).__init__(*__args)

        # Guarantee of getting an int-shaped string
        self.setValidator(QRegExpValidator(QRegExp(r'\d{8}')))
        self.__default_text = _default_text
        self.setDefaultText(self.__default_text)
コード例 #5
0
    def __init__(self, parent=None):
        super(QWidget, self).__init__(parent)
        self.le_input = QLineEdit(self)

        reg_ex = QRegExp("[1-9]+.?[0-9]{,2}")
        input_validator = QRegExpValidator(reg_ex, self.le_input)
        self.le_input.setValidator(input_validator)
コード例 #6
0
 def __init__(self):
     QtWidgets.QDialog.__init__(self)
     
     float_ex = QRegExp("[0-9]+[.]?[0-9]{1,2}")
     float_validator = QRegExpValidator(float_ex)
     
     int_pos_ex = QRegExp("[0-9]+")
     int_pos_validator = QRegExpValidator(int_pos_ex)
     
     self.ui = uic.loadUi('simulator_ui.ui')
     self.ui.startSimulation.clicked.connect(self.start_simulation)
     self.ui.stopSimulation.clicked.connect(self.stop_simulation)
     self.ui.exitProgramm.clicked.connect(self.exit_application)
     
     self.ui.bodyCount.setValidator(int_pos_validator)
     self.ui.minMass.setValidator(int_pos_validator)
     self.ui.minMassPot.setValidator(int_pos_validator)
     self.ui.maxMass.setValidator(int_pos_validator)
     self.ui.maxMassPot.setValidator(int_pos_validator)
     self.ui.minRad.setValidator(int_pos_validator)
     self.ui.minRadPot.setValidator(int_pos_validator)
     self.ui.maxRad.setValidator(int_pos_validator)
     self.ui.maxRadPot.setValidator(int_pos_validator)
     self.ui.centerMass.setValidator(int_pos_validator)
     self.ui.centerMassPot.setValidator(int_pos_validator)
     self.ui.centerRad.setValidator(int_pos_validator)
     self.ui.centerRadPot.setValidator(int_pos_validator)
     self.ui.scale.setValidator(int_pos_validator)
     self.ui.scalePot.setValidator(int_pos_validator)
     
     self.ui.slider.valueChanged.connect(self.update_slider_label)
     
     self.ui.stepScale.editingFinished.connect(self.update_slider)
     self.ui.stepScale.setValidator(int_pos_validator)
     
     self.ui.slider_label.editingFinished.connect(self.slider_label_changed)
     self.ui.slider_label.setValidator(float_validator)
     
     self.renderer_conn, self.simulation_conn = None, None
     self.render_process = None
     self.simulation_process = None
     multiprocessing.set_start_method('spawn')
     
     self.manager = Manager()
     self.step_scale = self.manager.Value('int', 0)
     
     self.update_slider_label()
コード例 #7
0
 def __init__(self, *args):
     QLineEdit.__init__(self, *args)
     self.setValidator(QRegExpValidator(QRegExp(r'\d+\.\d+'), self))
     self.setToolTip(textwrap.fill('<p>'+_(
         'Go to a reference. To get reference numbers, use the <i>reference '
         'mode</i>, by clicking the reference mode button in the toolbar.')))
     if hasattr(self, 'setPlaceholderText'):
         self.setPlaceholderText(_('Go to...'))
     self.editingFinished.connect(self.editing_finished)
コード例 #8
0
 def __init__(self, parent=None):
     super(ValidatorQDialog, self).__init__(parent)
     self.setWindowTitle('Edit Dialog')
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setStyleSheet(settings.css_style)
     self.setWindowIcon(QIcon(settings.get_image('icon')))
     self.setObjectName('dialog')
     self.setFixedSize(250, 200)
     # Fields
     self.line_edit = QLineEdit()
     self.valid_text = QLabel()
     self.validator = QRegExpValidator()
     self.old_text = ''
コード例 #9
0
 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent reference to the parent widget
     @type QWidget
     """
     super(Dialog, self).__init__(parent)
     self.normalFlag = False
     self.setupUi(self)
     self.lineEditLambda.setVisible(False)
     self.lambdaInfo.setVisible(False)
     self.regExp = QRegExp("^(-?\d+)(\.\d+)?$")  # 创建了一个模式
     self.validator = QRegExpValidator(self.regExp)
     self.lineEditLambda.setValidator(self.validator)
     self.lineEditNum.setValidator(self.validator)
     self.lineEditPower.setValidator(self.validator)
コード例 #10
0
    def __init__(self):
        super().__init__()
        self.layout = QHBoxLayout()
        q_reg = QRegExp("\d{3}")
        for x in range(4):
            line_edit = QLineEdit()
            q_validator = QRegExpValidator(q_reg, line_edit)
            line_edit.setValidator(q_validator)
            line_edit.setFont(QFont(None, 13))
            line_edit.setMaximumWidth(34)
            line_edit.setMinimumWidth(34)

            self.layout.addWidget(line_edit)
            if x < 3:
                self.layout.addWidget(QLabel("."))

            self.line_edits.append(line_edit)
        self.layout.addStretch()
        self.setLayout(self.layout)
コード例 #11
0
ファイル: settings.py プロジェクト: cunyap/pyIMD
    def __init__(self, settings_dictionary):
        """
        Settings user interface (UI) constructor.

        Returns:
            QDialog (`obj`):     Settings ui object
        """
        super(SettingsDialog, self).__init__()
        uic.loadUi(resource_path(os.path.join('ui', 'setting_dialog.ui')),
                   self)
        self.setWindowTitle('pyIMD :: Settings')
        self.settingsIcon = QIcon()
        self.settingsIcon.addPixmap(
            self.style().standardPixmap(QStyle.SP_FileDialogDetailedView),
            QIcon.Disabled, QIcon.Off)
        self.setWindowIcon(self.settingsIcon)
        self.frequency_offset_spin.setMinimum(1)
        self.frequency_offset_spin.setMaximum(10**9)
        self.settings_dictionary = settings_dictionary

        # Establish connections
        self.defaultBtn.clicked.connect(self.set_defaults)
        self.commitBtn.clicked.connect(self.commit_parameters)
        self.cancelBtn.clicked.connect(self.close_settings_dialog)
        self.do_offset_corr_chkbox.clicked.connect(
            self.on_toggle_frequency_offset)
        self.offsetGroupBox.setEnabled(False)
        self.frequency_offset_edit.setEnabled(False)
        self.frequency_offset_mode_auto.setChecked(True)
        self.frequency_offset_mode_auto.toggled.connect(
            self.on_frequency_offset_mode_auto)
        self.frequency_offset_mode_manual.toggled.connect(
            self.on_frequency_offset_mode_manual)

        double_validator = QDoubleValidator()
        self.figure_width_edit.setValidator(double_validator)
        self.figure_width_edit.textChanged.connect(self.check_state)
        self.figure_height_edit.setValidator(double_validator)
        self.figure_height_edit.textChanged.connect(self.check_state)
        self.figure_resolution_edit.setValidator(double_validator)
        self.figure_resolution_edit.textChanged.connect(self.check_state)
        self.conversion_factor_hz_edit.setValidator(double_validator)
        self.conversion_factor_hz_edit.textChanged.connect(self.check_state)
        self.conversion_factor_deg_edit.setValidator(double_validator)
        self.conversion_factor_deg_edit.textChanged.connect(self.check_state)
        self.spring_constant_edit.setValidator(double_validator)
        self.spring_constant_edit.textChanged.connect(self.check_state)
        self.cantilever_length_edit.setValidator(double_validator)
        self.cantilever_length_edit.textChanged.connect(self.check_state)
        self.cell_position_edit.setValidator(double_validator)
        self.cell_position_edit.textChanged.connect(self.check_state)
        self.read_text_data_from_line_edit.setValidator(double_validator)
        self.read_text_data_from_line_edit.textChanged.connect(
            self.check_state)
        self.figure_plot_every_nth_point_edit.setValidator(double_validator)
        self.figure_plot_every_nth_point_edit.textChanged.connect(
            self.check_state)
        self.rolling_window_size_edit.setValidator(double_validator)
        self.rolling_window_size_edit.textChanged.connect(self.check_state)
        self.frequency_offset_edit.setValidator(double_validator)
        self.frequency_offset_edit.textChanged.connect(self.check_state)

        reg_ex = QRegExp("[0-9-a-z-A-Z_]+")
        self.figure_name_wo_cell_edit.setValidator(
            QRegExpValidator(reg_ex, self.figure_name_wo_cell_edit))
        self.figure_name_wo_cell_edit.textChanged.connect(self.check_state)
        self.figure_name_w_cell_edit.setValidator(
            QRegExpValidator(reg_ex, self.figure_name_w_cell_edit))
        self.figure_name_w_cell_edit.textChanged.connect(self.check_state)
        self.figure_name_data_edit.setValidator(
            QRegExpValidator(reg_ex, self.figure_name_data_edit))
        self.figure_name_data_edit.textChanged.connect(self.check_state)

        self.figure_unit_edit.setValidator(
            QRegExpValidator(QRegExp("[a-z-A-Z_]+"),
                             self.figure_name_wo_cell_edit))
        self.figure_unit_edit.textChanged.connect(self.check_state)

        self.figure_format_edit.setValidator(
            QRegExpValidator(QRegExp(".+[a-z-A-Z_]"),
                             self.figure_name_wo_cell_edit))
        self.figure_format_edit.textChanged.connect(self.check_state)
        self.text_data_delimiter_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\\{1}\w*)"),
                             self.text_data_delimiter_edit))
        self.text_data_delimiter_edit.textChanged.connect(self.check_state)

        self.intial_param_guess_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\[\d+.+,\s*)+\d+.+\\]{1}"),
                             self.intial_param_guess_edit))
        self.intial_param_guess_edit.textChanged.connect(self.check_state)

        self.lower_param_bound_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\[\d+.+,\s*)+\d+.+\\]{1}"),
                             self.lower_param_bound_edit))
        self.lower_param_bound_edit.textChanged.connect(self.check_state)

        self.upper_param_bound_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\[\d+.+,\s*)+\d+.+\\]{1}"),
                             self.upper_param_bound_edit))
        self.upper_param_bound_edit.textChanged.connect(self.check_state)
コード例 #12
0
    def initUI(self):
        self.resize(1280, 700)
        conLayout = QVBoxLayout()
        self.table = QTableWidget()
        self.table.setRowCount(93)
        self.table.setColumnCount(24)

        header_labels = []
        for i in range(6):
            s1 = '%d月实际-金额' % (i + 1)
            s2 = '%d月实际-吨耗' % (i + 1)
            header_labels.append(s1)
            header_labels.append(s2)
            s1 = '%d月分解-金额' % (i + 1)
            s2 = '%d月费解-吨耗' % (i + 1)
            header_labels.append(s1)
            header_labels.append(s2)

        self.table.setHorizontalHeaderLabels(header_labels)
        self.table.setVerticalHeaderLabels(self._cost_type)

        # for i in range(12):
        #     self.table.setSpan(0, 2*i+1, 1, 2)
        #     self.table.setSpan(2, 2*i+1, 1, 2)
        #     self.table.setItem(0, 2*i+1, self.setItem('%d月实际' % (i+1)))
        #
        #     self.table.setItem(1, 2*i+1, self.setItem('金额'))
        #     self.table.setItem(1, 2*i+2, self.setItem('吨耗'))
        #
        # for i in range(len(self._cost_type)):
        #     self.table.setItem(2+i, 0, self.setItem(self._cost_type[i]))

        # twheader = QTableWidget()
        # twheader.setRowCount(2)
        # twheader.setColumnCount(26)
        # twheader.horizontalHeader().setVisible(False)
        # twheader.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        # twheader.setEditTriggers(QAbstractItemView.NoEditTriggers)
        # twheader.setFocusPolicy(Qt.NoFocus)
        #
        # conLayout.addWidget(twheader)

        self.table.itemChanged.connect(self.table_item_changed)

        # self.table.itemSelectionChanged.connect(self.table_item_changed)

        conLayout.addWidget(self.table)

        self.btn_layout = QHBoxLayout()

        self.save_button = QPushButton('记得随时保存')
        self.cal_button = QPushButton('计算')
        self.create_button = QPushButton('生成excel')
        self.btn_layout.addWidget(self.save_button)
        self.btn_layout.addWidget(self.cal_button)
        self.btn_layout.addWidget(self.create_button)
        conLayout.addLayout(self.btn_layout)
        self.setLayout(conLayout)

        for i in range(93):
            for j in range(24):
                # self.table.setItem(i, j, self.setItem('0.00'))
                edit = QLineEdit('0.00')
                # edit.textChanged.connect(self.text_changed)
                edit.focusOutEvent(self.text_changed)
                edit.setValidator(QRegExpValidator(QRegExp('^\d+(\.\d\d)?$')))
                self.table.setCellWidget(i, j, edit)

        self.center()
コード例 #13
0
ファイル: extended_mode.py プロジェクト: 0id80/CourseWork
    def __init__(self):
        super(ExtendedModeWindow, self).__init__()
        self.grid_layout = QGridLayout()
        self.grid_layout.setObjectName("grid_layout")
        self.setWindowTitle("Calculator - Extended Mode")
        self.resize(*self._normal_size)
        self.setMinimumSize(*self._normal_size)
        self.setStyleSheet(
            u"QTextBrowser { border: 0px; font-size 25pt; }"
            u"QWidget { background-color: #333333; color: white } "
            u"QPushButton { color: black; font-size: 15pt; background-color: #f4f4f4 } "
            u"QLineEdit { border: 0px; border-bottom: 1px solid white ; font-size: 15pt; }"
        )

        self.label_bio = QLabel()
        self.label_bio.setText('Малых Евгений Александрович')
        self.label_bio.setFont(QFont("Calibri", 25))
        self.label_bio.setAlignment(Qt.AlignCenter)
        self.label_bio.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.grid_layout.addWidget(self.label_bio, 0, 0, 1, 5)

        self.label_id = QLabel()
        self.label_id.setText('MUIV ID:')
        self.label_id.setFont(QFont("Calibri", 15))
        self.label_id.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.label_id.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.grid_layout.addWidget(self.label_id, 1, 0, 1, 1)

        self.display_id = QLineEdit()
        self.display_id.setText(str(self._default_id))
        self.display_id.setFont(QFont("Calibri", 15))
        self.display_id.setAlignment(Qt.AlignCenter)
        self.display_id.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.display_id.setValidator(QRegExpValidator(QRegExp(r'\d{8}')))
        self.grid_layout.addWidget(self.display_id, 1, 1, 1, 1)

        self.display = Display()
        self.display.setFont(QFont("Calibri", 12))
        self.display.setFocusPolicy(Qt.NoFocus)
        self.display.setReadOnly(True)
        self.display.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.calculate_display_rows()
        self.grid_layout.addWidget(self.display, 2, 0, 1, 5)

        self.button_normal_mode = self.create_button("≡", position=(3, 0))
        self.button_calculate_display_memory = self.create_button("<>",
                                                                  position=(3,
                                                                            1))

        self.button_memory_change = QComboBox()
        self.button_memory_change.setFont(QFont("Calibri", 14))
        self.button_memory_change.clear()
        self.button_memory_change.addItems(self._memory_cells.keys())
        self.grid_layout.addWidget(self.button_memory_change, 3, 2)

        self.button_deletion = self.create_button("←", position=(3, 3))
        self.button_clear = self.create_button("C", position=(3, 4))

        self.button_sinh = self.create_button("sinh", position=(4, 0))
        self.button_mod = self.create_button("mod", position=(4, 1))
        self.button_y_x = self.create_button("ʸ√ₓ", position=(4, 2))
        self.button_lg_10 = self.create_button("lg10", position=(4, 3))
        self.button_clear_all = self.create_button("CE", position=(4, 4))

        self.button_memory_clear = self.create_button("MC", position=(5, 0))
        self.button_memory_read = self.create_button("MR", position=(5, 1))
        self.button_memory_save = self.create_button("MS", position=(5, 2))
        self.button_memory_plus = self.create_button("M+", position=(5, 3))
        self.ext_button_memory_minus = self.create_button("M-",
                                                          position=(5, 4))

        self.button_7 = self.create_button("7", position=(6, 0))
        self.button_8 = self.create_button("8", position=(6, 1))
        self.button_9 = self.create_button("9", position=(6, 2))
        self.button_division = self.create_button("/", position=(6, 3))
        self.button_degree = self.create_button("x^y", position=(6, 4))

        self.button_4 = self.create_button("4", position=(7, 0))
        self.button_5 = self.create_button("5", position=(7, 1))
        self.button_6 = self.create_button("6", position=(7, 2))
        self.button_multiplication = self.create_button("*", position=(7, 3))
        self.button_root = self.create_button("√", position=(7, 4))

        self.button_1 = self.create_button("1", position=(8, 0))
        self.button_2 = self.create_button("2", position=(8, 1))
        self.button_3 = self.create_button("3", position=(8, 2))
        self.button_minus = self.create_button("-", position=(8, 3))
        self.button_negative = self.create_button("±", position=(8, 4))

        self.button_0 = self.create_button("0", position=(9, 0, 1, 2))
        self.button_point = self.create_button(".", position=(9, 2))
        self.button_plus = self.create_button("+", position=(9, 3))
        self.button_equal = self.create_button("=", position=(9, 4))

        self.setLayout(self.grid_layout)

        self.calculate_memory()
コード例 #14
0
 def __init__(self, *args):
     QLineEdit.__init__(self, *args)
     self.setValidator(
         QRegExpValidator(QRegExp(r'(^\d*\.[\d]{1,2}$)|(^[1-9]\d*[\.]$)'),
                          self))
コード例 #15
0
    def request_octo_init_settings(self, wizard, method):
        vbox = QVBoxLayout()
        next_enabled = True
        label = QLabel(_("Enter a label to name your device:"))
        name = QLineEdit()
        hl = QHBoxLayout()
        hl.addWidget(label)
        hl.addWidget(name)
        hl.addStretch(1)
        vbox.addLayout(hl)

        def clean_text(widget):
            text = widget.toPlainText().strip()
            return ' '.join(text.split())

        if method in [TIM_NEW, TIM_RECOVER]:
            gb = QGroupBox()
            hbox1 = QHBoxLayout()
            gb.setLayout(hbox1)
            vbox.addWidget(gb)
            gb.setTitle(_("Select your seed length:"))
            bg_numwords = QButtonGroup()
            for i, count in enumerate([12, 18, 24]):
                rb = QRadioButton(gb)
                rb.setText(_("%d words") % count)
                bg_numwords.addButton(rb)
                bg_numwords.setId(rb, i)
                hbox1.addWidget(rb)
                rb.setChecked(True)
            cb_pin = QCheckBox(_('Enable PIN protection'))
            cb_pin.setChecked(True)
        else:
            text = QTextEdit()
            text.setMaximumHeight(60)
            if method == TIM_MNEMONIC:
                msg = _("Enter your BIP39 mnemonic:")
            else:
                msg = _("Enter the master private key beginning with xprv:")

                def set_enabled():
                    from electrum.keystore import is_xprv
                    wizard.next_button.setEnabled(is_xprv(clean_text(text)))

                text.textChanged.connect(set_enabled)
                next_enabled = False

            vbox.addWidget(QLabel(msg))
            vbox.addWidget(text)
            pin = QLineEdit()
            pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,9}')))
            pin.setMaximumWidth(100)
            hbox_pin = QHBoxLayout()
            hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):")))
            hbox_pin.addWidget(pin)
            hbox_pin.addStretch(1)

        if method in [TIM_NEW, TIM_RECOVER]:
            vbox.addWidget(WWLabel(RECOMMEND_PIN))
            vbox.addWidget(cb_pin)
        else:
            vbox.addLayout(hbox_pin)

        passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT)
        passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
        passphrase_warning.setStyleSheet("color: red")
        cb_phrase = QCheckBox(_('Enable passphrases'))
        cb_phrase.setChecked(False)
        vbox.addWidget(passphrase_msg)
        vbox.addWidget(passphrase_warning)
        vbox.addWidget(cb_phrase)

        # ask for recovery type (random word order OR matrix)
        if method == TIM_RECOVER:
            gb_rectype = QGroupBox()
            hbox_rectype = QHBoxLayout()
            gb_rectype.setLayout(hbox_rectype)
            vbox.addWidget(gb_rectype)
            gb_rectype.setTitle(_("Select recovery type:"))
            bg_rectype = QButtonGroup()

            rb1 = QRadioButton(gb_rectype)
            rb1.setText(_('Scrambled words'))
            bg_rectype.addButton(rb1)
            bg_rectype.setId(rb1, RECOVERY_TYPE_SCRAMBLED_WORDS)
            hbox_rectype.addWidget(rb1)
            rb1.setChecked(True)

            rb2 = QRadioButton(gb_rectype)
            rb2.setText(_('Matrix'))
            bg_rectype.addButton(rb2)
            bg_rectype.setId(rb2, RECOVERY_TYPE_MATRIX)
            hbox_rectype.addWidget(rb2)
        else:
            bg_rectype = None

        wizard.exec_layout(vbox, next_enabled=next_enabled)

        if method in [TIM_NEW, TIM_RECOVER]:
            item = bg_numwords.checkedId()
            pin = cb_pin.isChecked()
            recovery_type = bg_rectype.checkedId() if bg_rectype else None
        else:
            item = ' '.join(str(clean_text(text)).split())
            pin = str(pin.text())
            recovery_type = None

        return (item, name.text(), pin, cb_phrase.isChecked(), recovery_type)
コード例 #16
0
    def __init__(self, astergui, parent=None):
        """
        Create panel.

        Arguments:
            astergui (AsterGui): AsterGui instance.
            parent (Optional[QWidget]): Parent widget.
        """
        super(ParameterPanel,
              self).__init__(parent=parent,
                             name=translate("ParameterPanel", "Edit command"),
                             astergui=astergui)
        self.setPixmap(load_pixmap("as_pic_edit_command.png"))

        self._files_model = astergui.study().dataFilesModel()
        self._unit_model = None

        self._command = None
        self.title = ParameterTitle(self)
        self.title.installEventFilter(self)
        self._name = QLineEdit(self)
        self.views = QStackedWidget(self)
        v_layout = QVBoxLayout(self)
        v_layout.setContentsMargins(0, 0, 0, 0)
        v_layout.setSpacing(5)
        v_layout.addWidget(self.title)
        v_layout.addWidget(HLine(self))

        n_layout = QHBoxLayout()
        v_layout.addLayout(n_layout)
        n_layout.addWidget(QLabel(translate("ParameterPanel", "Name"), self))
        n_layout.addWidget(self._name)
        # force to be a valid identifier + length <= 8
        self._name.setValidator(QRegExpValidator(QRegExp(r"[a-zA-Z]\w{1,7}")))

        # create toolbar
        tbar = QToolBar(self)
        tbar.setToolButtonStyle(Qt.ToolButtonIconOnly)
        # - Edit comment
        edit_comment = QAction(translate("AsterStudy", "Edit &Comment"), self)
        edit_comment.setToolTip(translate("AsterStudy", "Edit comment"))
        edit_comment.setStatusTip(
            translate("AsterStudy", "Edit comment for the "
                      "selected object"))
        edit_comment.setIcon(load_icon("as_pic_edit_comment.png"))
        connect(edit_comment.triggered, self._editComment)
        tbar.addAction(edit_comment)
        # - Switch on/off business-translations
        title = translate("AsterStudy", "Use Business-Oriented Translations")
        self.use_translations = QAction(title, self)
        title = translate("AsterStudy", "Use business-oriented translations")
        self.use_translations.setToolTip(title)
        self.use_translations.setStatusTip(title)
        self.use_translations.setIcon(load_icon("as_pic_use_translations.png"))
        self.use_translations.setCheckable(True)
        if behavior().forced_native_names:
            force = behavior().force_native_names
            self.use_translations.setDisabled(True)
            is_on = not force
        else:
            is_on = behavior().use_business_translations
        Options.use_translations = is_on
        self.use_translations.setChecked(is_on)
        connect(self.use_translations.toggled, self.updateTranslations)
        tbar.addAction(self.use_translations)
        # - Hide unused
        hide_unused = astergui.action(ActionType.HideUnused)
        connect(hide_unused.toggled, self._unusedVisibility)
        tbar.addAction(hide_unused)
        # - What's this
        whats_this = QWhatsThis.createAction(tbar)
        whats_this.setToolTip(translate("AsterStudy", "What's this?"))
        whats_this.setStatusTip(
            translate("AsterStudy", "Show element's description"))
        whats_this.setIcon(load_icon("as_pic_whats_this.png"))
        tbar.addAction(whats_this)
        # - Link to doc
        tbar.addAction(astergui.action(ActionType.LinkToDoc))

        n_layout.addWidget(tbar)

        v_layout.addWidget(self.views)
        self._updateState()
コード例 #17
0
    def _init_ui(self):
        self.setWindowTitle(self.config.title)
        self.resize(*self.config.size)
        self.setMinimumSize(*self.config.min_size)
        self.setStyleSheet(self.config.style_sheet)

        self.grid = QGridLayout()

        _cols = len(self.config.student_id) // 2 + 2

        self.id_label = QLabel()
        self.id_label.setText(
            f'{self.config.student_name} | {self.config.student_id}')
        self.id_label.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.id_label.setFont(QFont(self.config.font, self.config.font_size))
        self.id_label.setAlignment(Qt.AlignCenter)
        self.grid.addWidget(self.id_label, 0, 0, 1, _cols)

        _start_iteration = Iteration.get(percent=0)

        self.display = Display()
        self.display.show_stage(_start_iteration)
        self.display.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.display.setFont(QFont(self.config.font, self.config.font_size))
        self.display.setAlignment(Qt.AlignCenter)
        self.grid.addWidget(self.display, 1, 0, 5, _cols)

        self.info_display = InfoDisplay()
        self.info_display.show_info(_start_iteration)
        self.info_display.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.info_display.setFont(
            QFont(self.config.font, self.config.font_size))
        self.info_display.setAlignment(Qt.AlignCenter)
        self.grid.addWidget(self.info_display, 6, 0, 1, _cols)

        _n = int()

        for col in range(_cols):
            if col == 0:
                self.button_start = QPushButton()
                self.button_start.setText('Draw begin')
                self.button_start.setSizePolicy(
                    QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
                self.button_start.setFont(
                    QFont(self.config.font, self.config.font_size))
                self.grid.addWidget(self.button_start, 7, col, 2, 1)
            elif col == _cols - 1:
                self.button_end = QPushButton()
                self.button_end.setText('Draw end')
                self.button_end.setSizePolicy(
                    QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
                self.button_end.setFont(
                    QFont(self.config.font, self.config.font_size))
                self.grid.addWidget(self.button_end, 7, col, 2, 1)
            else:
                entry = QLineEdit()
                entry.setValidator(QRegExpValidator(QRegExp(r'\d{2}')))
                entry.setSizePolicy(
                    QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
                entry.setFont(QFont(self.config.font, self.config.font_size))
                entry.setAlignment(Qt.AlignCenter)
                entry.setText(self.config.student_id[_n * 2:_n * 2 + 2])
                _n += 1
                self.grid.addWidget(entry, 7, col, 1, 1)
                setattr(self, f'entry_{col}', entry)

                button = QPushButton()
                button.setText(f'Draw: {col}')
                button.setSizePolicy(
                    QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
                button.setFont(QFont(self.config.font, self.config.font_size))
                self.grid.addWidget(button, 8, col, 1, 1)
                setattr(self, f'button_{col}', button)

        self.setLayout(self.grid)
コード例 #18
0
class ValidatorQDialog(QDialog):
    """
        Class who create Validator QDialog to edit text in Alignak-app with regexp to validate
    """

    def __init__(self, parent=None):
        super(ValidatorQDialog, self).__init__(parent)
        self.setWindowTitle('Edit Dialog')
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setStyleSheet(settings.css_style)
        self.setWindowIcon(QIcon(settings.get_image('icon')))
        self.setObjectName('dialog')
        self.setFixedSize(250, 200)
        # Fields
        self.line_edit = QLineEdit()
        self.valid_text = QLabel()
        self.validator = QRegExpValidator()
        self.old_text = ''

    def initialize(self, title, text, regexp):
        """
        Initialize QDialog for ValidatorQDialog

        :param title: title of the QDialog
        :type title: str
        :param text: text to edit
        :type text: str
        :param regexp: regular expression to validate
        :type regexp: str
        """

        self.old_text = text
        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, title))

        text_title = QLabel(_("Edit your text:"))
        text_title.setObjectName('subtitle')
        main_layout.addWidget(text_title)
        main_layout.setAlignment(text_title, Qt.AlignCenter)

        main_layout.addWidget(self.get_text_widget(regexp))

    def get_text_widget(self, regexp):
        """
        Return text QWidget with QTextEdit

        :return: text QWidget
        :rtype: QWidget
        """

        text_widget = QWidget()
        text_widget.setObjectName('dialog')
        text_layout = QVBoxLayout()
        text_widget.setLayout(text_layout)

        text_layout.addWidget(self.valid_text)

        qreg_exp = QRegExp(regexp)
        self.validator.setRegExp(qreg_exp)
        self.line_edit.setPlaceholderText(_('type your text...'))
        self.line_edit.setText(self.old_text)
        self.line_edit.setValidator(self.validator)
        self.line_edit.setFixedHeight(25)
        self.line_edit.textChanged.connect(self.check_text)
        text_layout.addWidget(self.line_edit)

        # Accept button
        accept_btn = QPushButton(_('Confirm'), self)
        accept_btn.clicked.connect(self.accept_text)
        accept_btn.setObjectName('valid')
        accept_btn.setMinimumHeight(30)
        text_layout.addWidget(accept_btn)

        return text_widget

    def check_text(self):
        """
        Valid email with ``QRegExpValidator`` and inform user

        """

        state = self.validator.validate(self.line_edit.text(), 0)[0]
        if state == QRegExpValidator.Acceptable:
            text = 'Valid email'
            color = '#27ae60'  # green
        else:
            text = 'Invalid email !'
            color = '#e67e22'  # orange

        self.valid_text.setStyleSheet('QLabel { color: %s; }' % color)
        self.valid_text.setText(text)

    def accept_text(self):  # pragma: no cover
        """
        Set Edit QDialog to Rejected or Accepted (prevent to patch for nothing)

        """

        state = self.validator.validate(self.line_edit.text(), 0)[0]
        if self.old_text == self.line_edit.text():
            self.reject()
        elif not self.old_text or self.old_text.isspace():
            if not self.line_edit.text() or self.line_edit.text().isspace():
                self.reject()
            else:
                if state == QRegExpValidator.Acceptable:
                    self.accept()
                else:
                    self.reject()
        elif not self.line_edit.text() or self.line_edit.text().isspace():
            self.line_edit.setText('')
            self.accept()
        else:
            if state == QRegExpValidator.Acceptable:
                self.accept()
            else:
                self.reject()
コード例 #19
0
class ValidatorQDialog(QDialog):
    """
        Class who create Validator QDialog to edit text in Alignak-app with regexp to validate
    """
    def __init__(self, parent=None):
        super(ValidatorQDialog, self).__init__(parent)
        self.setWindowTitle('Edit Dialog')
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setStyleSheet(settings.css_style)
        self.setWindowIcon(QIcon(settings.get_image('icon')))
        self.setObjectName('dialog')
        self.setFixedSize(250, 200)
        # Fields
        self.line_edit = QLineEdit()
        self.valid_text = QLabel()
        self.validator = QRegExpValidator()
        self.old_text = ''

    def initialize(self, title, text, regexp):
        """
        Initialize QDialog for ValidatorQDialog

        :param title: title of the QDialog
        :type title: str
        :param text: text to edit
        :type text: str
        :param regexp: regular expression to validate
        :type regexp: str
        """

        self.old_text = text
        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, title))

        text_title = QLabel(_("Edit your text:"))
        text_title.setObjectName('subtitle')
        main_layout.addWidget(text_title)
        main_layout.setAlignment(text_title, Qt.AlignCenter)

        main_layout.addWidget(self.get_text_widget(regexp))

    def get_text_widget(self, regexp):
        """
        Return text QWidget with QTextEdit

        :return: text QWidget
        :rtype: QWidget
        """

        text_widget = QWidget()
        text_widget.setObjectName('dialog')
        text_layout = QVBoxLayout()
        text_widget.setLayout(text_layout)

        text_layout.addWidget(self.valid_text)

        qreg_exp = QRegExp(regexp)
        self.validator.setRegExp(qreg_exp)
        self.line_edit.setPlaceholderText(_('type your text...'))
        self.line_edit.setText(self.old_text)
        self.line_edit.setValidator(self.validator)
        self.line_edit.setFixedHeight(25)
        self.line_edit.textChanged.connect(self.check_text)
        text_layout.addWidget(self.line_edit)

        # Accept button
        accept_btn = QPushButton(_('Confirm'), self)
        accept_btn.clicked.connect(self.accept_text)
        accept_btn.setObjectName('valid')
        accept_btn.setMinimumHeight(30)
        text_layout.addWidget(accept_btn)

        return text_widget

    def check_text(self):
        """
        Valid email with ``QRegExpValidator`` and inform user

        """

        state = self.validator.validate(self.line_edit.text(), 0)[0]
        if state == QRegExpValidator.Acceptable:
            text = 'Valid email'
            color = '#27ae60'  # green
        else:
            text = 'Invalid email !'
            color = '#e67e22'  # orange

        self.valid_text.setStyleSheet('QLabel { color: %s; }' % color)
        self.valid_text.setText(text)

    def accept_text(self):  # pragma: no cover
        """
        Set Edit QDialog to Rejected or Accepted (prevent to patch for nothing)

        """

        state = self.validator.validate(self.line_edit.text(), 0)[0]
        if self.old_text == self.line_edit.text():
            self.reject()
        elif not self.old_text or self.old_text.isspace():
            if not self.line_edit.text() or self.line_edit.text().isspace():
                self.reject()
            else:
                if state == QRegExpValidator.Acceptable:
                    self.accept()
                else:
                    self.reject()
        elif not self.line_edit.text() or self.line_edit.text().isspace():
            self.line_edit.setText('')
            self.accept()
        else:
            if state == QRegExpValidator.Acceptable:
                self.accept()
            else:
                self.reject()