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


Python QComboBox.setModel方法代码示例

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


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

示例1: CustomPage

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class CustomPage(QWizardPage):
    '''
    Custom Computer Wizard Page
    
    Contains inputs for the Driver and Parser that the user can define a 
    custom mix of driver/parser/options.
    '''
    def __init__(self, parent=None):
        super(CustomPage, self).__init__(parent)
        
        self._createLayout()
        
        self.registerField('driver', self._cbxDriver)
        self.registerField('parser', self._cbxParser)
        self.registerField('driveropt', self._txtDOpts)
        self.registerField('parseropt', self._txtPOpts)
    
        self.setTitle(self.tr('Setup Driver Options'))
        self.setSubTitle(self.tr('Select the Driver and Parser to use with your Dive Computer.'))
    
    def nextId(self):
        'Return the next Page Id'
        return Pages.Browse
    
    def _createLayout(self):
        'Create the Wizard Page Layout'
        
        self._cbxDriver = QComboBox()
        self._cbxDriver.setModel(DriverModel())
        self._lblDriver = QLabel(self.tr('&Driver:'))
        self._lblDriver.setBuddy(self._cbxDriver)
        
        self._cbxParser = QComboBox()
        self._cbxParser.setModel(ParserModel())
        self._lblParser = QLabel(self.tr('&Parser:'))
        self._lblParser.setBuddy(self._cbxParser)
        
        self._txtDOpts = QLineEdit()
        self._lblDOpts = QLabel(self.tr('Driver Options:'))
        self._lblDOpts.setBuddy(self._txtDOpts)
        
        self._txtPOpts = QLineEdit()
        self._lblPOpts = QLabel(self.tr('Parser Options:'))
        self._lblPOpts.setBuddy(self._txtPOpts)
        
        gbox = QGridLayout()
        gbox.addWidget(self._lblDriver, 0, 0)
        gbox.addWidget(self._cbxDriver, 0, 1)
        gbox.addWidget(self._lblParser, 1, 0)
        gbox.addWidget(self._cbxParser, 1, 1)
        gbox.addWidget(self._lblDOpts, 2, 0)
        gbox.addWidget(self._txtDOpts, 2, 1)
        gbox.addWidget(self._lblPOpts, 3, 0)
        gbox.addWidget(self._txtPOpts, 3, 1)
        
        vbox = QVBoxLayout()
        vbox.addLayout(gbox)
        vbox.addStretch()
        
        self.setLayout(vbox)
开发者ID:asymworks,项目名称:python-divelog,代码行数:62,代码来源:add_dc.py

示例2: _OptionsSelector

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

    def __init__(self, list_options, parent=None):
        QDialog.__init__(self, parent)

        # Variables
        model = _AvailableOptionsListModel()
        for options in list_options:
            model.addOptions(options)

        # Widgets
        lbltext = QLabel('Select the options to import')

        self._combobox = QComboBox()
        self._combobox.setModel(model)

        buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        # Layouts
        layout = QVBoxLayout()
        layout.addWidget(lbltext)
        layout.addWidget(self._combobox)
        layout.addWidget(buttons)
        self.setLayout(layout)

        # Signals
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)

    def options(self):
        return self._combobox.model().options(self._combobox.currentIndex())
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:33,代码来源:runner.py

示例3: ExportDialog

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class ExportDialog(QDialog):
  """Allows the choice of format and browsing to a save location
     Call data() after exec_()"""
  
  def __init__(self, parent=None):
    super(ExportDialog, self).__init__(parent)
    self._output_folder = None
    self.setModal(True)
    layout_main = QGridLayout()
    label_choose_format = QLabel(self.tr("Choose format"))
    self.combo_choose_format = QComboBox()
    self.combo_choose_format.setModel(QStringListModel(FileExporter.FORMATS_AVAILABLE))
    label_saveto = QLabel(self.tr("Save location"))
    button_saveto = QPushButton(self.tr("Browse ..."))
    button_saveto.clicked.connect(self._openFolderChoiceDialog)
    self.label_output = QLabel()
    button_export = QPushButton(self.tr("Export"))
    button_export.clicked.connect(self.accept)
    button_cancel = QPushButton(self.tr("Cancel"))
    button_cancel.clicked.connect(self.reject)
    row = 0; col = 0;
    layout_main.addWidget(label_choose_format, row, col, 1, 2)
    col += 2
    layout_main.addWidget(self.combo_choose_format, row, col, 1, 2)
    row += 1; col -= 2;
    layout_main.addWidget(label_saveto, row, col, 1, 2)
    col += 2
    layout_main.addWidget(button_saveto, row, col, 1, 2)
    row += 1; col -= 2;
    layout_main.addWidget(self.label_output, row, col, 1, 4)
    row += 1; col += 2
    layout_main.addWidget(button_export, row, col)
    col += 1
    layout_main.addWidget(button_cancel, row, col)
    self.setWindowTitle(self.tr("Export Parameters"))
    self.setLayout(layout_main)
    
  def data(self):
    if self._output_folder is None: return None
    else:
      return ExportInfo(self.combo_choose_format.currentText(), self._output_folder)
  
  def _openFolderChoiceDialog(self):
    folder = QFileDialog.getExistingDirectory(self, caption=self.tr("Choose output directory"))
    if not folder:
      self.label_output.setText("<font style='color:red;'>" + self.tr("Please choose an output folder") 
                                + "</font>")
    else: 
      self.label_output.setText(folder)
      self._output_folder = folder
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:52,代码来源:dialog.py

示例4: SetToTopCompound

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class SetToTopCompound(QWidget):
  def __init__(self, boardCombo=None, parent=None):
    super(SetToTopCompound, self).__init__(parent)
    label_fraction = QLabel("Fraction")
    self.spinbox_fraction = QDoubleSpinBox()
    label_board = QLabel("Board")
    self.combobox_board = QComboBox()
    self._boards = []
    if boardCombo is not None:
      self.combobox_board.setModel(boardCombo.model())
      self._boards = boardCombo.boards()
    layout = QGridLayout()
    row = 0; col = 0
    layout.addWidget(label_fraction, row, col)
    col += 1
    layout.addWidget(self.spinbox_fraction, row, col)
    row += 1; col = 0;
    layout.addWidget(label_board, row, col)
    col += 1
    layout.addWidget(self.combobox_board, row, col)
    self.setLayout(layout)
开发者ID:github-account-because-they-want-it,项目名称:PokerViewer,代码行数:23,代码来源:widgets.py

示例5: STMainWindow

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
    class STMainWindow(QMainWindow):
        def __init__(self):
            QMainWindow.__init__(self)
            fileMenu = self.menuBar().addMenu(self.tr("&File"))
            fileMenu.addAction(
                QAction("E&xit", self,
                        shortcut = "Ctrl+Q",
                        statusTip = "Exit",
                        triggered = self.close))
            window = QWidget()
            layout = QVBoxLayout(self)
            l = QHBoxLayout()
            l.addWidget(self.createCombo())
            self.button = QPushButton("Pick Me")
            self.button.clicked.connect(self.set_user_id)
            l.addWidget(self.button)
            layout.addLayout(l)
            self.user_id = QLabel()
            layout.addWidget(self.user_id)
            layout.addWidget(self.createTable())
            window.setLayout(layout)
            self.setCentralWidget(window)

        def set_user_id(self):
            self.user_id.setText(self.combo.itemData(self.combo.currentIndex()).name)

        def createCombo(self):
            self.combo = QComboBox()
            view = grumble.qt.model.ListModel(grumble.Query(QtUser, False), "display_name")
            self.combo.setModel(view)
            return self.combo

        def createTable(self):
            tv = grumble.qt.view.TableView(QtCountry.query(keys_only = False), ["countryname", "countrycode"])
            tv.setMinimumSize(400, 300)
            return tv
开发者ID:JanDeVisser,项目名称:Grumble,代码行数:38,代码来源:test.py

示例6: LimitWizardPage

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

#.........这里部分代码省略.........
        def insert(self, index, limit):
            self.insertRows(index)
            self.setData(self.createIndex(index, 0), limit)

        def remove(self, limit):
            index = self._limits.index(limit)
            self.removeRows(index)

        def modify(self, index, limit):
            self.setData(self.createIndex(index, 0), limit)

        def clear(self):
            self.removeRows(0, self.rowCount())

        def limits(self):
            limits = set(self._limits)
            limits.discard(None)
            return limits

        def limit(self, index):
            return self._limits[index.row()]

    class _LimitTableDelegate(QItemDelegate):

        def __init__(self, parent=None):
            QItemDelegate.__init__(self, parent)

        def createEditor(self, parent, option, index):
            return None

        def setEditorData(self, editor, index):
            pass

        def setModelData(self, editor, model, index):
            return None

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

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

        # Widgets
        self._cb_limit = QComboBox()
        self._cb_limit.setModel(self._LimitComboBoxModel())

        btn_limit_add = QPushButton()
        btn_limit_add.setIcon(getIcon("list-add"))

        self._tbl_limit = QTableView()
        self._tbl_limit.setModel(tbl_model)
        self._tbl_limit.setItemDelegate(self._LimitTableDelegate())
        header = self._tbl_limit.horizontalHeader()
        header.setResizeMode(QHeaderView.Stretch)
        header.hide()
        policy = self._tbl_limit.sizePolicy()
        policy.setVerticalStretch(True)
        self._tbl_limit.setSizePolicy(policy)

        tlb_limit = QToolBar()
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        tlb_limit.addWidget(spacer)
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:70,代码来源:limit.py

示例7: ExchangeView

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class ExchangeView(QGroupBox):
    '''The box containing the rate value'''

    def __init__(self, title = 'Peak Exchange Matrix', parent = None):
        '''Initialize'''
        super(ExchangeView, self).__init__(parent)
        self.setTitle(title)
        self._createWidgets()

    def _createWidgets(self):
        '''Create the widgets contained in this box'''
        # Peak number chooser
        self.numpeaks = [QRadioButton("2"),
                         QRadioButton("3"),
                         QRadioButton("4")]
        
        self.numpeaks[0].setToolTip(ttt('Model the exchange of 2 peaks'))
        self.numpeaks[1].setToolTip(ttt('Model the exchange of 3 peaks'))
        self.numpeaks[2].setToolTip(ttt('Model the exchange of 4 peaks'))
        # Make 4x4 matrix of QLabels
        self.exview = [[QLabel(self) for i in xrange(4)] for j in xrange(4)]
        for i in xrange(4):
            for e in self.exview[i]:
                e.setToolTip(ttt('The current exchange matrix'))
        # Enforce symmetry button
        self.symmetry = QCheckBox("Enforce Symmetry", self)
        self.symmetry.setToolTip(ttt('If symmetry is on then you only need to '
                                     'manually set the upper triangle of the '
                                     'exchange matrix.  Thse values are '
                                     'mirrored '
                                     'in the lower triangle and the diagonals '
                                     'are automatically set so that each row '
                                     'sums to 1. '
                                     'Otherwise you must set every element'))
        # Exchange picker
        self.exchooser = QComboBox(self)
        self.exchooser.setToolTip(ttt('Choose between which two peaks to set '
                                  'the exchange (relative) rate'))
        # Exchange value
        self.exvalue = QLineEdit(self)
        self.exvalue.setToolTip(ttt('The exchange (relative) rate'))
        self.exvalue.setValidator(QDoubleValidator(0.0, 1.0, 3, self.exvalue))

    def makeConnections(self):
        '''Connect the widgets together'''
        # When the table has been resized, tidy it up
        self.matrix.matrixChanged.connect(self.resetMatrix)
        # If the check state changed, change the data model
        self.symmetry.stateChanged.connect(self.changeDataModel)
        self.numpeaks[0].clicked.connect(self.changeDataModel)
        self.numpeaks[1].clicked.connect(self.changeDataModel)
        self.numpeaks[2].clicked.connect(self.changeDataModel)
        # Attach the chooser to an exchange rate
        self.exchooser.currentIndexChanged.connect(self.attachExchange)
        # If the exchange rate is changed, update the matrix
        self.exvalue.editingFinished.connect(self.newExchange)

    def initUI(self):
        '''Lays out the widgets'''
        nums = QHBoxLayout()
        nums.addWidget(QLabel("Number of Peaks: "))
        nums.addWidget(self.numpeaks[0])
        nums.addWidget(self.numpeaks[1])
        nums.addWidget(self.numpeaks[2])
        val = QHBoxLayout()
        val.addWidget(QLabel("Exchange: "))
        val.addStretch()
        val.addWidget(self.exchooser)
        self.exvalue.setMaximumWidth(50)
        val.addWidget(self.exvalue)
        ex = QGridLayout()
        for i in xrange(4):
            for j in xrange(4):
                ex.addWidget(self.exview[i][j], i+1, j+1)
        lo = QVBoxLayout()
        lo.addLayout(nums)
        lo.addWidget(self.symmetry)
        lo.addLayout(val)
        lo.addLayout(ex)
        self.setLayout(lo)

    def setModel(self, model, npmodel):
        '''Attaches models to the views.'''
        self.matrix = model
        self.npmodel = npmodel

    def setNumPeaks(self, npeaks):
        '''Manually set the number of peaks'''
        if npeaks == 2:
            self.numpeaks[0].click()
        elif npeaks == 3:
            self.numpeaks[1].click()
        elif npeaks == 4:
            self.numpeaks[2].click()
        else:
            error.showMessage('Only valid number of peaks is 2, 3, or 4')

    def setMatrixSymmetry(self, sym):
        '''Manually set the matrix symmetry'''
        self.symmetry.setChecked(sym)
#.........这里部分代码省略.........
开发者ID:jensengrouppsu,项目名称:rapid,代码行数:103,代码来源:exchange.py

示例8: RateView

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class RateView(QGroupBox):
    '''The box containing the rate value'''

    def __init__(self, title = 'Rate', parent = None):
        '''Initialize'''
        super(RateView, self).__init__(parent)
        self.setTitle(title)
        self._createWidgets()

    def _createWidgets(self):
        '''Create the widgets contained in this box'''

        # Rate or lifetime chooser
        self.rate = QRadioButton('Rate', self)
        self.rate.setToolTip(ttt('Choose this to express exchange as rate'))
        self.lifetime = QRadioButton('Lifetime', self)
        self.lifetime.setToolTip(ttt('Choose this to express exchange as '
                                     'lifetime'))

        # Box containing value
        self.rate_value = QLineEdit(self)
        validate = QDoubleValidator(self.rate_value)
        validate.setDecimals(3)
        validate.setBottom(0.0)
        self.rate_value.setValidator(validate)
        self.rate_value.setToolTip(ttt('The rate or lifetime value'))

        # Unit
        self.unit = QComboBox(self)
        self.unit.setToolTip(ttt('Selects the input unit for the rate '
                                 'or lifetime'))

    def initUI(self):
        '''Lays out the widgets'''
        radios = QVBoxLayout()
        radios.addWidget(self.rate)
        radios.addWidget(self.lifetime)
        rate = QGridLayout()
        rate.addWidget(QLabel("Unit: "), 1, 1)
        rate.addWidget(self.unit, 1, 2)
        rate.addWidget(QLabel("Value: "), 2, 1)
        rate.addWidget(self.rate_value, 2, 2)
        total = QHBoxLayout()
        total.addLayout(radios)
        total.addStretch()
        total.addLayout(rate)
        self.setLayout(total)

    def makeConnections(self):
        '''Connect the widgets together'''

        # When one radio button is checked, change the combo box model
        # and un-check the other radio button
        self.rate.clicked.connect(self.setRateModel)
        self.lifetime.clicked.connect(self.setLifetimeModel)

        # If the text changes, emit that rate
        self.rate_value.editingFinished.connect(self.emitRate)

        # If the underlying model changes, adjust the text
        self.model.rateChanged.connect(self.updateRate)

        # If the unit changes, update rate
        self.unit.currentIndexChanged.connect(self.updateUnit)

    def setModel(self, model):
        '''Attaches models to the views'''
        self.model = model

    def setRate(self, rate):
        '''Set the rate manually'''
        self.rate_value.setText(str(rate))
        self.rate_value.editingFinished.emit()

    def setUnit(self, unit):
        '''Set the unit manually'''
        if unit == 's':
            self.lifetime.click()
            self.unit.setCurrentIndex(0)
        elif unit == 'ns':
            self.lifetime.click()
            self.unit.setCurrentIndex(1)
        elif unit == 'ps':
            self.lifetime.click()
            self.unit.setCurrentIndex(2)
        elif unit == 'fs':
            self.lifetime.click()
            self.unit.setCurrentIndex(3)
        elif unit in ('Hz', 'hz'):
            self.rate.click()
            self.unit.setCurrentIndex(0)
        elif unit in ('GHz', 'ghz'):
            self.rate.click()
            self.unit.setCurrentIndex(1)
        elif unit in ('THz', 'thz'):
            self.rate.click()
            self.unit.setCurrentIndex(2)
        elif unit in ('PHz', 'phz'):
            self.rate.click()
            self.unit.setCurrentIndex(3)
#.........这里部分代码省略.........
开发者ID:jensengrouppsu,项目名称:rapid,代码行数:103,代码来源:rate.py

示例9: _PhotonDistributionResultOptionsToolItem

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class _PhotonDistributionResultOptionsToolItem(_ResultToolItem):
    def _initUI(self):
        # Variables
        result = self.result()
        transitions = sorted(result.iter_transitions())
        transition0 = transitions[0]
        model = _TransitionListModel(transitions)

        # Widgets
        self._chk_errorbar = QCheckBox("Show error bars")
        self._chk_errorbar.setChecked(True)

        self._cb_transition = QComboBox()
        self._cb_transition.setModel(model)
        self._cb_transition.setCurrentIndex(0)

        self._chk_pg = QCheckBox("No absorption, no fluorescence")
        state = result.exists(transition0, True, False, False, False)
        self._chk_pg.setEnabled(state)
        self._chk_pg.setChecked(state)

        self._chk_eg = QCheckBox("With absorption, no fluorescence")
        state = result.exists(transition0, True, True, False, False)
        self._chk_eg.setEnabled(state)
        self._chk_eg.setChecked(state)

        self._chk_pt = QCheckBox("No absorption, with fluorescence")
        state = result.exists(transition0, True, False, True, True)
        self._chk_pt.setEnabled(state)
        self._chk_pt.setChecked(state)

        self._chk_et = QCheckBox("With absorption, with fluorescence")
        state = result.exists(transition0, True, True, True, True)
        self._chk_et.setEnabled(state)
        self._chk_et.setChecked(state)

        # Layouts
        layout = _ResultToolItem._initUI(self)
        layout.addRow(self._chk_errorbar)
        layout.addRow("Transition", self._cb_transition)

        boxlayout = QVBoxLayout()
        boxlayout.addWidget(self._chk_pg)
        boxlayout.addWidget(self._chk_eg)
        boxlayout.addWidget(self._chk_pt)
        boxlayout.addWidget(self._chk_et)

        box_generated = QGroupBox("Curves")
        box_generated.setLayout(boxlayout)
        layout.addRow(box_generated)

        # Signals
        self._cb_transition.currentIndexChanged.connect(self._onTransitionChanged)
        self._chk_pg.stateChanged.connect(self.stateChanged)
        self._chk_eg.stateChanged.connect(self.stateChanged)
        self._chk_pt.stateChanged.connect(self.stateChanged)
        self._chk_et.stateChanged.connect(self.stateChanged)
        self._chk_errorbar.stateChanged.connect(self.stateChanged)

        return layout

    def _onTransitionChanged(self):
        result = self.result()

        index = self._cb_transition.currentIndex()
        transition = self._cb_transition.model().transition(index)

        self._chk_pg.setEnabled(result.exists(transition, True, False, False, False))
        self._chk_eg.setEnabled(result.exists(transition, True, True, False, False))
        self._chk_pt.setEnabled(result.exists(transition, True, False, True, True))
        self._chk_et.setEnabled(result.exists(transition, True, True, True, True))

        self.stateChanged.emit()

    def transition(self):
        index = self._cb_transition.currentIndex()
        return self._cb_transition.model().transition(index)

    def showConditions(self):
        return (
            self._chk_pg.isChecked() and self._chk_pg.isEnabled(),
            self._chk_eg.isChecked() and self._chk_eg.isEnabled(),
            self._chk_pt.isChecked() and self._chk_pt.isEnabled(),
            self._chk_et.isChecked() and self._chk_et.isEnabled(),
        )

    def showErrorbar(self):
        return self._chk_errorbar.isChecked()
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:90,代码来源:result.py

示例10: PointEditor

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class PointEditor(QDialog):
  
  def __init__(self, playerName='', sbChips=0, bbChips=0, action='', board=None, boardCombo=None,
               editMode=False, parent=None):
    super(PointEditor, self).__init__(parent)
    self._boards = boardCombo.boards() # boards is an array of MyEquityArray objects
    self._label_player = QLabel("Player")
    self._radiogroup_player = PlayerRadioGroup(playerName)
    self._label_sb_chips = QLabel("SB Chips")
    self._spinbox_sb_chips = BetAmountSpinBox()
    self._spinbox_sb_chips.setValue(sbChips)
    self._label_bb_chips = QLabel("BB Chips")
    self._spinbox_bb_chips = BetAmountSpinBox()
    self._spinbox_bb_chips.setValue(bbChips)
    label_board = QLabel("Choose board")
    self.combobox_board = QComboBox()
    self.combobox_board.setModel(boardCombo.model())
    if board is not None:
      self.combobox_board.setCurrentIndex(self._getComboItems(self.combobox_board).index(board.originalBoard()))
    self._action_label = QLabel("Parent action")
    if editMode:
      button_ok_text = "Edit point"
    else:
      button_ok_text = "Add point"
    button_ok = QPushButton(button_ok_text)
    button_cancel = QPushButton("Cancel")
    button_ok.clicked.connect(self.accept)
    button_cancel.clicked.connect(self.reject)
    self._radiogroup_action = ActionRadioGroup(action)
    layout = QGridLayout()
    row = 0; col = 0;
    layout.addWidget(self._label_player, row, col)
    col += 1
    layout.addWidget(self._radiogroup_player, row, col)
    row += 1; col = 0;
    layout.addWidget(self._action_label, row, col)
    col += 1
    layout.addWidget(self._radiogroup_action, row, col)
    row += 1; col = 0;
    layout.addWidget(self._label_sb_chips, row, col)
    col += 1
    layout.addWidget(self._spinbox_sb_chips, row, col)
    row += 1; col = 0;
    layout.addWidget(self._label_bb_chips, row, col)
    col += 1;
    layout.addWidget(self._spinbox_bb_chips, row, col)
    row += 1; col = 0;
    layout.addWidget(label_board, row, col)
    col += 1
    layout.addWidget(self.combobox_board, row, col)
    row += 1; col = 0;
    layout.addWidget(button_ok, row, col)
    col += 1
    layout.addWidget(button_cancel, row, col)
    self.setModal(True)
    self.setMinimumWidth(300)
    if editMode:
      title = "Edit Point Information"
    else:
      title = "Enter Point Information"
    self.setWindowTitle(title)
    self.setLayout(layout)
    
  def playerName(self):
    return self._radiogroup_player.getValue()
  
  def setPlayerName(self, playerName):
    self._radiogroup_player.setCheckedCombo(playerName)
  
  def sbChips(self):
    return self._spinbox_sb_chips.value()
  
  def setSbChips(self, sbChips):
    self._spinbox_sb_chips.setValue(sbChips)
  
  def bbChips(self):
    return self._spinbox_bb_chips.value()
  
  def setBbChips(self, bbChips):
    self._spinbox_bb_chips.setValue(bbChips)
    
  def board(self):
    if len(self._boards):
      return self._boards[self.combobox_board.currentIndex()]
    else:
      return None
  
  def setBoard(self, board):
    self.combobox_board.setCurrentIndex(self._boards.index(board))
    
  def playAction(self):
    return self._radiogroup_action.getValue()
  
  def setPlayAction(self, action):
    self._radiogroup_action.setCheckedCombo(action)
    
  def _getComboItems(self, combobox):
    items = []
    for i in range(combobox.count()):
      items.append(combobox.itemData(i, Qt.DisplayRole))
#.........这里部分代码省略.........
开发者ID:github-account-because-they-want-it,项目名称:PokerViewer,代码行数:103,代码来源:widgets.py

示例11: __init__

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
    def __init__(self, results, result_key,
                 parameter_getters, x_parameter_name,
                 series=None, parent=None):
        QDialog.__init__(self, parent)

        # Variables
        self._results = results
        self._result_key = result_key
        self._parameter_getters = parameter_getters
        options = results.options

        # Widgets
        self._txt_name = QLineEdit()

        self._cb_parameters = {}
        for name, getter in parameter_getters.items():
            if name == x_parameter_name:
                continue

            combobox = QComboBox()
            values = np.array(getter(options), ndmin=1)
            combobox.setModel(_ValuesModel(values))
            self._cb_parameters[name] = combobox

        self._cb_summary_key = QComboBox()
        self._cb_summary_key.setModel(_ValuesModel([]))

        buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        # Layouts
        layout = QFormLayout()
        if sys.platform == 'darwin': # Fix for Mac OS
            layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
        layout.addRow('Name', self._txt_name)
        for name, combobox in self._cb_parameters.items():
            layout.addRow(name, combobox)
        layout.addRow('Summary variable', self._cb_summary_key)

        layout.addRow(buttons)

        self.setLayout(layout)

        # Signals
        buttons.accepted.connect(self._onOk)
        buttons.rejected.connect(self.reject)

        for combobox in self._cb_parameters.values():
            combobox.currentIndexChanged.connect(self._onParameterChanged)

        # Defaults
        if series is not None:
            self._txt_name.setText(series.name)

            for name, _, value in series.conditions:
                combobox = self._cb_parameters[name]
                index = combobox.model().valueIndex(value)
                combobox.setCurrentIndex(index)
            self._onParameterChanged()

            index = self._cb_summary_key.model().valueIndex(series.summary_key)
            self._cb_summary_key.setCurrentIndex(index)
        else:
            self._onParameterChanged()
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:65,代码来源:summary.py

示例12: _SeriesDialog

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

    def __init__(self, results, result_key,
                 parameter_getters, x_parameter_name,
                 series=None, parent=None):
        QDialog.__init__(self, parent)

        # Variables
        self._results = results
        self._result_key = result_key
        self._parameter_getters = parameter_getters
        options = results.options

        # Widgets
        self._txt_name = QLineEdit()

        self._cb_parameters = {}
        for name, getter in parameter_getters.items():
            if name == x_parameter_name:
                continue

            combobox = QComboBox()
            values = np.array(getter(options), ndmin=1)
            combobox.setModel(_ValuesModel(values))
            self._cb_parameters[name] = combobox

        self._cb_summary_key = QComboBox()
        self._cb_summary_key.setModel(_ValuesModel([]))

        buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        # Layouts
        layout = QFormLayout()
        if sys.platform == 'darwin': # Fix for Mac OS
            layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
        layout.addRow('Name', self._txt_name)
        for name, combobox in self._cb_parameters.items():
            layout.addRow(name, combobox)
        layout.addRow('Summary variable', self._cb_summary_key)

        layout.addRow(buttons)

        self.setLayout(layout)

        # Signals
        buttons.accepted.connect(self._onOk)
        buttons.rejected.connect(self.reject)

        for combobox in self._cb_parameters.values():
            combobox.currentIndexChanged.connect(self._onParameterChanged)

        # Defaults
        if series is not None:
            self._txt_name.setText(series.name)

            for name, _, value in series.conditions:
                combobox = self._cb_parameters[name]
                index = combobox.model().valueIndex(value)
                combobox.setCurrentIndex(index)
            self._onParameterChanged()

            index = self._cb_summary_key.model().valueIndex(series.summary_key)
            self._cb_summary_key.setCurrentIndex(index)
        else:
            self._onParameterChanged()

    def _onParameterChanged(self):
        summary_keys = set()

        for container in self._results:
            match = True
            for name, expected in self.parameterValue().items():
                getter = self._parameter_getters[name]
                actual = getter(container.options)
                if actual != expected:
                    match = False
                    break

            if not match:
                continue

            try:
                result = container[self._result_key]
            except KeyError:
                continue

            summary_keys.update(result.get_summary().keys())

        self._cb_summary_key.setModel(_ValuesModel(summary_keys))

    def _onOk(self):
        if self._cb_summary_key.currentIndex() < 0:
            return
        self.accept()

    def name(self):
        name = self._txt_name.text().strip()

        if not name:
            parts = []
#.........这里部分代码省略.........
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:103,代码来源:summary.py

示例13: TransferPanel

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setModel [as 别名]
class TransferPanel(QWidget):
    '''
    Transfer Panel
    
    This Panel is the main dialog box for the Dive Computer Transfer GUI
    '''
    def __init__(self, parent=None):
        super(TransferPanel, self).__init__(parent)
        
        self._logbook = None
        self._logbookName = 'None'
        self._logbookPath = None
        
        self._createLayout()
        
        self._readSettings()
        self.setWindowTitle(self.tr('DC Transfer - %s') % self._logbookName)
        
    def _createLayout(self):
        'Create the Widget Layout'
        
        self._txtLogbook = QLineEdit()
        self._txtLogbook.setReadOnly(True)
        self._lblLogbook = QLabel(self.tr('&Logbook File:'))
        self._lblLogbook.setBuddy(self._txtLogbook)
        self._btnBrowse = QPushButton('...')
        self._btnBrowse.clicked.connect(self._btnBrowseClicked)
        self._btnBrowse.setStyleSheet('QPushButton { min-width: 24px; max-width: 24px; }')
        self._btnBrowse.setToolTip(self.tr('Browse for a Logbook'))
        
        self._cbxComputer = QComboBox()
        self._lblComputer = QLabel(self.tr('Dive &Computer:'))
        self._lblComputer.setBuddy(self._cbxComputer)
        self._btnAddComputer = QPushButton(QPixmap(':/icons/list-add.png'), self.tr(''))
        self._btnAddComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }')
        self._btnAddComputer.clicked.connect(self._btnAddComputerClicked)
        self._btnRemoveComputer = QPushButton(QPixmap(':/icons/list-remove.png'), self.tr(''))
        self._btnRemoveComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }')
        self._btnRemoveComputer.clicked.connect(self._btnRemoveComputerClicked)
        
        hbox = QHBoxLayout()
        hbox.addWidget(self._btnAddComputer)
        hbox.addWidget(self._btnRemoveComputer)
        
        gbox = QGridLayout()
        gbox.addWidget(self._lblLogbook, 0, 0)
        gbox.addWidget(self._txtLogbook, 0, 1)
        gbox.addWidget(self._btnBrowse, 0, 2)
        gbox.addWidget(self._lblComputer, 1, 0)
        gbox.addWidget(self._cbxComputer, 1, 1)
        gbox.addLayout(hbox, 1, 2)
        gbox.setColumnStretch(1, 1)
        
        self._pbTransfer = QProgressBar()
        self._pbTransfer.reset()
        self._txtStatus = QTextEdit()
        self._txtStatus.setReadOnly(True)
        
        self._btnTransfer = QPushButton(self.tr('&Transfer Dives'))
        self._btnTransfer.clicked.connect(self._btnTransferClicked)
        
        self._btnExit = QPushButton(self.tr('E&xit'))
        self._btnExit.clicked.connect(self.close)
        
        hbox = QHBoxLayout()
        hbox.addWidget(self._btnTransfer)
        hbox.addStretch()
        hbox.addWidget(self._btnExit)
        
        vbox = QVBoxLayout()
        vbox.addLayout(gbox)
        vbox.addWidget(self._pbTransfer)
        vbox.addWidget(self._txtStatus)
        vbox.addLayout(hbox)
        
        self.setLayout(vbox)
        
    def _closeLogbook(self):
        'Close the current Logbook'
        if self._logbook is None:
            return
        
        self._logbook = None
        self._logbookName = 'None'
        self._logbookPath = None
        
        self._txtLogbook.clear()
        self._cbxComputer.setModel(None)
        
        self._writeSettings()
        self.setWindowTitle(self.tr('DC Transfer - %s') % self._logbookName)
        
    def _openLogbook(self, path):
        'Open an existing Logbook'
        if self._logbook is not None:
            self._closeLogbook()
            
        if not os.path.exists(path):
            QMessageBox.critical(self, self.tr('Missing Logbook'), 
                self.tr('Logbook File "%s" does not exist.') % path)
#.........这里部分代码省略.........
开发者ID:asymworks,项目名称:python-divelog,代码行数:103,代码来源:qdcxfer.py

示例14: DetectorWizardPage

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

#.........这里部分代码省略.........
        def detectors(self):
            detectors = {}
            for key, detector in self._detectors:
                if detector is not None:
                    detectors.setdefault(key, []).append(detector)
            return detectors

        def detector(self, index):
            return self._detectors[index.row()][1]

        def key(self, index):
            return self._detectors[index.row()][0]

    class _DetectorTableDelegate(QItemDelegate):

        def __init__(self, parent=None):
            QItemDelegate.__init__(self, parent)

        def createEditor(self, parent, option, index):
            column = index.column()
            if column == 0:
                editor = QLineEdit(parent)
                editor.setValidator(QRegExpValidator(QRegExp(r"^(?!\s*$).+")))
                return editor
            elif column == 1:
                return None

        def setEditorData(self, editor, index):
            column = index.column()
            if column == 0:
                key = index.model().data(index, Qt.DisplayRole)
                editor.setText(key)

        def setModelData(self, editor, model, index):
            column = index.column()
            if column == 0:
                if not editor.hasAcceptableInput():
                    return
                model.setData(index, editor.text())

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

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

        # Widgets
        self._cb_detector = QComboBox()
        self._cb_detector.setModel(self._DetectorComboBoxModel())

        btn_detector_add = QPushButton()
        btn_detector_add.setIcon(getIcon("list-add"))

        self._tbl_detector = QTableView()
        self._tbl_detector.setModel(tbl_model)
        self._tbl_detector.setItemDelegate(self._DetectorTableDelegate())
        header = self._tbl_detector.horizontalHeader()
        header.setResizeMode(1, QHeaderView.Stretch)
        policy = self._tbl_detector.sizePolicy()
        policy.setVerticalStretch(True)
        self._tbl_detector.setSizePolicy(policy)

        tlb_detector = QToolBar()
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:70,代码来源:detector.py

示例15: ModelWizardPage

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

    class _ModelTypeComboBoxModel(QAbstractListModel):

        def __init__(self, model_types=None):
            QAbstractListModel.__init__(self)
            if model_types is None:
                model_types = []
            self._model_types = list(model_types)

        def rowCount(self, *args, **kwargs):
            return len(self._model_types)

        def data(self, index, role=Qt.DisplayRole):
            if not index.isValid() or \
                    not (0 <= index.row() < self.rowCount()):
                return None

            if role == Qt.TextAlignmentRole:
                return Qt.AlignCenter

            if role != Qt.DisplayRole:
                return None

            return str(self._model_types[index.row()])

        def modelType(self, index):
            return self._model_types[index]

    class _ModelComboBoxModel(QAbstractListModel):

        def __init__(self, models_text=None):
            QAbstractListModel.__init__(self)

            if models_text is None:
                models_text = {}
            self._models_text = models_text.copy()

            self._models = {}
            for model in models_text.keys():
                self._models.setdefault(model.type, []).append(model)

            self._model_type = None

        def rowCount(self, *args, **kwargs):
            return len(self._models.get(self._model_type, []))

        def data(self, index, role=Qt.DisplayRole):
            if not index.isValid() or \
                    not (0 <= index.row() < self.rowCount()):
                return None

            if role == Qt.TextAlignmentRole:
                return Qt.AlignCenter

            if role != Qt.DisplayRole:
                return None

            model = self._models[self._model_type][index.row()]
            return self._models_text[model]

        def setModelType(self, model_type):
            self._model_type = model_type
            self.reset()

        def model(self, index):
            return self._models[self._model_type][index]

        def add(self, model):
            if model not in self._models_text:
                raise ValueError('No text defined for model: %s' % model)
            self._models[model.type].append(model)
            self.reset()

        def remove(self, model):
            self._models[model.type].remove(model)
            self.reset()

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

    def _initUI(self):
        # Widgets
        self._cb_model_type = QComboBox()
        self._cb_model_type.setModel(self._ModelTypeComboBoxModel())

        self._cb_model = QComboBox()
        self._cb_model.setModel(self._ModelComboBoxModel())
        self._cb_model.setMaxVisibleItems(10)

        btn_model_add = QPushButton()
        btn_model_add.setIcon(getIcon("list-add"))

        self._tbl_model = ModelTableWidget()

        tlb_model = QToolBar()
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        tlb_model.addWidget(spacer)
#.........这里部分代码省略.........
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:103,代码来源:model.py


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