本文整理汇总了Python中PyQt5.QtGui.QStandardItem.setCheckState方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setCheckState方法的具体用法?Python QStandardItem.setCheckState怎么用?Python QStandardItem.setCheckState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.setCheckState方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scanPath
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def scanPath(self):
path=self.path
sbpCheck=self.subPathCheck.checkState()==2
listdir=[]
if sbpCheck:
[[listdir.append(p.replace(path+os.sep,"")+os.sep+x if p.replace(path,"")!="" else x) for x in f] for (p,d,f) in os.walk(path)]
else:
listdir=os.listdir(path)
#print(listdir)
iconDict={"doc":QIcon("icons\\doc.png"),"docx":QIcon("icons\\docx.png")}
model=self.FilesTableModel
model.clear()
self.FilesList.clear()
for x in listdir:
filepath=self.path+os.sep+x
if not os.path.exists(filepath) or os.path.isdir(filepath): continue
attrs=win32api.GetFileAttributes(filepath)
#print(p,x, attrs, win32con.FILE_ATTRIBUTE_HIDDEN) Исключаем все скрытые файлы
if attrs in [2,3,34,35]: continue#win32con.FILE_ATTRIBUTE_HIDDEN=2,arch=32,readonly=1
keyIcon=x.split(".")[-1]
if keyIcon in iconDict.keys():
item=QStandardItem(iconDict[keyIcon],x)
item.setCheckable(True)
item.setCheckState(2)
item.setEditable(False)
model.appendRow(item)
self.ChangeFilesList()
示例2: fillReferences
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def fillReferences(self):
for value in self.referenceList:
item = QStandardItem(value[0])
check = Qt.Checked if value[1] else Qt.Unchecked
item.setCheckState(check)
item.setCheckable(True)
self.referenceListModel.appendRow(item)
示例3: setModelData
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def setModelData(self, items, checkedItems):
self.clear()
for item in items:
modelItem = QStandardItem(item)
if item in checkedItems:
modelItem.setCheckState(Qt.Checked)
else:
modelItem.setCheckState(Qt.Unchecked)
self.appendRow(modelItem)
示例4: __init__
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def __init__(self, db):
super(TagChooser,self).__init__()
self.db = db
self.filter = u''
self.data = QStandardItemModel()
self.proxy = QSortFilterProxyModel()
self.proxy.setSourceModel(self.data)
self.setModel(self.proxy)
self.data.itemChanged.connect(self.changed)
for t in sorted(self.db.list_tags()):
item = QStandardItem(t)
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
item.setCheckState(Qt.Unchecked)
self.data.appendRow(item)
示例5: update_list_view
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def update_list_view(self, xind):
self.mass_list = []
for i in range(len(xind)):
m = "{:.1f}".format(float(xind[i]))
self.mass_list.append(str(m))
self.model.clear()
self.model = QStandardItemModel()
for mass in self.mass_list:
item = QStandardItem(mass)
item.setCheckable(True)
item.setEditable(True)
item.setCheckState(Qt.Checked)
self.model.appendRow(item)
self.view = self.ui.listView_Mass
self.view.setModel(self.model)
# changes in one item, don't know which one
self.model.itemChanged.connect(self.change_list)
示例6: __init__
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def __init__(self, availableScalars, scalarsToShow, parent=None):
"""
Constructor
@param parent reference to the parent widget (QWidget)
"""
super().__init__(parent)
self.setupUi(self)
self.ValueListModel = QStandardItemModel()
for value in availableScalars:
item = QStandardItem(value)
check = Qt.Checked if value in scalarsToShow else Qt.Unchecked
item.setCheckState(check)
item.setCheckable(True)
self.ValueListModel.appendRow(item)
self.ValueListView.setModel(self.ValueListModel)
示例7: fill_tree
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def fill_tree(self, children: List[FsFileInfo]) -> None:
self.item.removeRows(0, self.item.rowCount())
for child in self.tree.sort_children(children):
subitem = QStandardItem(child.get_label())
if child.checkable():
subitem.setCheckable(True)
subitem.setCheckState(True)
subitem.setTristate(True)
subitem.setCheckState(child.state)
subitem.setEnabled(child.enable())
subitem.setSelectable(child.selectable())
subitem.setEditable(False)
subitem.setData(QVariant(child), Qt.UserRole)
if child.folderish():
# Add "Loading..." entry in advance for when the user
# will click to expand it.
loaditem = QStandardItem(Translator.get("LOADING"))
loaditem.setSelectable(False)
subitem.appendRow(loaditem)
self.item.appendRow(subitem)
示例8: refreshInputDirectory
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def refreshInputDirectory(self):
if not str(self.ui.lineInputDir.text()):
return
self.listViewFilesModel = QStandardItemModel(self.ui.listViewFiles)
self.listViewFilesModel.itemChanged.connect(self.listViewChanged)
self.inputFiles = []
for file in os.listdir(self.ui.lineInputDir.text()):
if self.ui.lineFilter.text().upper() in file.upper():
if file.endswith(".svg"):
item = QStandardItem(file)
item.setCheckable(True)
item.setCheckState(QtCore.Qt.Unchecked)
self.listViewFilesModel.appendRow(item)
self.ui.listViewFiles.setModel(self.listViewFilesModel)
if self.listViewFilesModel.rowCount() == 1:
self.ui.labelFilter.setText("{0} svg file found".format(self.listViewFilesModel.rowCount()))
else:
self.ui.labelFilter.setText("{0} svg files found".format(self.listViewFilesModel.rowCount()))
self.ui.labelSelected.setText("0 svg files selected")
self.ui.btnConvert.setEnabled(False)
示例9: __updateSlotsModel
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def __updateSlotsModel(self):
"""
Private slot to update the slots tree display.
"""
self.filterEdit.clear()
try:
dlg = uic.loadUi(
self.formFile, package=self.project.getProjectPath())
objects = dlg.findChildren(QWidget) + dlg.findChildren(QAction)
signatureList = self.__signatures()
self.slotsModel.clear()
self.slotsModel.setHorizontalHeaderLabels([""])
for obj in objects:
name = obj.objectName()
if not name or name.startswith("qt_"):
# ignore un-named or internal objects
continue
metaObject = obj.metaObject()
className = metaObject.className()
itm = QStandardItem("{0} ({1})".format(name, className))
self.slotsModel.appendRow(itm)
for index in range(metaObject.methodCount()):
metaMethod = metaObject.method(index)
if metaMethod.methodType() == QMetaMethod.Signal:
if qVersion() >= "5.0.0":
itm2 = QStandardItem("on_{0}_{1}".format(
name,
bytes(metaMethod.methodSignature()).decode()))
else:
itm2 = QStandardItem("on_{0}_{1}".format(
name, metaMethod.signature()))
itm.appendRow(itm2)
if self.__module is not None:
if qVersion() >= "5.0.0":
method = "on_{0}_{1}".format(
name,
bytes(metaMethod.methodSignature())
.decode().split("(")[0])
else:
method = "on_{0}_{1}".format(
name, metaMethod.signature().split("(")[0])
method2 = "{0}({1})".format(
method, ", ".join(
[self.__mapType(t)
for t in metaMethod.parameterTypes()]))
if method2 in signatureList or \
method in signatureList:
itm2.setFlags(Qt.ItemFlags(Qt.ItemIsEnabled))
itm2.setCheckState(Qt.Checked)
itm2.setForeground(QBrush(Qt.blue))
continue
returnType = self.__mapType(
metaMethod.typeName().encode())
if returnType == 'void':
returnType = ""
parameterTypesList = [
self.__mapType(t)
for t in metaMethod.parameterTypes()]
pyqtSignature = ", ".join(parameterTypesList)
parameterNames = metaMethod.parameterNames()
if parameterNames:
for index in range(len(parameterNames)):
if not parameterNames[index]:
parameterNames[index] = \
QByteArray("p{0:d}".format(index)
.encode("utf-8"))
parameterNamesList = [bytes(n).decode()
for n in parameterNames]
methNamesSig = ", ".join(parameterNamesList)
if methNamesSig:
if qVersion() >= "5.0.0":
pythonSignature = \
"on_{0}_{1}(self, {2})".format(
name,
bytes(metaMethod.methodSignature())
.decode().split("(")[0],
methNamesSig)
else:
pythonSignature = \
"on_{0}_{1}(self, {2})".format(
name,
metaMethod.signature().split("(")[0],
methNamesSig)
else:
if qVersion() >= "5.0.0":
pythonSignature = "on_{0}_{1}(self)".format(
name,
bytes(metaMethod.methodSignature())
.decode().split("(")[0])
else:
pythonSignature = "on_{0}_{1}(self)".format(
name,
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def __init__(self, font, parent=None):
super().__init__(parent, name="OS/2")
# OS2Group = QGroupBox("OS/2 table", self)
# OS2Group.setFlat(True)
OS2Layout = QGridLayout(self)
usWidthClassLabel = QLabel("usWidthClass:", self)
self.usWidthClassDrop = QComboBox(self)
items = [
"None", "Ultra-condensed", "Extra-condensed", "Condensed",
"Semi-Condensed", "Medium (normal)", "Semi-expanded", "Expanded",
"Extra-expanded", "Ultra-expanded"]
self.usWidthClassDrop.insertItems(0, items)
if font.info.openTypeOS2WidthClass is not None:
self.usWidthClassDrop.setCurrentIndex(
font.info.openTypeOS2WidthClass)
fsSelectionLabel = QLabel("fsSelection:", self)
fsSelection = font.info.openTypeOS2Selection
self.fsSelectionList = QListView(self)
items = [
"1 UNDERSCORE", "2 NEGATIVE", "3 OUTLINED", "4 STRIKEOUT",
"7 USE_TYPO_METRICS", "8 WWS", "9 OBLIQUE"]
# http://stackoverflow.com/a/26613163
model = QStandardItemModel(7, 1)
for index, elem in enumerate(items):
item = QStandardItem()
item.setText(elem)
item.setCheckable(True)
bit = index + 1
if fsSelection is not None and bit in fsSelection:
# maybe default setting? if so, unneeded
item.setCheckState(Qt.Checked)
else:
item.setCheckState(Qt.Unchecked)
model.setItem(index, item)
self.fsSelectionList.setModel(model)
achVendorIDLabel = QLabel("achVendorID:", self)
self.achVendorIDEdit = QLineEdit(font.info.openTypeOS2VendorID, self)
self.achVendorIDEdit.setMaxLength(4)
fsTypeLabel = QLabel("fsType:", self)
fsType = font.info.openTypeOS2Type
self.fsTypeDrop = QComboBox(self)
items = [
"No embedding restrictions", "Restricted embedding",
"Preview and print embedding allowed",
"Editable embedding allowed"]
self.allowSubsettingBox = QCheckBox("Allow subsetting", self)
self.allowBitmapEmbeddingBox = QCheckBox(
"Allow only bitmap embedding", self)
self.fsTypeDrop.currentIndexChanged[int].connect(
self._updateFsTypeVisibility)
self.fsTypeDrop.insertItems(0, items)
if fsType is not None:
for i in range(1, 4):
if i in fsType:
self.fsTypeDrop.setCurrentIndex(i)
break
self.allowSubsettingBox.setChecked(8 not in fsType)
self.allowBitmapEmbeddingBox.setChecked(9 in fsType)
# XXX: ulUnicodeRange
# XXX: ulCodePageRange
sTypoAscenderLabel = QLabel("sTypoAscender:", self)
sTypoDescenderLabel = QLabel("sTypoDescender:", self)
sTypoLineGapLabel = QLabel("sTypoLineGap:", self)
usWeightClassLabel = QLabel("usWeightClass:", self)
usWinAscentLabel = QLabel("usWinAscent:", self)
usWinDescentLabel = QLabel("usWinDescent:", self)
ySubscriptXSizeLabel = QLabel("ySubscriptXSize:", self)
ySubscriptYSizeLabel = QLabel("ySubscriptYSize:", self)
ySubscriptXOffsetLabel = QLabel("ySubscriptXOffset:", self)
ySubscriptYOffsetLabel = QLabel("ySubscriptYOffset:", self)
ySuperscriptXSizeLabel = QLabel("ySuperscriptXSize:", self)
ySuperscriptYSizeLabel = QLabel("ySuperscriptYSize:", self)
ySuperscriptXOffsetLabel = QLabel("ySuperscriptXOffset:", self)
ySuperscriptYOffsetLabel = QLabel("ySuperscriptYOffset:", self)
yStrikeoutSizeLabel = QLabel("yStrikeoutSize:", self)
yStrikeoutPositionLabel = QLabel("yStrikeoutPosition:", self)
self.loadPositiveInteger(
font, "openTypeOS2WeightClass", "usWeightClass")
self.loadInteger(font, "openTypeOS2TypoAscender", "sTypoAscender")
self.loadInteger(font, "openTypeOS2TypoDescender", "sTypoDescender")
self.loadInteger(font, "openTypeOS2TypoLineGap", "sTypoLineGap")
self.loadPositiveInteger(font, "openTypeOS2WinAscent", "usWinAscent")
self.loadPositiveInteger(font, "openTypeOS2WinDescent", "usWinDescent")
self.loadInteger(font, "openTypeOS2SubscriptXSize", "ySubscriptXSize")
self.loadInteger(font, "openTypeOS2SubscriptYSize", "ySubscriptYSize")
self.loadInteger(
font, "openTypeOS2SubscriptXOffset", "ySubscriptXOffset")
self.loadInteger(
font, "openTypeOS2SubscriptYOffset", "ySubscriptYOffset")
self.loadInteger(
font, "openTypeOS2SuperscriptXSize", "ySuperscriptXSize")
self.loadInteger(
#.........这里部分代码省略.........
示例11: _createItem
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setCheckState [as 别名]
def _createItem(self, name):
item = QStandardItem(name)
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
item.setCheckState(Qt.Unchecked)
return item