本文整理匯總了Python中PyQt4.QtCore.QDate方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QDate方法的具體用法?Python QtCore.QDate怎麽用?Python QtCore.QDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.QDate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QDate [as 別名]
def __init__(self, title="Calendar"):
super(CalendarWidget, self).__init__()
self.setWindowTitle(title)
layout = qt_widgets.QGridLayout()
layout.setColumnStretch(1, 1)
self.cal = qt_widgets.QCalendarWidget(self)
self.cal.setGridVisible(True)
self.cal.clicked[QtCore.QDate].connect(self.show_date)
layout.addWidget(self.cal, 0, 0, 1, 2)
self.date_label = qt_widgets.QLabel()
self.date = self.cal.selectedDate()
self.date_label.setText(self.date.toString())
layout.addWidget(self.date_label, 1, 0)
button_box = qt_widgets.QDialogButtonBox()
confirm_button = button_box.addButton(qt_widgets.QDialogButtonBox.Ok)
confirm_button.clicked.connect(self.confirm)
layout.addWidget(button_box, 1, 1)
self.setLayout(layout)
self.show()
self.raise_()
示例2: __setitem__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QDate [as 別名]
def __setitem__(self, key, value):
isDate = False
if isinstance(value, QDate):
value = value.toString('MM/dd/yyyy')
isDate = True
elif isinstance(value, date):
value = value.strftime('%m/%d/%Y')
isDate = True
elif not isinstance(value, (float, int, str, unicode, QString)):
value = repr(value)
# addProperty is also setProperty
if isDate:
mxs.fileProperties.addProperty(self.customName, key, value, mxs.pyhelper.namify('date'))
else:
mxs.fileProperties.addProperty(self.customName, key, value)
self.emitChange(key)
示例3: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QDate [as 別名]
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
self.start_date = '1984-04-25'
# Sets end date to current date.
self.end_date = str((QtCore.QDate.currentDate()).toString('yyyy-MM-dd'))
self.selected_lake = 'Lake Tahoe'
self.selectlakeDropMenu.activated[str].connect(self.selectLakeHandle)
self.okBtn.clicked.connect(self.okHandle)
# Sets end date as current date. Couldn't set this option in QT Designer
self.endDate.setDate(QtCore.QDate.currentDate())
self.endDate.dateChanged[QtCore.QDate].connect(self.endHandle)
self.startDate.dateChanged[QtCore.QDate].connect(self.startHandle)
self.faiState = False
self.ndtiState = False
self.completedSignal.connect(self.completeLakeThread, QtCore.Qt.QueuedConnection)
示例4: add_non_entity_parent
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QDate [as 別名]
def add_non_entity_parent(self, layer_icon):
"""
Adds details of layers that are view based.
:param layer_icon: The icon of the tree node.
:type layer_icon: QIcon
"""
for feature_map in self.features_data():
parent = QStandardItem(
layer_icon,
format_name(unicode(self.layer.name()))
)
for k, v, in feature_map.iteritems():
if isinstance(v, QDate):
v = v.toPyDate()
if isinstance(v, QDateTime):
v = v.toPyDateTime()
if k != 'id':
child = QStandardItem(u'{}: {}'.format(
format_name(k, False), v)
)
child.setSelectable(False)
parent.appendRow([child])
self.model.appendRow(parent)
self.set_bold(parent)
self.expand_node(parent)
示例5: to_pydate
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QDate [as 別名]
def to_pydate(self, q_date):
"""
Converts QDate to normal python date
:param q_date: PyQT QDate type
:type q_date: QDate
:return: Python date
:rtype: datetime.date
"""
return q_date.toPyDate() if isinstance(q_date, QDate) else q_date
示例6: _addFeatures
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QDate [as 別名]
def _addFeatures(self, addedFeatures):
for featureID, feature in addedFeatures.iteritems():
QgsMessageLog.logMessage('Add feature with feature ID: ' + str(featureID), 'CartoDB Plugin', QgsMessageLog.INFO)
sql = "INSERT INTO " + self._schema() + self.cartoTable + " ("
addComma = False
fieldsStr = ""
valuesStr = ""
for field in feature.fields():
value = feature[field.name()]
if unicode(value) == 'NULL' or value is None:
continue
elif isinstance(value, QDate):
if value.isNull():
continue
else:
value = value.toString(Qt.ISODate)
if addComma:
fieldsStr = fieldsStr + ", "
valuesStr = valuesStr + ", "
fieldsStr = fieldsStr + field.name()
valuesStr = valuesStr + "'" + unicode(value) + "'"
addComma = True
if feature.geometry() is not None:
if addComma:
fieldsStr = fieldsStr + ", "
valuesStr = valuesStr + ", "
fieldsStr = fieldsStr + "the_geom"
valuesStr = valuesStr + "ST_GeomFromText('" + feature.geometry().exportToWkt() + "', 4326)"
sql = sql + fieldsStr + ") VALUES (" + valuesStr + ") RETURNING cartodb_id"
nullableFields = ['cartodb_id']
if feature.fieldNameIndex("created_at") != -1:
sql = sql + ", created_at"
nullableFields.append('created_at')
if feature.fieldNameIndex("updated_at") != -1:
sql = sql + ", updated_at"
nullableFields.append('updated_at')
sql = sql.encode('utf-8')
res = self._updateSQL(sql, 'Some error ocurred inserting feature')
if isinstance(res, dict) and res['total_rows'] == 1:
self.iface.messageBar().pushMessage('Info',
'Feature inserted at CartoDB servers',
level=self.iface.messageBar().INFO, duration=10)
for f in nullableFields:
self._updateNullableFields(featureID, f, res['rows'][0][f])