本文整理汇总了Python中spyderlib.qt.QtGui.QTextEdit.setCheckState方法的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit.setCheckState方法的具体用法?Python QTextEdit.setCheckState怎么用?Python QTextEdit.setCheckState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QTextEdit
的用法示例。
在下文中一共展示了QTextEdit.setCheckState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from spyderlib.qt.QtGui import QTextEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QTextEdit import setCheckState [as 别名]
def setup(self):
for label, value in self.data:
if DEBUG_FORMLAYOUT:
print("value:", value)
if label is None and value is None:
# Separator: (None, None)
self.formlayout.addRow(QLabel(" "), QLabel(" "))
self.widgets.append(None)
continue
elif label is None:
# Comment
self.formlayout.addRow(QLabel(value))
self.widgets.append(None)
continue
elif is_text_string(value):
if '\n' in value:
for linesep in (os.linesep, '\n'):
if linesep in value:
value = value.replace(linesep, u("\u2029"))
field = QTextEdit(value, self)
else:
field = QLineEdit(value, self)
elif isinstance(value, (list, tuple)):
value = list(value) # in case this is a tuple
selindex = value.pop(0)
field = QComboBox(self)
if isinstance(value[0], (list, tuple)):
keys = [key for key, _val in value]
value = [val for _key, val in value]
else:
keys = value
field.addItems(value)
if selindex in value:
selindex = value.index(selindex)
elif selindex in keys:
selindex = keys.index(selindex)
elif not isinstance(selindex, int):
print("Warning: '%s' index is invalid (label: " \
"%s, value: %s)" % (selindex, label, value),
file=STDERR)
selindex = 0
field.setCurrentIndex(selindex)
elif isinstance(value, bool):
field = QCheckBox(self)
field.setCheckState(Qt.Checked if value else Qt.Unchecked)
elif isinstance(value, QLabel):
field = QCheckBox(self)
field.setCheckState(Qt.Checked if value.text() else Qt.Unchecked)
elif isinstance(value, float):
field = QLineEdit(repr(value), self)
field.setValidator(QDoubleValidator(field))
dialog = self.get_dialog()
dialog.register_float_field(field)
self.connect(field, SIGNAL('textChanged(QString)'),
lambda text: dialog.update_buttons())
elif isinstance(value, int):
field = QSpinBox(self)
field.setRange(-1e9, 1e9)
field.setValue(value)
elif isinstance(value, datetime.datetime):
field = QDateTimeEdit(self)
field.setDateTime(value)
elif isinstance(value, datetime.date):
field = QDateEdit(self)
field.setDate(value)
else:
field = QLineEdit(repr(value), self)
self.formlayout.addRow(label, field)
self.widgets.append(field)