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


Python QTextEdit.setDate方法代码示例

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


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

示例1: setup

# 需要导入模块: from spyderlib.qt.QtGui import QTextEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QTextEdit import setDate [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)
开发者ID:KGerring,项目名称:package_sanity,代码行数:80,代码来源:pip_browse_widget.py


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