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


Python QComboBox.count方法代码示例

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


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

示例1: GeometryWizardPage

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import count [as 别名]
class GeometryWizardPage(_ExpandableOptionsWizardPage):

    def __init__(self, options, parent=None):
        _ExpandableOptionsWizardPage.__init__(self, options, parent)
        self.setTitle('Geometry')

    def _initUI(self):
        # Variables
        self._widgets = {}

        # Widgets
        self._cb_geometry = QComboBox()

        self._wdg_geometry = QStackedWidget()
        policy = self._wdg_geometry.sizePolicy()
        policy.setVerticalStretch(True)
        self._wdg_geometry.setSizePolicy(policy)

        # Layouts
        layout = _ExpandableOptionsWizardPage._initUI(self)
        layout.addRow("Type of geometry", self._cb_geometry)
        layout.addRow(self._wdg_geometry)

        # Signals
        self._cb_geometry.currentIndexChanged.connect(self._onGeometryChanged)
        self._cb_geometry.currentIndexChanged.connect(self.valueChanged)

        return layout

    def _onGeometryChanged(self):
        newindex = self._cb_geometry.currentIndex()
        oldwidget = self._wdg_geometry.currentWidget()
        newwidget = self._wdg_geometry.widget(newindex)
        if newwidget is None:
            return

        try:
            newwidget.setValue(oldwidget.value())
        except:
            newwidget.setValue(self.options().geometry)

        self._wdg_geometry.setCurrentIndex(newindex)

        # See https://qt-project.org/faq/answer/how_can_i_get_a_qstackedwidget_to_automatically_switch_size_depending_on_th
        oldwidget.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        newwidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self._wdg_geometry.adjustSize()

    def _find_material_class(self, programs):
        highest_class = Material

        for program in programs:
            converter = program.converter_class
            for clasz in converter.MATERIALS:
                if issubclass(clasz, highest_class):
                    highest_class = clasz

        return highest_class

    def initializePage(self):
        _ExpandableOptionsWizardPage.initializePage(self)

        # Clear
        self._widgets.clear()
        for i in reversed(range(self._cb_geometry.count())):
            self._cb_geometry.removeItem(i)
            self._wdg_geometry.removeWidget(self._wdg_geometry.widget(i))

        # Populate combo box
        it = self._iter_widgets('pymontecarlo.ui.gui.options.geometry',
                                'GEOMETRIES')
        for clasz, widget_class, programs in it:
            widget = widget_class()
            widget.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
            widget.setMaterialClass(self._find_material_class(programs))

            self._widgets[clasz] = widget

            program_text = ', '.join(map(attrgetter('name'), programs))
            text = '{0} ({1})'.format(widget.accessibleName(), program_text)
            self._cb_geometry.addItem(text)
            self._wdg_geometry.addWidget(widget)

            widget.valueChanged.connect(self.valueChanged)

        # Select geometry
        geometry = self.options().geometry

        widget = self._widgets.get(geometry.__class__)
        if widget is None:
            widget = next(iter(self._widgets.values()))

        widget.setValue(geometry)
        self._wdg_geometry.setCurrentWidget(widget)
        self._cb_geometry.setCurrentIndex(self._wdg_geometry.currentIndex())

    def validatePage(self):
        if not self._wdg_geometry.currentWidget().hasAcceptableInput():
            return False

#.........这里部分代码省略.........
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:103,代码来源:geometry.py

示例2: ToolOther

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import count [as 别名]
class ToolOther(QtGui.QWidget):
    def __init__(self, parent, ClientObj):
        QtGui.QWidget.__init__(self, parent)
        self.user_config = ClientObj.user_config
        self._parent = parent

        self.grid = QtGui.QGridLayout(self)

        self.grid.setContentsMargins(2, 2, 2, 2)
        self.grid.setSpacing(2)
        self.grid.setColumnStretch(0, 3)
        self.grid.setColumnStretch(1, 5)

        # lang settings
        self.lang_lbl = LabelWordWrap(_("Select Language"), self)
        self.lang_lbl.setMaximumWidth(self.lang_lbl.sizeHint().width())

        self.lang_ComboBox = QComboBox(self)
        lang_dict = {"en": _("English"), "ru": _("Russian"), "fr": _("French")}

        for lang in lang_dict:
            self.lang_ComboBox.addItem(lang_dict[lang])
            self.lang_ComboBox.setItemData(self.lang_ComboBox.count() - 1, lang)
            if ClientObj.lang == lang:
                self.lang_ComboBox.setCurrentIndex(self.lang_ComboBox.count() - 1)

        # add lang settings in grid
        self.grid.addWidget(self.lang_lbl, 0, 0)
        self.grid.addWidget(self.lang_ComboBox, 0, 1)

        # add open file in grid
        self.cert_path_lbl = LabelWordWrap(_("Path to Certificates"), self)
        self.cert_path_lbl.setMaximumWidth(self.cert_path_lbl.sizeHint().width())

        self.fd_cert = FileOpenWgt(self, "dir", _("Certificate Directory"), "~/.calculate")

        self.fd_cert.setToolTip(_("Empty to default path"))
        self.fd_cert.setText(ClientObj.path_to_cert)

        self.grid.addWidget(self.cert_path_lbl, 1, 0)
        self.grid.addWidget(self.fd_cert, 1, 1)

        #        # add timeout in grid
        #        self.timeout_lbl = LabelWordWrap(_('Timeout'), self)
        #        self.timeout_lbl.setMaximumWidth(self.timeout_lbl.sizeHint().width())
        #
        #        self.timeout_lineedit = QtGui.QLineEdit(self)
        #
        #        self.timeout_lineedit.setText(str(ClientObj.timeout))
        #
        #        self.grid.addWidget(self.timeout_lbl, 2, 0)
        #        self.grid.addWidget(self.timeout_lineedit, 2, 1)

        # add spacer
        self.grid.addItem(QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 5, 0, 1, 2)

        # connect all with change value slot
        self.lang_ComboBox.currentIndexChanged.connect(self.changed_val)
        self.fd_cert.textChanged.connect(self.changed_val)
        #        self.timeout_lineedit.textChanged.connect(self.changed_val)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

    def changed_val(self):
        self._parent.changed_flag = True

    def check_cfg(self, flag, config, part, param, value):
        # if param not exists in config
        if not flag:
            part_flag = False
            temp_cfg = []
            for line in config:
                temp_cfg.append(line)
                # add new line in config
                if line.startswith(part):
                    temp_cfg.append("%s = %s\n" % (param, value))
                    part_flag = True

            config = temp_cfg
            # if part not exists
            if not part_flag:
                config.append("\n")
                config.append("%s\n" % part)
                config.append("%s = %s\n" % (param, value))
        return config

    def save_changes(self, ClientObj):
        def wrapper():
            if not os.path.isfile(self.user_config):
                f = open(self.user_config, "w")
                f.close()

            fc = open(self.user_config, "r")
            config = fc.readlines()
            fc.close()
            new_config = []

            lang_flag = False
            cert_flag = False
            #            timeout_flag = False
#.........这里部分代码省略.........
开发者ID:nocl,项目名称:calculate-3-console-gui,代码行数:103,代码来源:tools.py

示例3: MainWindow

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import count [as 别名]

#.........这里部分代码省略.........
            self.username_edit.setVisible(True)
            self.strength_label.setVisible(True)
            self.strength_selector.setVisible(True)
            self.password_label.setVisible(True)
            self.password.setVisible(True)
        else:
            self.username_label.setVisible(False)
            self.username_edit.setVisible(False)
            self.strength_label.setVisible(False)
            self.strength_selector.setVisible(False)
            self.password_label.setVisible(False)
            self.password.setVisible(False)
            self.clipboard_button.setVisible(False)

    def domain_changed(self):
        self.setting_dirty = True
        self.password.setText("")
        self.clipboard_button.setVisible(False)
        self.set_visibilities()
        if self.kgk_manager.has_kgk() and (not self.decrypt_kgk_task or not self.decrypt_kgk_task.is_running()) and \
           len(self.domain_edit.lineEdit().text()) > 0 and \
           self.domain_edit.lineEdit().text() in self.settings_manager.get_domain_list():
            self.domain_entered()

    def domain_entered(self):
        self.setting_dirty = self.domain_edit.lineEdit().text() not in self.settings_manager.get_domain_list()
        self.setting = self.settings_manager.get_setting(self.domain_edit.lineEdit().text())
        self.username_edit.blockSignals(True)
        self.username_edit.setText(self.setting.get_username())
        self.username_edit.blockSignals(False)
        self.strength_selector.blockSignals(True)
        self.strength_selector.set_length(self.setting.get_length())
        self.strength_selector.set_complexity(self.setting.get_complexity())
        self.strength_selector.set_extra_count(len(self.setting.get_extra_character_set()))
        self.strength_selector.blockSignals(False)
        self.generate_password()

    def move_focus(self):
        line_edits = [self.master_password_edit, self.domain_edit, self.username_edit]
        for i, edit in enumerate(line_edits):
            if edit.hasFocus() and i + 1 < len(line_edits):
                line_edits[i + 1].setFocus()
                return True
        self.generate_button.setFocus()

    def generate_password(self):
        if not self.kgk_manager.has_kgk():
            self.kgk_manager.create_new_kgk()
            self.kgk_manager.create_and_save_new_kgk_block()
        if not self.kgk_manager.kgk_crypter or not self.kgk_manager.salt:
            self.kgk_manager.get_kgk_crypter(self.master_password_edit.text().encode('utf-8'),
                                             self.kgk_manager.get_kgk_crypter_salt())
        if self.setting_dirty:
            self.setting.new_salt()
            self.setting.calculate_template()
        self.settings_manager.set_setting(self.setting)
        if not self.setting.get_legacy_password():
            generator = CtSesam(self.setting.get_domain(),
                                self.setting.get_username(),
                                self.kgk_manager.get_kgk(),
                                self.setting.get_salt(),
                                self.setting.get_iterations())
            password = generator.generate(self.setting)
        else:
            password = self.setting.get_legacy_password()
        self.password.setText(password)
开发者ID:pinae,项目名称:ctSESAM-pyside,代码行数:70,代码来源:ctSESAM.py

示例4: BeamWizardPage

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import count [as 别名]
class BeamWizardPage(_ExpandableOptionsWizardPage):
    def __init__(self, options, parent=None):
        _ExpandableOptionsWizardPage.__init__(self, options, parent)
        self.setTitle("Beam")

    def _initUI(self):
        # Variables
        self._widgets = {}

        # Widgets
        self._cb_beam = QComboBox()
        self._wdg_beam = QStackedWidget()

        # Layouts
        layout = _ExpandableOptionsWizardPage._initUI(self)
        layout.addRow("Type of beam", self._cb_beam)
        layout.addRow(self._wdg_beam)

        # Signals
        self._cb_beam.currentIndexChanged.connect(self._onBeamChanged)
        self._cb_beam.currentIndexChanged.connect(self.valueChanged)

        return layout

    def _onBeamChanged(self):
        newindex = self._cb_beam.currentIndex()
        oldwidget = self._wdg_beam.currentWidget()
        newwidget = self._wdg_beam.widget(newindex)
        if newwidget is None:
            return

        try:
            newwidget.setValue(oldwidget.value())
        except:
            newwidget.setValue(self.options().beam)

        self._wdg_beam.setCurrentIndex(newindex)

    def initializePage(self):
        _ExpandableOptionsWizardPage.initializePage(self)

        # Clear
        self._widgets.clear()
        for i in reversed(range(self._cb_beam.count())):
            self._cb_beam.removeItem(i)
            self._wdg_beam.removeWidget(self._wdg_beam.widget(i))

        # Populate combo box
        it = self._iter_widgets("pymontecarlo.ui.gui.options.beam", "BEAMS")
        for clasz, widget_class, programs in it:
            widget = widget_class()
            self._widgets[clasz] = widget

            program_text = ", ".join(map(attrgetter("name"), programs))
            text = "{0} ({1})".format(widget.accessibleName(), program_text)
            self._cb_beam.addItem(text)
            self._wdg_beam.addWidget(widget)

            widget.setParticlesEnabled(False)
            for program in programs:
                converter = program.converter_class
                for particle in converter.PARTICLES:
                    widget.setParticleEnabled(particle, True)

            widget.valueChanged.connect(self.valueChanged)

        # Select beam
        beam = self.options().beam

        widget = self._widgets.get(beam.__class__)
        if widget is None:
            widget = next(iter(self._widgets.values()))

        widget.setValue(beam)

        self._wdg_beam.setCurrentWidget(widget)
        self._cb_beam.setCurrentIndex(self._wdg_beam.currentIndex())

    def validatePage(self):
        if not self._wdg_beam.currentWidget().hasAcceptableInput():
            return False

        self.options().beam = self._wdg_beam.currentWidget().value()

        return True

    def expandCount(self):
        try:
            return len(expand(self._wdg_beam.currentWidget().value()))
        except:
            return 0
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:93,代码来源:beam.py

示例5: Dialog

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import count [as 别名]
class Dialog(QWidget):

    def __init__(self, parent=None):
        super(Dialog, self).__init__(parent)
        self.setupUI()
        self.setupConnection()
        self.threadPool = []
        self.totalUids = 0
        self.finishedThreadNum = 0
        self.realThreadNum = 0
        self.excel = Excel()
        #self.initSearchDb()

    def setupUI(self):

        self.pushButton = QPushButton(u"Search", self)
        #self.testButton = QPushButton(u"Test", self)
        self.lineEdit = QLineEdit(self)
        self.textEdit = QTextEdit(self)
        self.comboBox = QComboBox(self)
        self.label = QLabel(u"DB:", self)
        self.progressBar = QProgressBar(self)
        self.progressBar.setRange(0,1)
        
        self.textEdit.setReadOnly(True)

        self.layout = QVBoxLayout()
        self.topLayout = QHBoxLayout()
        
        self.topLayout.addWidget(self.label)
        self.topLayout.addWidget(self.comboBox)
        self.topLayout.addWidget(self.lineEdit)
        self.topLayout.addWidget(self.pushButton)
        #self.topLayout.addWidget(self.testButton)

        #self.testButton.clicked.connect(self.onTestButtonClicked)

        self.layout.addLayout(self.topLayout)
        self.layout.addWidget(self.textEdit)
        self.layout.addWidget(self.progressBar)

        self.setLayout(self.layout)

        self.resize(600, 700)
        self.setWindowTitle(u"Search Data for NCBI")

    def setupConnection(self):
        self.pushButton.clicked.connect(self.onButtonClicked)

    def onButtonClicked(self):
        if not self.lineEdit.text() or not self.comboBox.count():
            QtGui.QMessageBox.information(self, u"Warning", u"Please Set the Search Field")
            return
        # disable button
        self.pushButton.setDisabled(True)
        dbName = self.comboBox.currentText()
        fieldName = self.lineEdit.text()
        self.log("Start searching db: %s and field: %s" % (dbName, fieldName))
        # add use history to add all uids to the history server
        handle = self.entrez.esearch(db=dbName, term=fieldName, usehistory='y')
        record = self.entrez.read(handle)
        self.log("All result count %s" % record['Count'])
        self.totalUids = int(record['Count'])
        # to get onnly data less than the MAX_COUNT
        if self.totalUids > MAX_COUNT:
            ret = QtGui.QMessageBox.question(
                    self,
                    u'Warning',
                    u'result count %s is too large, will only get the %s result \
                            continue?' % (self.totalUids, MAX_COUNT),
                            QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel
                            )
            if ret == QtGui.QMessageBox.Ok:
                self.totalUids = MAX_COUNT
            else:
                return
        #handle = self.entrez.efetch(db=dbName, id=record['IdList'], rettype='gb')
        self.finishedThreadNum = 0
        WebEnv = record['WebEnv']
        QueryKey = record['QueryKey']
        global FINISHED_COUNT
        FINISHED_COUNT = 0
        self.progressBar.setValue(0)
        self.progressBar.setMaximum(self.totalUids)
        if self.totalUids / RET_MAX_SUMMARY >= MAX_THREAD:
            self.realThreadNum = MAX_THREAD
            each_count = self.totalUids/MAX_THREAD
            startIndex = 0
            for i in range(MAX_THREAD - 1):
                thread = MyThread(startIndex, each_count, dbName, fieldName, WebEnv, QueryKey)
                thread.finished.connect(self.onThreadFinished)
                thread.finishedCountChanged.connect(self.onFinishedCountChange)
                thread.start()
                self.threadPool.append(thread)
                startIndex = startIndex + each_count
            thread = MyThread(startIndex, (self.totalUids-startIndex+1), dbName, fieldName, WebEnv, QueryKey)
            thread.finished.connect(self.onThreadFinished)
            thread.finishedCountChanged.connect(self.onFinishedCountChange)
            self.threadPool.append(thread)
            thread.start()
#.........这里部分代码省略.........
开发者ID:ypvk,项目名称:python_search_ncbi,代码行数:103,代码来源:search_gui.py

示例6: ConsoleWidget

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import count [as 别名]

#.........这里部分代码省略.........
    def query(self, sql):
        if not self._connection:
            self.logEdit.appendPlainText('No connection')
            return None

        try:
            query = self._connection.NewObject('Query', sql)
            result = query.Execute()
        except Exception as e:
            self.logEdit.appendPlainText(str(e))
            return None

        return result

    def refresh(self, result):
        self.model.clear()

        columns = list()
        result_columns = result.Columns
        for index in range(result_columns.Count()):
            name = result_columns.Get(index).Name
            columns.append(name)

        self.model.setColumnCount(len(columns))
        for section, name in enumerate(columns):
            self.model.setHeaderData(section, Qt.Horizontal, name)

        select = result.Choose()
        self.logEdit.appendPlainText('Selected %d records' % select.Count())
        while select.Next():
            items = list()
            for index in range(len(columns)):
                value = select.Get(index)

                item = QStandardItem('')
                if isinstance(value, bool):
                    item.setText(value and 'Yes' or 'No')

                elif isinstance(value, (int, str)):
                    item.setText(str(value))

                elif isinstance(value, datetime.datetime):
                    item.setText(value.strftime('%Y.%m.%d %H:%M:%S'))

                else:
                    item.setText(str(value))
                items.append(item)

            self.model.appendRow(items)

    @Slot()
    def executeQuery(self):
        sql = self.sqlEdit.toPlainText()
        result = self.query(sql)
        if result:
            path = os.path.join(self._home, 'last-sql.txt')
            open(path, 'w').write(sql)
            self.refresh(result)

    @Slot()
    def connectOneS(self):
        uri = self.connectionUriCombo.currentText().strip()
        if not uri:
            self.logEdit.appendPlainText('Need a connection string')
            return

        version = self.onesVersionCombo.currentText()
        comName = "V%s.COMConnector" % str(version).replace('.', '')

        pythoncom.CoInitialize()
        try:
            obj = win32com.client.Dispatch(comName)
            self._connection = obj.Connect(uri)
        except Exception as e:
            self.logEdit.appendPlainText(str(e))
            return

        self.connectAction.setDisabled(True)
        self.disconnectAction.setEnabled(True)
        self.queryAction.setEnabled(True)

        uri_history = list()
        for i in range(self.connectionUriCombo.count()):
            uri_history.append(self.connectionUriCombo.itemText(i))

        if uri not in uri_history:
            self.connectionUriCombo.clearEditText()
            self.connectionUriCombo.addItem(uri)
            self.connectionUriCombo.setCurrentIndex(len(uri_history))
            uri_history.append(uri)
            path = os.path.join(self._home, 'uri_history.txt')
            open(path, 'w').write('\n'.join(uri_history))

    @Slot()
    def disconnectOneS(self):
        pythoncom.CoUninitialize()
        self._connection = None
        self.connectAction.setEnabled(True)
        self.disconnectAction.setDisabled(True)
        self.queryAction.setDisabled(True)
开发者ID:gsfarm,项目名称:ones-console,代码行数:104,代码来源:console.py


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