Python源码示例:PyQt5.QtCore.Qt.PartiallyChecked()
示例1
def __GetFields(self, parent):
fields = []
for i in range(parent.childCount()):
childItem = parent.child(i)
# leaf
if childItem.childCount() == 0:
if childItem.checkState(0) == Qt.Checked:
field = self.__GetFieldByShowName(self._fields, childItem.text(0))
fields.append(field)
continue
if childItem.checkState(0) == Qt.Checked or childItem.checkState(0) == Qt.PartiallyChecked:
field = self.__GetFields(childItem)
fields.extend(field)
return fields
示例2
def __GetFields(self, parent):
fields = []
for i in range(parent.childCount()):
childItem = parent.child(i)
# leaf
if childItem.childCount() == 0:
if childItem.checkState(0) == Qt.Checked:
field = self.__GetFieldByShowName(self._fields, childItem.text(0))
fields.append(field)
continue
if childItem.checkState(0) == Qt.Checked or childItem.checkState(0) == Qt.PartiallyChecked:
field = self.__GetFields(childItem)
fields.extend(field)
return fields
示例3
def __UpdateParent(self, child):
parent = child.parent()
if parent is None or parent is self: return
partiallySelected = False
selectedCount = 0
childCount = parent.childCount()
for i in range(childCount):
childItem = parent.child(i)
if childItem.checkState(0) == Qt.Checked:
selectedCount += 1
elif childItem.checkState(0) == Qt.PartiallyChecked:
partiallySelected = True
if partiallySelected:
parent.setCheckState(0, Qt.PartiallyChecked)
else:
if selectedCount == 0:
parent.setCheckState(0, Qt.Unchecked)
elif selectedCount > 0 and selectedCount < childCount:
parent.setCheckState(0, Qt.PartiallyChecked)
else:
parent.setCheckState(0, Qt.Checked)
self.__UpdateParent(parent)
示例4
def enable_check(self, enabled):
self.group.setCheckable(enabled)
self.group.setChecked(False)
self.noOutputCheckBox.setTristate(enabled)
if enabled:
self.noOutputCheckBox.setCheckState(Qt.PartiallyChecked)
self.noErrorCheckBox.setTristate(enabled)
if enabled:
self.killCheckBox.setCheckState(Qt.PartiallyChecked)
self.killCheckBox.setTristate(enabled)
if enabled:
self.killCheckBox.setCheckState(Qt.PartiallyChecked)
示例5
def get_settings(self):
settings = {}
if not (self.group.isCheckable() and not self.group.isChecked()):
if self.commandLineEdit.text().strip():
settings['command'] = self.commandLineEdit.text()
if self.noOutputCheckBox.checkState() != Qt.PartiallyChecked:
settings['no_output'] = self.noOutputCheckBox.isChecked()
if self.noErrorCheckBox.checkState() != Qt.PartiallyChecked:
settings['no_error'] = self.noErrorCheckBox.isChecked()
if self.killCheckBox.checkState() != Qt.PartiallyChecked:
settings['kill'] = self.killCheckBox.isChecked()
return settings
示例6
def group_check_state(self):
if not self.is_group:
return None
if self.childCount() == 0:
return Qt.Unchecked
if all(child.show for child in self.children):
return Qt.Checked
elif any(child.show for child in self.children):
return Qt.PartiallyChecked
else:
return Qt.Unchecked
示例7
def __UpdateParent(self, child):
parent = child.parent()
if parent is None or parent is self: return
partiallySelected = False
selectedCount = 0
childCount = parent.childCount()
for i in range(childCount):
childItem = parent.child(i)
if childItem.checkState(0) == Qt.Checked:
selectedCount += 1
elif childItem.checkState(0) == Qt.PartiallyChecked:
partiallySelected = True
if partiallySelected:
parent.setCheckState(0, Qt.PartiallyChecked)
else:
if selectedCount == 0:
parent.setCheckState(0, Qt.Unchecked)
elif selectedCount > 0 and selectedCount < childCount:
parent.setCheckState(0, Qt.PartiallyChecked)
else:
parent.setCheckState(0, Qt.Checked)
self.__UpdateParent(parent)