當前位置: 首頁>>代碼示例>>Python>>正文


Python QLineEdit.setChecked方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setChecked方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setChecked方法的具體用法?Python QLineEdit.setChecked怎麽用?Python QLineEdit.setChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QLineEdit的用法示例。


在下文中一共展示了QLineEdit.setChecked方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ConfigParamEditWindow

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setChecked [as 別名]
class ConfigParamEditWindow(QDialog):
    def __init__(self, parent, model, cli_iface, store_callback):
        super(ConfigParamEditWindow, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle('Edit Parameter')
        self.setModal(True)

        self._model = model
        self._cli_iface = cli_iface
        self._store_callback = store_callback

        name_label = QLabel(model.name, self)
        name_label.setFont(get_monospace_font())

        if model.type is bool:
            self._value = QCheckBox(self)
            self._value.setChecked(model.value)
        elif model.type is int:
            self._value = QSpinBox(self)
            if model.minimum is not None:
                self._value.setRange(model.minimum,
                                     model.maximum)
            else:
                self._value.setRange(-0x80000000,
                                     +0x7FFFFFFF)
            self._value.setValue(model.value)
        elif model.type is float:
            self._value = QDoubleSpinBox(self)
            if model.minimum is not None:
                self._value.setRange(model.minimum,
                                     model.maximum)
            else:
                self._value.setRange(-3.4028235e+38,
                                     +3.4028235e+38)
            self._value.setValue(model.value)
        elif model.type is str:
            self._value = QLineEdit(self)
            self._value.setText(model.value)
        else:
            raise ValueError('Unsupported value type %r' % model.type)

        self._ok_button = make_icon_button('check', 'Send changes to the device', self,
                                           text='OK', on_clicked=self._do_ok)

        self._cancel_button = make_icon_button('remove', 'Discard changes and close this window', self,
                                               text='Cancel', on_clicked=self.close)

        layout = QVBoxLayout(self)

        value_layout = QHBoxLayout(self)
        value_layout.addWidget(name_label)
        value_layout.addWidget(self._value, 1)

        controls_layout = QHBoxLayout(self)
        controls_layout.addWidget(self._cancel_button)
        controls_layout.addWidget(self._ok_button)

        layout.addLayout(value_layout)
        layout.addLayout(controls_layout)
        self.setLayout(layout)

    def _do_ok(self):
        if self._model.type is bool:
            value = self._value.isChecked()
        elif self._model.type is int or self._model.type is float:
            value = self._value.value()
        else:
            value = self._value.text()

        self._store_callback(value)
        self.close()
開發者ID:UAVCAN,項目名稱:gui_tool,代碼行數:73,代碼來源:slcan_cli.py

示例2: ConfigParamEditWindow

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setChecked [as 別名]
class ConfigParamEditWindow(QDialog):
    def __init__(self, parent, node, target_node_id, param_struct, update_callback):
        super(ConfigParamEditWindow, self).__init__(parent)
        self.setWindowTitle("Edit configuration parameter")
        self.setModal(True)

        self._node = node
        self._target_node_id = target_node_id
        self._param_struct = param_struct
        self._update_callback = update_callback

        min_val = get_union_value(param_struct.min_value)
        if "uavcan.protocol.param.Empty" in str(min_val):
            min_val = None

        max_val = get_union_value(param_struct.max_value)
        if "uavcan.protocol.param.Empty" in str(max_val):
            max_val = None

        value = get_union_value(param_struct.value)
        self._value_widget = None
        value_type = uavcan.get_active_union_field(param_struct.value)

        if value_type == "integer_value":
            min_val = min_val if min_val is not None else -0x8000000000000000
            max_val = max_val if max_val is not None else 0x7FFFFFFFFFFFFFFF
            if min_val >= -0x80000000 and max_val <= +0x7FFFFFFF:
                self._value_widget = QSpinBox(self)
                self._value_widget.setMaximum(max_val)
                self._value_widget.setMinimum(min_val)
                self._value_widget.setValue(value)
        if value_type == "real_value":
            min_val = round_float(min_val) if min_val is not None else -3.4028235e38
            max_val = round_float(max_val) if max_val is not None else 3.4028235e38
            value = round_float(value)
        if value_type == "boolean_value":
            self._value_widget = QCheckBox(self)
            self._value_widget.setChecked(bool(value))

        if self._value_widget is None:
            self._value_widget = QLineEdit(self)
            self._value_widget.setText(str(value))
        self._value_widget.setFont(get_monospace_font())

        layout = QGridLayout(self)

        def add_const_field(label, *values):
            row = layout.rowCount()
            layout.addWidget(QLabel(label, self), row, 0)
            if len(values) == 1:
                layout.addWidget(FieldValueWidget(self, values[0]), row, 1)
            else:
                sub_layout = QHBoxLayout(self)
                for idx, v in enumerate(values):
                    sub_layout.addWidget(FieldValueWidget(self, v))
                layout.addLayout(sub_layout, row, 1)

        add_const_field("Name", param_struct.name)
        add_const_field("Type", uavcan.get_active_union_field(param_struct.value).replace("_value", ""))
        add_const_field("Min/Max", min_val, max_val)
        add_const_field("Default", render_union(param_struct.default_value))

        layout.addWidget(QLabel("Value", self), layout.rowCount(), 0)
        layout.addWidget(self._value_widget, layout.rowCount() - 1, 1)

        fetch_button = make_icon_button(
            "refresh", "Read parameter from the node", self, text="Fetch", on_clicked=self._do_fetch
        )
        set_default_button = make_icon_button(
            "fire-extinguisher", "Restore default value", self, text="Restore", on_clicked=self._restore_default
        )
        send_button = make_icon_button(
            "flash", "Send parameter to the node", self, text="Send", on_clicked=self._do_send
        )
        cancel_button = make_icon_button(
            "remove", "Close this window; unsent changes will be lost", self, text="Cancel", on_clicked=self.close
        )

        controls_layout = QGridLayout(self)
        controls_layout.addWidget(fetch_button, 0, 0)
        controls_layout.addWidget(send_button, 0, 1)
        controls_layout.addWidget(set_default_button, 1, 0)
        controls_layout.addWidget(cancel_button, 1, 1)
        layout.addLayout(controls_layout, layout.rowCount(), 0, 1, 2)

        self._status_bar = QStatusBar(self)
        self._status_bar.setSizeGripEnabled(False)
        layout.addWidget(self._status_bar, layout.rowCount(), 0, 1, 2)

        left, top, right, bottom = layout.getContentsMargins()
        bottom = 0
        layout.setContentsMargins(left, top, right, bottom)

        self.setLayout(layout)

    def show_message(self, text, *fmt):
        self._status_bar.showMessage(text % fmt)

    def _assign(self, value_union):
        value = get_union_value(value_union)
#.........這裏部分代碼省略.........
開發者ID:UAVCAN,項目名稱:gui_tool,代碼行數:103,代碼來源:node_properties.py

示例3: showEvent

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setChecked [as 別名]
    def showEvent(self, *args, **kwargs):
        startup_config = self.cfg

        self.clear_layout(self.formSimple)
        self.clear_layout(self.formAdvance)
        self.configuration_inputs.clear()

        self.setWindowTitle("Create Plugin " + self.plugin_name)

        position = 0

        if 'uname' in startup_config.keys():
            value = startup_config['uname']['value']

            display_text = 'uname'

            if 'display_text' in startup_config['uname'].keys():
                display_text = startup_config['uname']['display_text']

            uname = self.gui_api.do_change_string_to_be_uname(self.plugin_name)
            uname = self.gui_api.change_uname_to_uniqe(uname)


            editable_field = QLineEdit(str(value))
            editable_field.setText(uname)
            editable_field.setObjectName('uname' + "_line_edit")

            self.formSimple.addRow(str(display_text) , editable_field)

            self.configuration_inputs['uname'] = editable_field

            #line_edit.selectAll()
            #line_edit.setFocus()

            position += 1

        if 'tab' in startup_config.keys():
            value = startup_config['tab']['value']

            display_text = 'Tab'

            if 'display_text' in startup_config['tab'].keys():
                display_text = startup_config['tab']['display_text']

            #uname = self.gui_api.do_change_string_to_be_uname(self.plugin_name)
            #uname = self.gui_api.change_uname_to_uniqe(uname)


            editable_field = QComboBox()
            tabs = list(self.TabManager.get_tabs_by_uname().keys())
            if len(tabs) == 0:
                tabs = [GUI_DEFAULT_TAB]
            tabs.sort(key=str.lower)
            editable_field.addItems(tabs)
            editable_field.setObjectName('Tab' + "_comboBox")

            self.formSimple.addRow(str(display_text) , editable_field)

            self.configuration_inputs['tab'] = editable_field


            #line_edit.selectAll()
            #line_edit.setFocus()

            position += 1

        startup_config_sorted = sorted(startup_config.items(), key=operator.itemgetter(0))

        for attr in startup_config_sorted:
            attr = attr[0]
            if attr != 'uname' and attr !='tab':
                value = startup_config[attr]['value']

                display_text = attr

                if 'display_text' in startup_config[attr].keys():
                    display_text = startup_config[attr]['display_text']


                # -------------------------------
                # Check for datatype
                # -------------------------------

                editable_field = None

                if 'type' in startup_config[attr]:
                    parameter_type = startup_config[attr]['type']

                    if parameter_type == 'bool':
                        editable_field = QCheckBox()

                        if value == '1':
                            editable_field.setChecked(True)
                        else:
                            editable_field.setChecked(False)

                    if parameter_type == 'file':
                        editable_field = FileLineEdit()
                        editable_field.setReadOnly(True)
                        editable_field.setText(value)
#.........這裏部分代碼省略.........
開發者ID:dani-l,項目名稱:PaPI,代碼行數:103,代碼來源:create_plugin_dialog.py

示例4: showEvent

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setChecked [as 別名]
    def showEvent(self, *args, **kwargs):
        """
        This function is called before the dialog is displayed.

        :param args:
        :param kwargs:
        :return:
        """
        startup_config = self.cfg

        for form in self.advancedForms:
            self.clear_layout(self.advancedForms[form])

        self.configuration_inputs.clear()

        self.setWindowTitle("Create Plugin " + self.plugin_name)

        position = 0

        if 'uname' in startup_config.keys():
            value = startup_config['uname']['value']

            display_text = 'Unique name'

            if 'display_text' in startup_config['uname'].keys():
                display_text = startup_config['uname']['display_text']

            uname = self.gui_api.do_change_string_to_be_uname(self.plugin_name)
            uname = self.gui_api.change_uname_to_uniqe(uname)

            editable_field = QLineEdit(str(value))
            editable_field.setText(uname)
            editable_field.setObjectName('uname' + "_line_edit")
            editable_field.setToolTip('Name as identifier in PaPI. Must be UNIQUE')

            form_name = 'PaPI -mandatory'
            if form_name not in self.advancedForms:
                self.advancedForms[form_name] = QFormLayout()
                tab_widget = QWidget()

                self.tabWidget.addTab(tab_widget, form_name)
                vlayout = QVBoxLayout(tab_widget)
                vlayout.addLayout(self.advancedForms[form_name])

            self.advancedForms[form_name].addRow(str(display_text), editable_field)

            self.configuration_inputs['uname'] = editable_field

            position += 1

        startup_config_sorted = startup_config.items()
        if not isinstance(startup_config, collections.OrderedDict):
            startup_config_sorted = sorted(startup_config.items(), key=operator.itemgetter(0))

        for attr in startup_config_sorted:
            attr = attr[0]
            if attr != 'uname':
                value = startup_config[attr]['value']

                display_text = attr

                if 'display_text' in startup_config[attr].keys():
                    display_text = startup_config[attr]['display_text']

                # -------------------------------
                # Check for datatype
                # -------------------------------

                editable_field = None

                if attr != 'tab':

                    if 'type' in startup_config[attr]:
                        parameter_type = startup_config[attr]['type']

                        if parameter_type == 'bool':
                            editable_field = QCheckBox()

                            if value == '1':
                                editable_field.setChecked(True)
                            else:
                                editable_field.setChecked(False)

                        if parameter_type == 'file':
                            editable_field = FileLineEdit()
                            editable_field.setReadOnly(True)
                            editable_field.setText(value)

                        if parameter_type == 'color':
                            editable_field = ColorLineEdit()
                            editable_field.set_default_color(startup_config[attr]['value'])
                            #
                            # editable_field.setText(value)

                    else:
                        editable_field = QLineEdit()

                        editable_field.setText(str(value))
                        editable_field.setObjectName(attr + "_line_edit")

#.........這裏部分代碼省略.........
開發者ID:TUB-Control,項目名稱:PaPI,代碼行數:103,代碼來源:CreatePluginDialog.py


注:本文中的PyQt5.QtWidgets.QLineEdit.setChecked方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。