当前位置: 首页>>代码示例>>Python>>正文


Python QtWidgets.QComboBox方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QComboBox方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QComboBox方法的具体用法?Python QtWidgets.QComboBox怎么用?Python QtWidgets.QComboBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets的用法示例。


在下文中一共展示了QtWidgets.QComboBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_input_action

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def add_input_action(self):
        self.inputs_table.setRowCount(self.inputs_table.rowCount()+1)
        i = self.inputs_table.rowCount()-1
        type_combo = QtWidgets.QComboBox()
        type_combo.addItems(["REG", "MEM"])
        action_combo = QtWidgets.QComboBox()
        action_combo.addItems(["DEFAULT", "PATCH", "CONC", "SYMB", "IGNORE"])
        when_combo = QtWidgets.QComboBox()
        when_combo.addItems(["BEFORE", "AFTER"])
        info = [type_combo, QtWidgets.QTableWidgetItem(), QtWidgets.QTableWidgetItem(), QtWidgets.QTableWidgetItem(),
                action_combo, when_combo]

        for col_id, widget in enumerate(info):
            if isinstance(widget, QtWidgets.QTableWidgetItem):
                self.inputs_table.setItem(i, col_id, widget)
            else:
                self.inputs_table.setCellWidget(i, col_id, widget)
        return i 
开发者ID:RobinDavid,项目名称:idasec,代码行数:20,代码来源:AnalysisWidget.py

示例2: getInputValue

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def getInputValue(self, key):
        """
        Get the value of a single input. This is intended to Pythonify the Qt values that come natively
        from the widgets. (ie. return a Python date rather than a QDate).

        This is used internally by getOptions()
        """
        one_input = self.inputs.get(key)
        if one_input:
            if isinstance(one_input, QtWidgets.QDateTimeEdit):
                # DateTime
                return one_input.dateTime().toString(QtCore.Qt.ISODate)
            elif isinstance(one_input, QtWidgets.QAbstractButton):
                # Radio/checkbox button
                return str(one_input.isChecked())
            elif isinstance(one_input, QtWidgets.QComboBox):
                return one_input.currentText()
            elif hasattr(one_input, 'text'):
                return one_input.text()
            raise Exception("Couldn't identify the QWidget type for %s (%s)" % (key, one_input))
        return None 
开发者ID:iris-edu,项目名称:pyweed,代码行数:23,代码来源:OptionsWidget.py

示例3: populate_combo_box

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def populate_combo_box(self):
        def set_toc_position(tocTree):
            currentIndex = tocTree.currentIndex()
            required_position = currentIndex.data(QtCore.Qt.UserRole)
            self.return_focus()
            self.parent.set_content(required_position, True, True)

        # Create the Combobox / Treeview combination
        tocTree = QtWidgets.QTreeView()
        self.tocComboBox.setView(tocTree)
        self.tocComboBox.setModel(self.parent.tocModel)
        tocTree.setRootIsDecorated(False)
        tocTree.setItemsExpandable(False)
        tocTree.expandAll()

        # Set the position of the QComboBox
        self.parent.set_tocBox_index(None, self.tocComboBox)

        # Make clicking do something
        self.tocComboBox.currentIndexChanged.connect(
            lambda: set_toc_position(tocTree)) 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:23,代码来源:dockwidgets.py

示例4: createEditor

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def createEditor(self, parent, option, index):
        '''
        Return QComboBox with list of choices (either values or their associated keys if they exist).
        '''
        try:
            editor = QComboBox(parent)
            value = index.model().data(index, Qt.DisplayRole)
            for i, choice in enumerate(self.choices):
                if (type(choice) is tuple) and (len(choice) == 2):
                    # choice is a (key, value) tuple.
                    key, val = choice
                    editor.addItem(str(key))  # key MUST be representable as a str.
                    if val == value:
                        editor.setCurrentIndex(i)
                else:
                    # choice is a value.
                    editor.addItem(str(choice))  # choice MUST be representable as a str.
                    if choice == value:
                        editor.setCurrentIndex(i)
            return editor
        except:
            return None 
开发者ID:aseylys,项目名称:KStock,代码行数:24,代码来源:ComboBoxDelegateQt.py

示例5: initUI

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def initUI(self):
 
        self.box = QtWidgets.QComboBox(self)

        for i in self.formats:
            self.box.addItem(strftime(i))

        insert = QtWidgets.QPushButton("Insert",self)
        insert.clicked.connect(self.insert)
 
        cancel = QtWidgets.QPushButton("Cancel",self)
        cancel.clicked.connect(self.close)
 
        layout = QtWidgets.QGridLayout()

        layout.addWidget(self.box,0,0,1,2)
        layout.addWidget(insert,1,0)
        layout.addWidget(cancel,1,1)
        
        self.setGeometry(300,300,400,80)
        self.setWindowTitle("Date and Time")
        self.setLayout(layout) 
开发者ID:goldsborough,项目名称:Writer-Tutorial,代码行数:24,代码来源:datetime.py

示例6: get_gui_options

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def get_gui_options(self):
        options = list()

        for name in self.CONTROLS.keys():
            gui_ctrl = self.CONTROLS[name]
            if gui_ctrl.control_enabled.isChecked():
                check_type = gui_ctrl.control_check_type.currentIndex()
                text = None

                if isinstance(gui_ctrl.control_value, QtWidgets.QLineEdit):
                    text = gui_ctrl.control_value.text()
                elif isinstance(gui_ctrl.control_value, QtWidgets.QComboBox):
                    text = gui_ctrl.control_value.currentText()

                options.append(gui_selection(name, check_type, text))

        return options 
开发者ID:yarox24,项目名称:attack_monitor,代码行数:19,代码来源:exception_dialog.py

示例7: _layout_widget_preferences_general

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def _layout_widget_preferences_general(self):
        """
        Create general options widget.
        """
        tab = QtWidgets.QWidget()
        tab_layout = QtWidgets.QVBoxLayout(tab)

        # language
        label = QtWidgets.QLabel('Choose')
        combobox = QtWidgets.QComboBox()
        tab_layout.addWidget(qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, combobox)), 'User Interface Language'))

        # vertical stretch
        tab_layout.addStretch()

        # add tab
        self.tab_general = tab
        self.stacked_layout.addWidget(tab) 
开发者ID:Trilarion,项目名称:imperialism-remake,代码行数:20,代码来源:preferences.py

示例8: createEditor

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def createEditor(self, parent,    # pylint:disable=C0103
                     option, index):  # pylint:disable=W0613
        """Return a panel to change selected preset."""

        dropdown = QtWidgets.QComboBox()
        dropdown.addItem("(select preset)")
        dropdown.addItems(self._presets)

        hor = QtWidgets.QHBoxLayout()
        hor.addWidget(dropdown)

        panel = QtWidgets.QWidget(parent)
        panel.setObjectName('editor')
        panel.setAutoFillBackground(True)
        panel.setFocusPolicy(QtCore.Qt.StrongFocus)
        panel.setLayout(hor)
        return panel 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:19,代码来源:listviews.py

示例9: _disable_inputs

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def _disable_inputs(self, flag=True):
        """
        Mass disable (or enable if flag is False) all inputs, except the
        cancel button.
        """

        for widget in (
                widget
                for widget in self.findChildren(self._INPUT_WIDGETS)
                if widget.objectName() != 'cancel'
                and (not isinstance(widget, QtWidgets.QComboBox) or
                     len(widget) > 1)
        ):
            widget.setDisabled(flag)

        if not flag:
            self.findChild(QtWidgets.QPushButton, 'presets_delete').setEnabled(
                self.findChild(QtWidgets.QComboBox,
                               'presets_dropdown').currentIndex() > 0
            )
            self.findChild(QtWidgets.QPushButton, 'presets_save').setEnabled(
                self.findChild(QtWidgets.QComboBox,
                               'service').currentIndex() < self._svc_count
            ) 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:26,代码来源:base.py

示例10: _get_service_values

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def _get_service_values(self):
        """
        Return the service ID and a dict of all the options.
        """

        dropdown = self.findChild(QtWidgets.QComboBox, 'service')
        idx = dropdown.currentIndex()
        svc_id = dropdown.itemData(idx)
        if svc_id.startswith('group:'):
            return svc_id, None

        vinputs = self.findChild(QtWidgets.QStackedWidget, 'panels') \
            .widget(idx).findChildren(self._OPTIONS_WIDGETS)
        options = self._addon.router.get_options(svc_id)

        assert len(options) == len(vinputs)

        return svc_id, {
            options[i]['key']:
                vinputs[i].value()
                if isinstance(vinputs[i], QtWidgets.QAbstractSpinBox)
                else vinputs[i].itemData(vinputs[i].currentIndex())
            for i in range(len(options))
        } 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:26,代码来源:base.py

示例11: _on_refresh

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def _on_refresh(self, select=None):
        """Repopulate the group dropdown and initialize panel."""

        groups = self.findChild(QtWidgets.QComboBox, 'groups')
        groups.clear()
        groups.addItem("View/Edit Group...")

        if self._groups:
            groups.setEnabled(True)
            groups.insertSeparator(1)
            groups.addItems(sorted(self._groups.keys(),
                                   key=lambda name: name.upper()))
            if select:
                idx = groups.findText(select)
                groups.setCurrentIndex(idx)
                self._on_group_activated(idx)
            else:
                self._on_group_activated(0)

        else:
            groups.setEnabled(False)
            self._on_group_activated(0) 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:24,代码来源:groups.py

示例12: show

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def show(self, *args, **kwargs):
        """
        Restore the three dropdown's last known state and then focus the
        field dropdown.
        """

        super(Templater, self).show(*args, **kwargs)

        for name in ['hide', 'target', 'field']:
            dropdown = self.findChild(QtWidgets.QComboBox, name)
            dropdown.setCurrentIndex(max(
                dropdown.findData(self._addon.config['templater_' + name]), 0
            ))

        if self._is_cloze:
            self.findChild(Checkbox, 'cloze') \
                .setChecked(self._addon.config['templater_cloze'])

        dropdown.setFocus()  # abuses fact that 'field' is last in the loop 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:21,代码来源:templater.py

示例13: _get_all

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def _get_all(self):
        """
        Adds support to remember the three dropdowns and cloze state (if any),
        in addition to the service options handled by the superclass.
        """

        combos = {
            name: widget.itemData(widget.currentIndex())
            for name in ['field', 'hide', 'target']
            for widget in [self.findChild(QtWidgets.QComboBox, name)]
        }

        return dict(
            list(super(Templater, self)._get_all().items()) +
            [('templater_' + name, value) for name, value in combos.items()] +
            (
                [(
                    'templater_cloze',
                    self.findChild(Checkbox, 'cloze').isChecked(),
                )]
                if self._is_cloze and combos['field']
                else []
            )
        ) 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:26,代码来源:templater.py

示例14: accept

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def accept(self):
        """Saves state on inputs; rough opposite of show()."""

        for list_view in self.findChildren(QtWidgets.QListView):
            for editor in list_view.findChildren(QtWidgets.QWidget, 'editor'):
                list_view.commitData(editor)  # if an editor is open, save it

        self._addon.config.update({
            widget.objectName(): (
                widget.isChecked() if isinstance(widget, Checkbox)
                else widget.atts_value if isinstance(widget, QtWidgets.QPushButton)
                else widget.value() if isinstance(widget, QtWidgets.QSpinBox)
                else widget.itemData(widget.currentIndex()) if isinstance(
                    widget, QtWidgets.QComboBox)
                else [
                    i for i in widget.model().raw_data
                    if i['compiled'] and 'bad_replace' not in i
                ] if isinstance(widget, QtWidgets.QListView)
                else widget.text()
            )
            for widget in self.findChildren(self._PROPERTY_WIDGETS)
            if widget.objectName() in self._PROPERTY_KEYS
        })

        super(Configurator, self).accept() 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:27,代码来源:configurator.py

示例15: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QComboBox [as 别名]
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.setLayout(QVBoxLayout())
        self.layout().setAlignment(Qt.AlignTop)

        self.functionGroup = QGroupBox(self)
        self.functionGroup.setTitle(translate('PresetSrcSettings', 'Presets'))
        self.functionGroup.setLayout(QVBoxLayout())
        self.layout().addWidget(self.functionGroup)

        self.functionCombo = QComboBox(self.functionGroup)
        self.functionGroup.layout().addWidget(self.functionCombo)

        for function in sorted(PresetSrc.PRESETS.keys()):
            self.functionCombo.addItem(function)

        self.functionDuration = QTimeEdit(self.functionGroup)
        self.functionDuration.setDisplayFormat('HH.mm.ss.zzz')
        self.functionGroup.layout().addWidget(self.functionDuration) 
开发者ID:FrancescoCeruti,项目名称:linux-show-player,代码行数:21,代码来源:preset_src.py


注:本文中的PyQt5.QtWidgets.QComboBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。