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


Python QComboBox.itemText方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import itemText [as 别名]
class TransferToolbarSection:
    """ The Transfer Toolbar section """
    
    def __init__(self, toolbar, table_view):
        """ Initialize the Transfer Toolbar Section """
        self.toolbar = toolbar
        self.table_view = table_view
        
    def addTransfers(self):
        """ Add the transfer widgets """
        if not self.toolbar.transaction.isTransfer():
            self.buildNewTransferSection()
        else:
            self.buildExistingTransferSection()
        
    def buildNewTransferSection(self):
        """ Build a new Transfer Section """
        self.transferLabel = QLabel("Transfer {0}: ".format(self.getTransferDirection()), self.toolbar)
        self.toolbar.addWidget(self.transferLabel)
        self.transferComboBox = QComboBox(self.toolbar)
        UpdateComboBoxWithAccounts(self.transferComboBox, ignoreCurrent=True, table_view=self.table_view)
        self.transferComboBox.activated.connect(self.setTransfer)
        self.toolbar.addWidget(self.transferComboBox)
        
    def buildExistingTransferSection(self):
        """ Build existing Transfer Section """
        if self.toolbar.transaction.account is self.table_view.account:
            self.transferLabel = QLabel("Transferred {0}: {1}".format(self.getTransferDirection(), self.toolbar.transaction.transferAccount.name), self.toolbar)
        else:
            self.transferLabel = QLabel("Transferred {0}: {1}".format(self.getTransferDirection(), self.toolbar.transaction.account.name), self.toolbar)
        self.toolbar.addWidget(self.transferLabel)
        eraseIcon = self.toolbar.getQIcon('erase.png')
        removeTransferAction = QAction(eraseIcon, 'Remove Transfer', self.toolbar)
        removeTransferAction.setStatusTip("Remove Transfer.")
        removeTransferAction.triggered.connect(self.removeTransfer)
        self.toolbar.addAction(removeTransferAction)
            
    def getTransferDirection(self):
        """ Return the Transfer Direction word """
        if self.toolbar.transaction.isIncome(self.table_view.account):
            return "from"
        else:
            return "to"
        
    def setTransfer(self, index):
        """ Set the Transaction Account to view """
        text = self.transferComboBox.itemText(index)
        account = Accounts.accountWithName(text)
        
        if not self.toolbar.transaction.isTransfer():
            transfer = Transfer(transaction=self.toolbar.transaction, account=account)
            Transfers.add(transfer)
            TheBalanceHelper.setupBalancesForAccount(account)
            TheBalanceHelper.setupBalancesForAccount(self.toolbar.transaction.account)
            self.toolbar.buildToolbarWidgets()
            
    def removeTransfer(self):
        """ Remove the Transfer """
        if self.toolbar.transaction.isTransfer():
            account = self.toolbar.transaction.transferAccount
            Transfers.delete(self.toolbar.transaction.transfer)
            Transfers.save()
            TheBalanceHelper.setupBalancesForAccount(account)
            TheBalanceHelper.setupBalancesForAccount(self.toolbar.transaction.account)
            self.toolbar.buildToolbarWidgets()
            self.table_view.updateTransactions()
开发者ID:cloew,项目名称:PersonalAccountingSoftware,代码行数:68,代码来源:transfer_toolbar_section.py

示例2: ParameterBox

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import itemText [as 别名]
class ParameterBox(QWidget):
    '''ParameterBox is a widget to select certain parameters for the numerical
    simulation.
    
    Arguments
    ---------
    parent : QWidget
        the parent widget        
    '''
        
    def __init__(self, parent):
        super(ParameterBox, self).__init__(parent)
        
        
        '''
        sliders
        '''

        self.sliders = {}

        slider = ParameterSlider(self, 'F')        
        slider.set_range(0, 0.1, 0.001)
        slider.set_value(0.035)
        self.sliders['F'] = slider            

        slider = ParameterSlider(self, 'k')        
        slider.set_range(0, 0.1, 0.001)
        slider.set_value(0.06)
        self.sliders['k'] = slider
        
        slider = ParameterSlider(self, 'timesteps')
        slider.set_format('.0f')
        slider.set_range(0, 100000, 1000)
        slider.set_value(10000)        
        self.sliders['timesteps'] = slider
        
        slider = ParameterSlider(self, 'keyframe distance')
        slider.set_format('.0f')
        slider.set_range(1, 100, 1)
        slider.set_value(10)
        self.sliders['keyframe_distance'] = slider
        
        slider = ParameterSlider(self, 'size')        
        slider.set_format('.0f')
        slider.set_range(32, 256, 32)
        slider.set_value(128)
        self.sliders['size'] = slider
        
        
        '''
        Combo box for default settings
        '''        
        
        self.default_coefficients = QComboBox()
        self.default_coefficients.setEditable(False)            
        for key in sorted([key for key in predefined_coefficients]):
            self.default_coefficients.addItem(key)        
        self.default_coefficients.activated.connect(self._load_predefined)
        self.default_coefficients.setCurrentIndex(0)
        self._load_predefined(0)        
        
        
        '''
        create layout
        '''        

        box = QVBoxLayout()
        box.addWidget(self.default_coefficients)
        box.addWidget(self.sliders['F'])
        box.addWidget(self.sliders['k'])
        box.addWidget(self.sliders['timesteps'])
        box.addWidget(self.sliders['keyframe_distance'])
        box.addWidget(self.sliders['size'])
        self.setLayout(box)
        
    def _load_predefined(self, index):
        key = self.default_coefficients.itemText(index)
        if key in predefined_coefficients:            
            coefficients = predefined_coefficients[key]            
            self.sliders['F'].set_value(coefficients['F'])
            self.sliders['k'].set_value(coefficients['k'])            

    def parameters(self):                
        coefficients = {}
        coefficients['Du'] = 0.16
        coefficients['Dv'] = 0.08
        coefficients['F'] = self.sliders['F'].value()
        coefficients['k'] = self.sliders['k'].value()
        
        params = {}
        params['coefficients'] = coefficients
        params['keyframe_distance'] = int(self.sliders['keyframe_distance'].value())
        params['size'] = int(self.sliders['size'].value())
        params['timesteps'] = int(self.sliders['timesteps'].value())                          
        
        return params
开发者ID:michaelschaefer,项目名称:grayscott,代码行数:98,代码来源:parameterbox.py

示例3: RateView

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

#.........这里部分代码省略.........
        # If there is no unit yet, just set it
        try:
            unit = self.model.unit
        except AttributeError:
            self.model.setConverter(str(self.unit.currentText()))
            try:
                self.model.setRate(float(self.rate_value.text()))
            except ValueError:
                pass
            return
        # Convert unit appropriately
        if self.rate.isChecked():
            if unit == 'Hz':
                conv = { 'GHz' : 1E-9,
                         'THz' : 1E-12,
                         'PHz' : 1E-15 }
            elif unit == 'GHz':
                conv = { 'Hz'  : 1E9,
                         'THz' : 1E-3,
                         'PHz' : 1E-6 }
            elif unit == 'THz':
                conv = { 'Hz'  : 1E12,
                         'GHz' : 1E3,
                         'PHz' : 1E-3 }
            elif unit == 'PHz':
                conv = { 'Hz'  : 1E15,
                         'GHz' : 1E6,
                         'THz' : 1E3 }
            else:
                conv = { ''    : 1,
                         'Hz'  : 1, 
                         'GHz' : 1, 
                         'THz' : 1, 
                         'PHz' : 1, }
        else:
            if unit == 's':
                conv = { 'ns' : 1E9,
                         'ps' : 1E12,
                         'fs' : 1E15 }
            elif unit == 'ns':
                conv = { 's'  : 1E-9,
                         'ps' : 1E3,
                         'fs' : 1E6 }
            elif unit == 'ps':
                conv = { 's'  : 1E-12,
                         'ns' : 1E-3,
                         'fs' : 1E3 }
            elif unit == 'fs':
                conv = { 's'  : 1E-15,
                         'ns' : 1E-6,
                         'ps' : 1E-3 }
            else:
                conv = { ''   : 1,
                         's'  : 1, 
                         'ns' : 1, 
                         'ps' : 1, 
                         'fs' : 1, }
        try:
            # Set the new converter, then change the rate
            self.model.setConverter(str(self.unit.currentText()))
            try:
                self.model.setRate(float(self.rate_value.text())
                                 * conv[str(self.unit.currentText())])
            except ValueError:
                pass
        except KeyError:
            pass

        # Save the new unit
        self.model.unit = str(self.unit.currentText())

    def setRateModel(self):
        '''Change the model to use the rate'''
        if self.model.method == 'rate':
            return
        self.model.method = 'rate'
        indx = self.unit.currentIndex()
        self.unit.setModel(self.model.runits)
        self.model.unit = str(self.unit.itemText(indx))
        self.unit.setCurrentIndex(indx)
        self.model.setConverter(self.model.unit)
        try:
            self.model.setRate(1 / float(self.rate_value.text()))
        except (ZeroDivisionError, ValueError):
            pass

    def setLifetimeModel(self):
        '''Change the model to use the lifetime'''
        if self.model.method == 'lifetime':
            return
        self.model.method = 'lifetime'
        indx = self.unit.currentIndex()
        self.unit.setModel(self.model.lunits)
        self.model.unit = str(self.unit.itemText(indx))
        self.unit.setCurrentIndex(indx)
        self.model.setConverter(self.model.unit)
        try:
            self.model.setRate(1 / float(self.rate_value.text()))
        except (ZeroDivisionError, ValueError):
            pass
开发者ID:jensengrouppsu,项目名称:rapid,代码行数:104,代码来源:rate.py

示例4: ConsoleWidget

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import itemText [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.itemText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。