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


Python QComboBox.setEnabled方法代码示例

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


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

示例1: SimpleComboboxOption

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setEnabled [as 别名]
class SimpleComboboxOption(SimpleOption):
    def __init__(self, settingsName, labelText, defaultValue, checkable=False, *options):
        self.options = options
        super(SimpleComboboxOption,self).__init__(settingsName, labelText, defaultValue, checkable)
    def editor(self, defaultValue):
        #options = ('Uniform','Exponential','Normal','Log Normal')
        options = self.options
        self.combo = QComboBox()
        self.combo.addItems(options)
        self.combo.setCurrentIndex(int(QSettings().value(self.settingsName, defaultValue)))
        self.combo.setToolTip('Default value: %s' % defaultValue)
        #self.combo.setAlignment(Qt.AlignLeft|Qt.AlignTop)
        self.layout().addWidget(self.combo)
    def setEnabled(self, e):
        self.combo.setEnabled(e)
    def getValue(self):
        return self.combo.currentIndex()
    def getName(self):
        return self.combo.currentText()
开发者ID:ThomasDalla,项目名称:Highway_Simulation_GUI,代码行数:21,代码来源:helpers.py

示例2: _SummaryOptionsToolItem

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

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

        def _program_getter(options):
            programs = list(options.programs)
            if len(programs) == 1:
                return programs[0]
            else:
                return list(programs)
        self._parameter_getters['program'] = _program_getter

        options = self.options()
        for name, getter in iter_getters(options):
            values = np.array(getter(options), ndmin=1)
            if len(values) < 2:
                continue
            self._parameter_getters[name] = getter

        # Actions
        act_add_series = QAction(getIcon("list-add"), "Add series", self)
        act_remove_series = QAction(getIcon("list-remove"), "Remove series", self)
        act_clear_series = QAction(getIcon("edit-clear"), "Clear", self)

        # Widgets
        self._cb_result_key = QComboBox()

        self._cb_x_parameter = QComboBox()
        self._cb_x_parameter.addItems(list(self._parameter_getters.keys()))

        self._lst_series = QListView()
        self._lst_series.setModel(_SeriesModel())

        tlb_series = QToolBar()
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        tlb_series.addWidget(spacer)
        tlb_series.addAction(act_add_series)
        tlb_series.addAction(act_remove_series)
        tlb_series.addAction(act_clear_series)

        self._chk_normalize = QCheckBox('Normalize series')

        # Layouts
        layout = _ResultsToolItem._initUI(self)
        layout.addRow("Result", self._cb_result_key)
        layout.addRow("X parameter", self._cb_x_parameter)
        layout.addRow("Series", self._lst_series)
        layout.addRow(tlb_series)
        layout.addRow(self._chk_normalize)

        # Signals
        act_add_series.triggered.connect(self._onAddSeries)
        act_remove_series.triggered.connect(self._onRemoveSeries)
        act_clear_series.triggered.connect(self._onClearSeries)
        self._lst_series.doubleClicked.connect(self._onSeriesDoubleClicked)
        self._cb_result_key.currentIndexChanged.connect(self._onResultKeyChanged)
        self._chk_normalize.stateChanged.connect(self.stateChanged)

        # Defaults
        keys = set()
        for container in self.results():
            for key, result in container.items():
                if not isinstance(result, _SummarizableResult):
                    continue
                keys.add(key)
        self._cb_result_key.addItems(sorted(keys))

        return layout

    def _onResultKeyChanged(self):
        ndim = self._getResultDimensions()
        self._cb_x_parameter.setEnabled(ndim == 1)

    def _onAddSeries(self):
        # Dialog
        result_key = self._cb_result_key.currentText()

        if self._getResultDimensions() > 1:
            x_parameter_name = None
        else:
            x_parameter_name = self._cb_x_parameter.currentText()

        dialog = _SeriesDialog(self.results(), result_key,
                               self._parameter_getters, x_parameter_name)
        if not dialog.exec_():
            return

        # Create series
        series_name = dialog.name()
        parameter_value = dialog.parameterValue()
        summary_key = dialog.summaryKey()

        conditions = []
        for name, value in parameter_value.items():
            conditions.append((name, self._parameter_getters[name], value))

        model = self._lst_series.model()
#.........这里部分代码省略.........
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:103,代码来源:summary.py

示例3: TransferPanel

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

#.........这里部分代码省略.........
                    self.tr('Are you sure you want to delete "%s"?') % dc.name,
                    QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) == QMessageBox.Yes:
            self._logbook.session.delete(dc)
            self._logbook.session.commit()
            self._cbxComputer.model().reload()
    
    @QtCore.Slot()
    def _btnBrowseClicked(self):
        'Browse for a Logbook File'
        if self._logbook is not None:
            dir = os.path.dirname(self._logbookPath)
        else:
            dir = os.path.expanduser('~')
        
        fn = QFileDialog.getOpenFileName(self,
            caption=self.tr('Select a Logbook file'), dir=dir,
            filter='Logbook Files (*.lbk);;All Files(*.*)')[0]    
        if fn == '':
            return
        if not os.path.exists(fn):
            if QMessageBox.question(self, self.tr('Create new Logbook?'), 
                    self.tr('Logbook "%s" does not exist. Would you like to create it?') % os.path.basename(fn),
                    QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) != QMessageBox.Yes:
                return
            Logbook.Create(fn)
        self._openLogbook(fn)
        
    @QtCore.Slot()
    def _btnTransferClicked(self):
        'Transfer Dives'
        idx = self._cbxComputer.currentIndex()
        dc = self._cbxComputer.itemData(idx, Qt.UserRole+0)
        
        if self._logbook.session.dirty:
            print "Flushing dirty session"
            self._logbook.rollback()
        
        self._txtLogbook.setEnabled(False)
        self._btnBrowse.setEnabled(False)
        self._cbxComputer.setEnabled(False)
        self._btnAddComputer.setEnabled(False)
        self._btnRemoveComputer.setEnabled(False)
        self._btnTransfer.setEnabled(False)
        self._btnExit.setEnabled(False)
        
        self._txtStatus.clear()
        
        thread = QThread(self)
        
        #FIXME: ZOMG HAX: Garbage Collector will eat TransferWorker when moveToThread is called
        #NOTE: Qt.QueuedConnection is important...
        self.worker = None
        self.worker = TransferWorker(dc)
        thread.started.connect(self.worker.start, Qt.QueuedConnection)
        self.worker.moveToThread(thread)
        self.worker.finished.connect(self._transferFinished, Qt.QueuedConnection)
        self.worker.finished.connect(self.worker.deleteLater, Qt.QueuedConnection)
        self.worker.finished.connect(thread.deleteLater, Qt.QueuedConnection)
        self.worker.progress.connect(self._transferProgress, Qt.QueuedConnection)
        self.worker.started.connect(self._transferStart, Qt.QueuedConnection)
        self.worker.status.connect(self._transferStatus, Qt.QueuedConnection)
        
        thread.start()
        
    @QtCore.Slot(str)
    def _transferStatus(self, msg):
        'Transfer Status Message'
        self._txtStatus.append(msg)
        
    @QtCore.Slot(int)
    def _transferStart(self, nBytes):
        'Transfer Thread Stated'
        if nBytes > 0:
            self._pbTransfer.setMaximum(nBytes)
        else:
            self._pbTransfer.setMaximum(100)
        self._pbTransfer.reset()
        
    @QtCore.Slot(int)
    def _transferProgress(self, nTransferred):
        'Transfer Thread Progress Event'
        self._pbTransfer.setValue(nTransferred)
        
    @QtCore.Slot(models.Dive)
    def _transferParsed(self, dive):
        'Transfer Thread Parsed Dive'
        self._logbook.session.add(dive)
        
    @QtCore.Slot()
    def _transferFinished(self):
        'Transfer Thread Finished'
        self._logbook.session.commit()
        
        self._txtLogbook.setEnabled(True)
        self._btnBrowse.setEnabled(True)
        self._cbxComputer.setEnabled(True)
        self._btnAddComputer.setEnabled(True)
        self._btnRemoveComputer.setEnabled(True)
        self._btnTransfer.setEnabled(True)
        self._btnExit.setEnabled(True)
开发者ID:asymworks,项目名称:python-divelog,代码行数:104,代码来源:qdcxfer.py

示例4: ExposureControl

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

    class Mode(Enum):
        AUTO = 1
        TV = 2
        AV = 4
        MANUAL = 8

        def __or__(self, other):
            return self.value | other.value

    def __init__(self, camera):
        super(ExposureControl, self).__init__()
        self.camera = camera
        self.initUI()

    def initUI(self):
        layout = QGridLayout()

        title = QLabel("Exposure")
        title.setAlignment(Qt.AlignCenter)
        layout.addWidget(title, 0, 0, 1, 4)

        btnAuto = OptionButton()
        btnAuto.setText("Full Auto")
        _safelyConnect(btnAuto.clicked, self.camera.setAutoExposure)
        btnAuto.setChecked(True)

        layout.addWidget(btnAuto, 1, 0)

        btnTV = OptionButton()
        btnTV.setText("Tv")
        _safelyConnect(btnTV.clicked, self.camera.setShutterPriority)

        layout.addWidget(btnTV, 1, 1)

        btnAV = OptionButton()
        btnAV.setText("Av")
        _safelyConnect(btnAV.clicked, self.camera.setAperturePriority)

        layout.addWidget(btnAV, 1, 2)

        btnManual = OptionButton()
        btnManual.setText("M")
        _safelyConnect(btnManual.clicked, self.camera.setManualExposure)

        layout.addWidget(btnManual, 1, 3)

        layout.addWidget(QLabel("Aperture"), 2, 0)

        self.aperture = QComboBox(self)
        for a in list(Aperture):
            self.aperture.addItem(a.label, userData=a)
        self.aperture.currentIndexChanged.connect(self.setAperture)
        self.aperture.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.aperture.setEnabled(False)

        layout.addWidget(self.aperture, 2, 1, 1, 3)

        layout.addWidget(QLabel("Shutter"), 3, 0)

        self.shutter = QComboBox(self)
        for s in list(Shutter):
            self.shutter.addItem(s.label, userData=s)
        self.shutter.currentIndexChanged.connect(self.setShutter)
        self.shutter.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.shutter.setEnabled(False)

        layout.addWidget(self.shutter, 3, 1, 1, 3)

        layout.addWidget(QLabel("Gain"), 4, 0)

        self.gain = QComboBox(self)
        for g in list(Gain):
            self.gain.addItem(g.label, userData=g)
        self.gain.currentIndexChanged.connect(self.setGain)
        self.gain.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.gain.setEnabled(False)

        layout.addWidget(self.gain, 4, 1, 1, 3)

        self.exposureButtons = QButtonGroup()
        self.exposureButtons.addButton(btnAuto, self.Mode.AUTO.value)
        self.exposureButtons.addButton(btnTV, self.Mode.TV.value)
        self.exposureButtons.addButton(btnAV, self.Mode.AV.value)
        self.exposureButtons.addButton(btnManual, self.Mode.MANUAL.value)

        self.exposureButtons.buttonClicked.connect(self.onExposureMethodSelected)

        layout.setRowStretch(0, 0)
        layout.setRowStretch(1, 1)
        layout.setRowStretch(2, 1)
        layout.setRowStretch(3, 1)
        layout.setRowStretch(4, 1)

        self.setLayout(layout)

    def onExposureMethodSelected(self):
        checked = self.exposureButtons.checkedId()
        self.aperture.setEnabled(checked & (self.Mode.MANUAL | self.Mode.AV))
#.........这里部分代码省略.........
开发者ID:staldates,项目名称:av-control,代码行数:103,代码来源:CameraControls.py

示例5: MassAttribute_UI

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

#.........这里部分代码省略.........
        self.setLocale(QLocale.C)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setAttribute(Qt.WA_QuitOnClose)

        self.setFixedWidth(300)
        self.setWindowTitle('Massive Attribute Modifier')

        # UI
        L_main = QVBoxLayout()

        self.WV_title = QLabel('')
        self.WV_title.setVisible(False)
        self.WV_title.setFont(QFont('Verdana', 10))
        self.WV_title.setContentsMargins(0, 0, 0, 7)

        self.WB_select = QPushButton('Select')
        self.WB_select.setVisible(False)
        self.WB_select.setFixedWidth(50)
        self.WB_select.clicked.connect(lambda: cmds.select(self.selection))

        self.WB_update = QPushButton('Update')
        self.WB_update.setFixedWidth(50)
        self.WB_update.clicked.connect(lambda:self.update_attributes(cmds.ls(sl=True)))

        self.WV_search = Filter()
        self.WV_search.textChanged.connect(self.filter)

        self.WC_cases = QCheckBox('Case sensitive')
        self.WC_cases.stateChanged.connect(self.filter)

        self.WC_types = QCheckBox('Type filtering')

        self.WL_attrtype = QComboBox()
        self.WL_attrtype.setEnabled(False)

        for i, ctx in enumerate(sorted(self.ctx_wide)):
            self.WL_attrtype.addItem(ctx.title())
            self.WL_attrtype.setItemIcon(i, self.ctx_icons[ctx])

        L_attrtype = line(self.WC_types, self.WL_attrtype)

        self.WC_types.stateChanged.connect(partial(self.update_attributes, self.selection))
        self.WC_types.stateChanged.connect(self.WL_attrtype.setEnabled)
        self.WL_attrtype.currentIndexChanged.connect(self.filter)

        self.WC_liveu = QCheckBox('Live')
        self.WC_liveu.stateChanged.connect(self.WB_update.setDisabled)
        self.WC_liveu.stateChanged.connect(self.set_callback)

        self.WC_histo = QCheckBox('Load history')
        self.WC_histo.setChecked(True)
        self.WC_histo.stateChanged.connect(partial(self.update_attributes, self.selection))

        self.WC_child = QCheckBox('Children')
        self.WC_child.stateChanged.connect(partial(self.update_attributes, self.selection))

        options = group('Options', line(self.WC_cases, L_attrtype),
                        line(self.WC_child, self.WC_histo, self.WC_liveu, self.WB_update))
        options.layout().setSpacing(2)

        self.WL_attributes = QTreeWidget()
        self.WL_attributes.setStyleSheet('QTreeView {alternate-background-color: #1b1b1b;}')
        self.WL_attributes.setAlternatingRowColors(True)
        self.WL_attributes.setHeaderHidden(True)
        self.WL_attributes.setRootIsDecorated(False)
开发者ID:DavideAlidosi,项目名称:May9,代码行数:69,代码来源:mass_attr.py

示例6: initUI

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setEnabled [as 别名]
    def initUI(self):
        grp = QGroupBox('Collision Primitive')
        grplay = QGridLayout()
        grp.setLayout(grplay)

        enabled = QCheckBox()
        benable = False
        if self.mdl.collprim:
            enabled.toggle()
            benable = True
        enabled.stateChanged.connect(self.enabled_changed)
        self.controls['collprim'] = enabled
        grplay.addWidget(QLabel('Enabled'), 0, 0)
        grplay.addWidget(enabled, 0, 1)

        widthl = QLabel('Dflt')
        grplay.addWidget(widthl, 1, 0)
        width = QDoubleSpinBox()
        width.setEnabled(benable)
        width.setValue(self.mdl.primitive[1])
        grplay.addWidget(width, 1, 1)
        self.controls['width'] = width
        self.controls['widthl'] = widthl

        heightl = QLabel('Dflt')
        grplay.addWidget(heightl, 1, 2)
        height = QDoubleSpinBox()
        height.setEnabled(benable)
        height.setValue(self.mdl.primitive[2])
        grplay.addWidget(height, 1, 3)
        self.controls['height'] = height
        self.controls['heightl'] = heightl

        depthl = QLabel('Dflt')
        grplay.addWidget(depthl, 1, 4)
        depth = QDoubleSpinBox()
        depth.setEnabled(benable)
        depth.setValue(self.mdl.primitive[3])
        grplay.addWidget(depth, 1, 5)
        self.controls['depth'] = depth
        self.controls['depthl'] = depthl

        numbox = QComboBox()
        numbox.addItems(self.mdl.collprim_by_name.keys())
        numbox.currentIndexChanged.connect(self.type_changed)
        numbox.setEnabled(benable)
        grplay.addWidget(QLabel('Type'), 0, 2)
        grplay.addWidget(numbox, 0, 3)
        self.controls['collprimtype'] = numbox
        if self.mdl.primitive[0] == 0:
            numbox.setCurrentIndex(0)
        elif self.mdl.primitive[0] == 1:
            numbox.setCurrentIndex(0)
        elif self.mdl.primitive[0] == 2:
            numbox.setCurrentIndex(1)
        elif self.mdl.primitive[0] == 4:
            numbox.setCurrentIndex(2)

        mainlay = QVBoxLayout()
        mainlay.addWidget(grp)

        btns = QHBoxLayout()
        btns.addStretch()

        save = QPushButton('Save')
        save.clicked.connect(self.save)
        close = QPushButton('Close')
        close.clicked.connect(self.close)

        btns.addWidget(save)
        btns.addWidget(close)

        mainlay.addLayout(btns)

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 200, 120)
        self.setWindowTitle('MSH Suite - {0} Collision Primitive'.format(self.mdl.name))
        self.update_labels()
        self.show()
开发者ID:Schlechtwetterfront,项目名称:mshsuite,代码行数:81,代码来源:model_dialogs.py


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