本文整理汇总了Python中PySide.QtGui.QComboBox.setCurrentIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setCurrentIndex方法的具体用法?Python QComboBox.setCurrentIndex怎么用?Python QComboBox.setCurrentIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setCurrentIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
class AccountToolbarSection:
""" The Account Toolbar section """
def __init__(self, toolbar, table_view):
""" Initialize the Account Toolbar Section """
self.toolbar = toolbar
self.table_view = table_view
def addAccount(self):
""" Add Account Label and Combo Box to the UI """
label = QLabel("Account: ", self.toolbar)
self.toolbar.addWidget(label)
self.accountComboBox = QComboBox(self.toolbar)
UpdateComboBoxWithAccounts(self.accountComboBox)
self.accountComboBox.activated.connect(self.setAccount)
index = self.accountComboBox.findText(self.table_view.account.name)
if not index == -1:
self.accountComboBox.setCurrentIndex(index)
self.toolbar.addWidget(self.accountComboBox)
def setAccount(self, index):
""" Set the Transaction Account to view """
account = Accounts.all()[index]
self.table_view.updateTransactions(account=account)
self.toolbar.buildToolbarWidgets()
def tabSelected(self):
""" Update the Account Tab when the tab is selected """
text = self.accountComboBox.currentText()
UpdateComboBoxWithAccounts(self.accountComboBox)
index = self.accountComboBox.findText(text)
if not (index == -1):
self.accountComboBox.setCurrentIndex(index)
示例2: ChooseMarkerDialog
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
class ChooseMarkerDialog(QDialog):
def __init__(self,markers):
super(ChooseMarkerDialog, self).__init__()
self.setWindowTitle('Select final marker...')
markerLabel = QLabel('Marker:')
self.marker = QComboBox()
self.marker.addItems(markers)
self.marker.setCurrentIndex(-1)
layout = QGridLayout()
layout.addWidget(markerLabel,0,0)
layout.addWidget(self.marker,0,1)
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
layout.addWidget(self.buttons,100,0,1,2)
self.setLayout(layout)
def getMarker(self):
return self.marker.currentText()
@staticmethod
def run(markers,parent = None):
dialog = ChooseMarkerDialog(markers)
result = dialog.exec_()
marker = dialog.getMarker()
return (marker,result == QDialog.Accepted)
示例3: AddAreaDlg
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
class AddAreaDlg(QDialog):
def __init__(self, parent=None):
super(AddAreaDlg, self).__init__(parent)
self.setWindowTitle("New Relief Device Area")
name_label = QLabel("&Name:")
self.name_lineedit = QLineEdit()
self.name_lineedit.setMaxLength(200)
name_label.setBuddy(self.name_lineedit)
location_label = QLabel("&Location:")
self.location_combobox = QComboBox()
self.location_combobox.setEditable(True)
location_label.setBuddy(self.location_combobox)
self.browse_button = QPushButton("&Browse...")
button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
layout = QGridLayout()
layout.addWidget(name_label, 0, 0)
layout.addWidget(self.name_lineedit, 0, 1)
layout.addWidget(location_label, 1, 0)
layout.addWidget(self.location_combobox, 1, 1)
layout.addWidget(self.browse_button, 1, 2)
#layout.addWidget(QFrame.HLine, 2, 0)
layout.addWidget(button_box, 2, 1)
self.setLayout(layout)
self.browse_button.clicked.connect(self.browseFiles)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
def browseFiles(self):
self.dirname = QFileDialog.getExistingDirectory(self, "Select file location", options=QFileDialog.ShowDirsOnly)
self.location_combobox.insertItem(0, self.dirname)
self.location_combobox.setCurrentIndex(0)
def accept(self):
if len(self.name_lineedit.text().strip()) == 0:
QMessageBox.warning(self, "Error: Relief Device Area Name Blank", "The relief device area must be given a name.", QMessageBox.Ok)
self.name_lineedit.setFocus()
return
if len(self.location_combobox.currentText().strip()) == 0:
QMessageBox.warning(self, "Error: Location Blank", "You must save the relief device area file to a valid directory.", QMessageBox.Ok)
self.location_combobox.setFocus()
return
if not os.path.exists(self.location_combobox.currentText().replace("\\", "/")):
QMessageBox.warning(self, "Error: Directory Does Not Exist", "The specified directory does not exist.", QMessageBox.Ok)
self.location_combobox.setFocus()
return
if os.path.isfile(self.location_combobox.currentText().replace("\\", "/") + "/" + self.name_lineedit.text() + ".rda"):
if QMessageBox.question(self, "File Already Exists",
"The file {0} already exists at {1}. Are you sure you want to proceed and overwrite this file?".format(self.name_lineedit.text() + ".rda",
self.location_combobox.currentText().replace("\\", "/")), QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
self.name_lineedit.setFocus()
return
QDialog.accept(self)
def returnVals(self):
return self.name_lineedit.text(), self.location_combobox.currentText().replace("\\", "/") + "/"
示例4: addFilter
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
def addFilter(self):
""" Add Filter Label and Combo Box to the UI """
label = QLabel("Filter: ", self.toolbar)
self.toolbar.addWidget(label)
comboBox = QComboBox(self.toolbar)
comboBox.addItems(__filter_order__)
comboBox.activated.connect(self.setTransactionFilter)
index = [__transaction_filters__[filterText] for filterText in __filter_order__].index(self.table_view.filters)
comboBox.setCurrentIndex(index)
self.toolbar.addWidget(comboBox)
示例5: __init__
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
class DateToolbarSection:
""" Represents the Date Toolbar Section """
def __init__(self, toolbar, panel):
""" Initialize the Date Toolbar Section """
self.toolbar = toolbar
self.panel = panel
def addDateSection(self):
""" Add Date Section """
self.dateLabel = QLabel("Month: ", self.toolbar)
self.toolbar.addWidget(self.dateLabel)
self.setupMonthComboBox()
self.setupYearComboBox()
def setupMonthComboBox(self):
""" Setup the month combo box """
self.monthComboBox = QComboBox(self.toolbar)
self.monthComboBox.addItems(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"])
self.monthComboBox.activated.connect(self.setMonth)
self.monthComboBox.setCurrentIndex(self.getCategoryStatistics().month-1)
self.toolbar.addWidget(self.monthComboBox)
def setupYearComboBox(self):
""" Setup the year combo box """
self.yearComboBox = QComboBox(self.toolbar)
self.getTransactionYears()
self.yearComboBox.addItems([str(year) for year in self.transactionYears])
self.yearComboBox.activated.connect(self.setYear)
self.yearComboBox.setCurrentIndex(self.transactionYears.index(self.getCategoryStatistics().year))
self.toolbar.addWidget(self.yearComboBox)
def getTransactionYears(self):
""" Get the possible transacttion years """
self.transactionYearsSet = Transactions.getAllYears()
self.transactionYearsSet.add(self.getCategoryStatistics().year)
self.transactionYears = list(self.transactionYearsSet)
self.transactionYears.sort()
def setMonth(self, index):
""" Set the month """
categoryStatistics = self.getCategoryStatistics()
categoryStatistics.month = index+1
self.panel.updatePanel()
def setYear(self, index):
""" Set the year """
categoryStatistics = self.getCategoryStatistics()
categoryStatistics.year = int(self.yearComboBox.currentText())
self.panel.updatePanel()
def getCategoryStatistics(self):
""" Returns the Category Statistics """
return self.panel.categoryStatistics
示例6: _addComboBox
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
def _addComboBox(self, row, col, items, currentItem=None):
comb = QComboBox()
for it in items:
comb.addItem(it)
self.table.setCellWidget(row, col, comb)
if currentItem is not None:
if currentItem in items:
comb.setCurrentIndex(items.index(currentItem))
else:
print('invalid item: {}'.format(currentItem))
return comb
示例7: SimpleComboboxOption
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [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()
示例8: LCRow
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
class LCRow():
def __init__(self,fileName,experimentName,guess):
self.fileName = QLabel(fileName)
self.plateID = QLineEdit()
self.experiment = QLineEdit()
self.guess = QLabel(guess[0] + ', ' + guess[1])
self.robot = QComboBox()
self.platePosition = QComboBox()
self.plateID.setText(path.splitext(path.basename(fileName))[0])
self.experiment.setText(experimentName)
self.robot.addItems(['2000','FX','96'])
self.robot.setCurrentIndex(self.robot.findText(guess[0]))
self.platePosition.addItems(['Plate 0','Plate 1','Plate 2','Plate 3','Plate 4'])
self.platePosition.setCurrentIndex(self.platePosition.findText(guess[1]))
def getFileName(self): return self.fileName.text()
def getPlateID(self): return self.plateID.text()
def getExperiment(self): return self.experiment.text()
def getRobot(self): return self.robot.currentText()
def getPlatePosition(self): return self.platePosition.currentIndex()
示例9: ChoiceField
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
class ChoiceField(BaseInputField):
def __init__(self, choices, initial="", label=""):
super(ChoiceField, self).__init__(initial, label)
self._choices = choices
def create_widget(self, parent):
self._widget = QComboBox(parent)
self.update_view()
return self._widget
def update_view(self):
if isinstance(self._choices, list):
choices = self._choices
elif isinstance(self._choices, str):
choices = getattr(self.simple_widget, self._choices)
self._widget.clear()
self._widget.addItems([str(choice) for choice in choices])
if self.initial:
self._widget.setCurrentIndex(choices.index(self.initial))
def get_value_from(self, widget):
return widget.currentText()
示例10: ToolOther
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [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
#.........这里部分代码省略.........
示例11: TransferPanel
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
self.showMaximized()
# Open the Logbook
if file is not None:
self._openLogbook(file)
def _writeSettings(self):
'Write settings to the configuration'
settings = QSettings()
settings.beginGroup('MainWindow')
settings.setValue('pos', self.pos())
settings.setValue('size', self.size())
settings.setValue('max', self.isMaximized())
settings.setValue('file', self._logbookPath)
settings.endGroup()
def closeEvent(self, e):
'Intercept an OnClose event'
self._writeSettings()
e.accept()
#--------------------------------------------------------------------------
# Slots
@QtCore.Slot()
def _btnAddComputerClicked(self):
'Add a Dive Computer'
dc = AddDiveComputerWizard.RunWizard(self)
if dc is not None:
self._logbook.session.add(dc)
self._logbook.session.commit()
self._cbxComputer.model().reload()
self._cbxComputer.setCurrentIndex(self._cbxComputer.findText(dc.name))
@QtCore.Slot()
def _btnRemoveComputerClicked(self):
'Remove a Dive Computer'
idx = self._cbxComputer.currentIndex()
dc = self._cbxComputer.itemData(idx, Qt.UserRole+0)
if QMessageBox.question(self, self.tr('Delete Dive Computer?'),
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)
示例12: ParameterBox
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [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
示例13: ColorMapWidget
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
class ColorMapWidget(QWidget):
"""Interface for changing ColorMap information. It shows the current
color map selection, a selector for other colormaps, and the option
to cycle the color map by any number of ordinal values.
This widget was designed for use with the tab dialog. It can be used by
itself or it can be used as part of a bigger color tab.
Changes to this widget are emitted via a changeSignal as a ColorMap
object and this widget's tag.
"""
changeSignal = Signal(ColorMap, str)
def __init__(self, parent, initial_map, tag):
"""Creates a ColorMap widget.
parent
The Qt parent of this widget.
initial_map
The colormap set on creation.
tag
A name for this widget, will be emitted on change.
"""
super(ColorMapWidget, self).__init__(parent)
self.color_map = initial_map.color_map
self.color_map_name = initial_map.color_map_name
self.color_step = initial_map.color_step
self.step_size = initial_map.step_size
self.tag = tag
self.color_map_label = "Color Map"
self.color_step_label = "Cycle Color Map"
self.number_steps_label = "Colors"
self.color_step_tooltip = "Use the given number of evenly spaced " \
+ " colors from the map and assign to discrete values in cycled " \
+ " sequence."
layout = QVBoxLayout()
layout.addWidget(self.buildColorBarControl())
layout.addItem(QSpacerItem(5,5))
layout.addWidget(self.buildColorStepsControl())
self.setLayout(layout)
def buildColorBarControl(self):
"""Builds the portion of this widget for color map selection."""
widget = QWidget()
layout = QHBoxLayout()
label = QLabel(self.color_map_label)
self.colorbar = QLabel(self)
self.colorbar.setPixmap(QPixmap.fromImage(ColorBarImage(
self.color_map, 180, 15)))
self.mapCombo = QComboBox(self)
self.mapCombo.addItems(map_names)
self.mapCombo.setCurrentIndex(map_names.index(self.color_map_name))
self.mapCombo.currentIndexChanged.connect(self.colorbarChange)
layout.addWidget(label)
layout.addItem(QSpacerItem(5,5))
layout.addWidget(self.mapCombo)
layout.addItem(QSpacerItem(5,5))
layout.addWidget(self.colorbar)
widget.setLayout(layout)
return widget
@Slot(int)
def colorbarChange(self, ind):
"""Handles a selection of a different colormap."""
indx = self.mapCombo.currentIndex()
self.color_map_name = map_names[indx]
self.color_map = getMap(self.color_map_name)
self.colorbar.setPixmap(QPixmap.fromImage(ColorBarImage(
self.color_map, 180, 12)))
self.changeSignal.emit(ColorMap(self.color_map_name, self.color_step,
self.step_size), self.tag)
def buildColorStepsControl(self):
"""Builds the portion of this widget for color cycling options."""
widget = QWidget()
layout = QHBoxLayout()
self.stepBox = QCheckBox(self.color_step_label)
self.stepBox.stateChanged.connect(self.colorstepsChange)
self.stepEdit = QLineEdit("8", self)
# Setting max to sys.maxint in the validator causes an overflow! D:
self.stepEdit.setValidator(QIntValidator(1, 65536, self.stepEdit))
self.stepEdit.setEnabled(False)
self.stepEdit.editingFinished.connect(self.colorstepsChange)
if self.color_step > 0:
self.stepBox.setCheckState(Qt.Checked)
#.........这里部分代码省略.........
示例14: MTTFilterFileDialog
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
bookmark_layout.setContentsMargins(2, 2, 2, 2)
bookmark_frame.setLayout(bookmark_layout)
bookmark_frame.setFrameStyle(QFrame.Sunken)
bookmark_frame.setFrameShape(QFrame.StyledPanel)
self.bookmark_list = MTTBookmarkList()
self.bookmark_list.bookmarkDeleted.connect(self.do_delete_bookmark)
self.bookmark_list.setAlternatingRowColors(True)
self.bookmark_list.dragEnabled()
self.bookmark_list.setAcceptDrops(True)
self.bookmark_list.setDropIndicatorShown(True)
self.bookmark_list.setDragDropMode(QListView.InternalMove)
self.bookmark_list_sel_model = self.bookmark_list.selectionModel()
self.bookmark_list_sel_model.selectionChanged.connect(
self.on_select_bookmark)
bookmark_layout.addWidget(self.bookmark_list)
bookmark_parent_layout.addWidget(bookmark_frame)
bookmark_parent_layout.addLayout(content_layout)
main_layout.addLayout(bookmark_parent_layout)
self.do_populate_bookmarks()
else:
main_layout.addLayout(content_layout)
if not self.defined_type:
# type layout
self.types = QComboBox()
self.types.addItems(self.supported_node_type)
self.types.currentIndexChanged.connect(self.on_node_type_changed)
if cmds.optionVar(exists='MTT_lastNodeType'):
last = cmds.optionVar(query='MTT_lastNodeType')
if last in self.supported_node_type:
self.types.setCurrentIndex(
self.supported_node_type.index(last))
buttons_layout.addWidget(self.types)
if not self.defined_path or not self.defined_type:
create_btn = QPushButton('C&reate')
create_btn.clicked.connect(self.accept)
cancel_btn = QPushButton('&Cancel')
cancel_btn.clicked.connect(self.reject)
buttons_layout.addStretch()
buttons_layout.addWidget(create_btn)
buttons_layout.addWidget(cancel_btn)
def __create_filter_ui(self):
""" Create filter widgets """
filter_layout = QHBoxLayout()
filter_layout.setSpacing(1)
filter_layout.setContentsMargins(0, 0, 0, 0)
self.filter_reset_btn = QPushButton()
icon = QIcon(':/filtersOff.png')
self.filter_reset_btn.setIcon(icon)
self.filter_reset_btn.setIconSize(QSize(22, 22))
self.filter_reset_btn.setFixedSize(24, 24)
self.filter_reset_btn.setToolTip('Reset filter')
self.filter_reset_btn.setFlat(True)
self.filter_reset_btn.clicked.connect(
partial(self.on_filter_set_text, ''))
self.filter_line = QLineEdit()
self.filter_line.setPlaceholderText('Enter filter string here')
self.filter_line.textChanged.connect(self.on_filter_change_text)
示例15: _SeriesDialog
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setCurrentIndex [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 = []
#.........这里部分代码省略.........