本文整理汇总了Python中PyQt5.QtWidgets.QDateTimeEdit方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QDateTimeEdit方法的具体用法?Python QtWidgets.QDateTimeEdit怎么用?Python QtWidgets.QDateTimeEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QDateTimeEdit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getInputValue
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDateTimeEdit [as 别名]
def getInputValue(self, key):
"""
Get the value of a single input. This is intended to Pythonify the Qt values that come natively
from the widgets. (ie. return a Python date rather than a QDate).
This is used internally by getOptions()
"""
one_input = self.inputs.get(key)
if one_input:
if isinstance(one_input, QtWidgets.QDateTimeEdit):
# DateTime
return one_input.dateTime().toString(QtCore.Qt.ISODate)
elif isinstance(one_input, QtWidgets.QAbstractButton):
# Radio/checkbox button
return str(one_input.isChecked())
elif isinstance(one_input, QtWidgets.QComboBox):
return one_input.currentText()
elif hasattr(one_input, 'text'):
return one_input.text()
raise Exception("Couldn't identify the QWidget type for %s (%s)" % (key, one_input))
return None
示例2: setInputValue
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QDateTimeEdit [as 别名]
def setInputValue(self, key, value):
"""
Set the input value based on a string from the options
"""
one_input = self.inputs.get(key)
if one_input:
if isinstance(one_input, QtWidgets.QDateTimeEdit):
# Ugh, complicated conversion from UTCDateTime
dt = QtCore.QDateTime.fromString(value, QtCore.Qt.ISODate)
one_input.setDateTime(dt)
elif isinstance(one_input, QtWidgets.QDoubleSpinBox):
# Float value
one_input.setValue(float(value))
elif isinstance(one_input, QtWidgets.QComboBox):
# Combo box
index = one_input.findText(value)
if index > -1:
one_input.setCurrentIndex(index)
elif isinstance(one_input, QtWidgets.QLineEdit):
# Text input
one_input.setText(value)
elif isinstance(one_input, QtWidgets.QAbstractButton):
# Radio/checkbox button
one_input.setChecked(strtobool(str(value)))
else:
raise Exception("Don't know how to set an input for %s (%s)" % (key, one_input))