本文整理汇总了Python中PyQt5.QtCore.QDate.fromString方法的典型用法代码示例。如果您正苦于以下问题:Python QDate.fromString方法的具体用法?Python QDate.fromString怎么用?Python QDate.fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QDate
的用法示例。
在下文中一共展示了QDate.fromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _populate
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def _populate(self):
self.event_type_edit.setText(self.data['event_type'])
self.description_edit.setText(self.data['description'])
self.from_date.setDate(QDate.fromString(self.data['from_date']))
self.to_date.setDate(QDate.fromString(self.data['to_date']))
self.exp_no_edit.setText(self.data['exp_no'])
self.planned_budget_edit.setText(self.data['planned_budget'])
self.decorations_edit.setText(self.data['decorations'])
self.filming_edit.setText(self.data['filming'])
self.poster_edit.setText(self.data['poster'])
self.food_edit.setText(self.data['food'])
self.music_edit.setText(self.data['music'])
self.computer_edit.setText(self.data['computer'])
self.other_edit.setText(self.data['other'])
self.approved_check_box.setChecked(self.data['approved'])
示例2: data_changed
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def data_changed(self, index1, index2, roles):
assert isinstance(index1, QModelIndex)
if index1.column() == 1:
if not index1.data():
QMessageBox.critical(None,
"Invalid data",
"Field cannot be empty.",
QMessageBox.Ok)
self.model.revertRow(index1.row())
elif len(str(index1.data())) != len(str(index1.data()).strip()):
QMessageBox.critical(None,
"Invalid data",
"Unwanted whitespace character.",
QMessageBox.Ok)
if index1.column() == 2 and index1.data() not in ("0", "1"):
QMessageBox.critical(None,
"Invalid data",
"Team field must be either 0 or 1.",
QMessageBox.Ok)
self.model.revertRow(index1.row())
if index1.column() == 3:
date = QDate.fromString(index1.data(), "yyyy-MM-dd")
if not date.isValid():
QMessageBox.critical(None,
"Invalid data",
"Entry date field is invalid.",
QMessageBox.Ok)
self.model.revertRow(index1.row())
示例3: setEditorData
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def setEditorData(self, widget, modelIndex):
Lumberjack.info('< MyItemDelegate > - -> (setEditorData)')
if hasattr(widget, 'currentIndex'):
widget.currentItem = modelIndex.data(role=Qt.EditRole)
elif hasattr(widget, 'currentFile'):
widget.currentFile = modelIndex.data(role=Qt.EditRole)
elif hasattr(widget, 'isChecked'):
widget.setChecked(modelIndex.data(role=Qt.EditRole))
elif hasattr(widget, 'date'):
date = str(modelIndex.data(role=Qt.EditRole))
qtDate = QDate.fromString(date, 'yyyy-MM-dd')
widget.setDate(qtDate)
elif hasattr(widget, 'amount'):
value = modelIndex.data(role=Qt.EditRole)
Lumberjack.debug('(setEditorData) - amount = {}({})'.format(type(value), value))
widget.amount = value
elif hasattr(widget, 'text'):
widget.setText(modelIndex.data())
elif hasattr(widget, 'recurrenceValue'):
widget.recurrenceValue = modelIndex.data(role=Qt.EditRole)
else:
Lumberjack.warning('(setEditorData) - NO MATCH FOUND!')
Lumberjack.debug('(setEditorData) - mismatching widget = {}'.format(widget))
for attr in widget.__dict__:
Lumberjack.debug('(setEditorData) - widget attr = {}'.format(attr))
示例4: _display_track
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def _display_track(self, track):
self._track_number.setText(self.tr("Track {0} of {1}").format(track.track_number, track.total_tracks))
self._track_title.setText(track.track_title)
self._main_artist.setText(track.lead_performer)
self._version.setText(track.version_info)
self._duration.setText(formatting.to_duration(track.duration))
self._bitrate.setText("{0} kbps".format(formatting.in_kbps(track.bitrate)))
self._featured_guest.setText(track.featured_guest)
self._comments.setPlainText(track.comments)
self._isrc.setText(track.isrc)
self._iswc.setText(track.iswc)
self._tags.setText(track.labels)
self._lyrics.setPlainText(track.lyrics)
self._language.setCurrentText(self.tr(LANGUAGES[track.language or 'und']))
self._software_notice.setText(self._compose_software_notice(track))
self._recording_studio.setText(track.recording_studio)
self._recording_time.setDate(QDate.fromString(track.recording_time, ISO_8601_FORMAT))
self._recording_studio_address.setText(track.recording_studio_address)
self._display_region(track.recording_studio_region, self._recording_studio_region)
self._music_producer.setText(track.music_producer)
self._production_company.setText(track.production_company)
self._display_region(track.production_company_region, self._production_company_region)
self._mixer.setText(track.mixer)
self._genre.setEditText(track.primary_style)
示例5: setGallery
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def setGallery(self, gallery):
"To be used for when editing a gallery"
self.gallery = gallery
self.url_edit.setText(gallery.link)
self.title_edit.setText(gallery.title)
self.author_edit.setText(gallery.artist)
self.descr_edit.setText(gallery.info)
self.tags_edit.setText(utils.tag_to_string(gallery.tags))
self._find_combobox_match(self.lang_box, gallery.language, 2)
self._find_combobox_match(self.type_box, gallery.type, 0)
self._find_combobox_match(self.status_box, gallery.status, 0)
gallery_pub_date = "{}".format(gallery.pub_date).split(' ')
try:
self.gallery_time = datetime.strptime(gallery_pub_date[1], '%H:%M:%S').time()
except IndexError:
pass
qdate_pub_date = QDate.fromString(gallery_pub_date[0], "yyyy-MM-dd")
self.pub_edit.setDate(qdate_pub_date)
self.link_lbl.setText(gallery.link)
self.path_lbl.setText(gallery.path)
示例6: loadFromFile
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def loadFromFile(self, fileName= None):
if not fileName:
fileName, _ = QFileDialog.getOpenFileName(self, "Open Address Book",
'', "Address Book (*.bl);;All Files (*)")
try:
in_file = open(str(fileName), 'rb')
except IOError:
QMessageBox.information(self, "Unable to open file",
"There was an error opening \"%s\"" % fileName)
return
self.contacts = pickle.load(in_file)
in_file.close()
if len(self.contacts) == 0:
QMessageBox.information(self, "No contacts in file",
"The file you are attempting to open contains no "
"contacts.")
else:
for title, obj in self.contacts:
date = QDate.fromString(obj['dokuryodate'])
self.titleLine.setText(title)
self.memoText.setText(obj['memo'])
self.shoziflag.setChecked(obj['shoziflag'])
self.isbnLine.setText(obj['isbn'])
self.dokuryodate.setDate(date)
self.updateInterface(self.NavigationMode)
示例7: get_statistic_items
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def get_statistic_items(self):
cursor = self.__connection.cursor()
results = {}
try:
cursor.execute(self.__WALLET_GET_METADATA_PERIODS_QUERY)
periods = cursor.fetchall()
if not periods:
return results
periods = [p[0] for p in periods]
old = periods[0]
for period in periods:
# Конвертируем данные в QDate
current_month_date = QDate.fromString(period, self.WalletDatabaseConvertor.WALLET_DATE_DB_FORMAT)
year = current_month_date.year()
month = current_month_date.month()
next_month = (current_month_date.month() + 1
if not current_month_date.month() == 12
else 1)
next_year = (current_month_date.year() + 1
if not current_month_date.month() == 12
else current_month_date.year())
next_date = QDate(next_year, next_month, current_month_date.day())
data_range = WalletDataRange(current_month_date, next_date, old)
metadata = self.get_metadata(data_range=data_range, cache_result=False)
if year not in results.keys():
results[year] = [(month, metadata)]
else:
results[year].append((month, metadata))
except sqlite3.Error as e:
raise WalletDatabaseException(tr('WalletDatabase', 'Could not get statistic periods: %s') % e)
return results
示例8: convert_to_database
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def convert_to_database(item):
elements = {}
for column in range(0, max(item.keys()) + 1):
data = 'NULL'
element = item.get(column, 'NULL')
if column == WalletItemModelType.INDEX_DATE.value and element:
if isinstance(element, QDate):
data = '\'%s\'' % element.toString(WalletDatabase.WalletDatabaseConvertor.WALLET_DATE_DB_FORMAT)
elif isinstance(element, str):
date = QDate.fromString(element, WalletDatabase.WalletDatabaseConvertor.WALLET_DATE_VIEW_FORMAT)
data = '\'%s\'' % date.toString(WalletDatabase.WalletDatabaseConvertor.WALLET_DATE_DB_FORMAT)
elif column == WalletItemModelType.INDEX_DESCRIPTION.value and element:
data = '\'%s\'' % element
elif (column == WalletItemModelType.INDEX_INCOMING.value or
column == WalletItemModelType.INDEX_EXPENSE.value or
column == WalletItemModelType.INDEX_SAVINGS.value or
column == WalletItemModelType.INDEX_DEBT.value) and element:
data = '%s' % element
elements[column] = data
# Обработка исключительных ситуаций
value = item.get(WalletItemModelType.INDEX_SAVINGS.value, None)
if value:
elements[WalletItemModelType.INDEX_INCOMING.value] = str(-1 * float(value))
value = item.get(WalletItemModelType.INDEX_DEBT.value, None)
if value:
elements[WalletItemModelType.INDEX_INCOMING.value] = str(value)
return elements
示例9: display
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def display(self, album):
self._display_cover(album.main_cover)
self._title.setText(album.release_name)
self._display_main_artist(album)
self._label_name.setText(album.label_name)
self._catalog_number.setText(album.catalog_number)
self._barcode.setText(album.upc)
self._release_time.setDate(QDate.fromString(album.release_time, ISO_8601_FORMAT))
示例10: changeDateFormat
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def changeDateFormat(self):
action = self.sender()
oldFormat = self.currentDateFormat
newFormat = self.currentDateFormat = action.text()
for row in range(self.table.rowCount()):
item = self.table.item(row, 1)
date = QDate.fromString(item.text(), oldFormat)
item.setText(date.toString(newFormat))
示例11: setModelData
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def setModelData(self, editor, model, index):
if not editor.isModified():
return
text = editor.text()
validator = editor.validator()
if validator is not None:
state, text, _ = validator.validate(text, 0)
if state != QValidator.Acceptable:
return
originalValue = index.model().data(index, Qt.UserRole)
if isinstance(originalValue, QColor):
self.colorExp.exactMatch(text)
value = QColor(min(int(self.colorExp.cap(1)), 255),
min(int(self.colorExp.cap(2)), 255),
min(int(self.colorExp.cap(3)), 255),
min(int(self.colorExp.cap(4)), 255))
elif isinstance(originalValue, QDate):
value = QDate.fromString(text, Qt.ISODate)
if not value.isValid():
return
elif isinstance(originalValue, QDateTime):
value = QDateTime.fromString(text, Qt.ISODate)
if not value.isValid():
return
elif isinstance(originalValue, QTime):
value = QTime.fromString(text, Qt.ISODate)
if not value.isValid():
return
elif isinstance(originalValue, QPoint):
self.pointExp.exactMatch(text)
value = QPoint(int(self.pointExp.cap(1)),
int(self.pointExp.cap(2)))
elif isinstance(originalValue, QRect):
self.rectExp.exactMatch(text)
value = QRect(int(self.rectExp.cap(1)),
int(self.rectExp.cap(2)),
int(self.rectExp.cap(3)),
int(self.rectExp.cap(4)))
elif isinstance(originalValue, QSize):
self.sizeExp.exactMatch(text)
value = QSize(int(self.sizeExp.cap(1)),
int(self.sizeExp.cap(2)))
elif isinstance(originalValue, list):
value = text.split(',')
else:
value = type(originalValue)(text)
model.setData(index, self.displayText(value), Qt.DisplayRole)
model.setData(index, value, Qt.UserRole)
示例12: set_web_metadata
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def set_web_metadata(self, metadata):
assert isinstance(metadata, gallerydb.Gallery)
self.link_lbl.setText(metadata.link)
self.title_edit.setText(metadata.title)
self.author_edit.setText(metadata.artist)
tags = ""
lang = ['English', 'Japanese']
self._find_combobox_match(self.lang_box, metadata.language, 2)
self.tags_edit.setText(utils.tag_to_string(metadata.tags))
pub_string = "{}".format(metadata.pub_date)
pub_date = QDate.fromString(pub_string.split()[0], "yyyy-MM-dd")
self.pub_edit.setDate(pub_date)
self._find_combobox_match(self.type_box, metadata.type, 0)
示例13: processAlgorithm
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def processAlgorithm(self, parameters, context, feedback):
"""
Here is where the processing itself takes place.
"""
# Retrieve the feature source and sink. The 'dest_id' variable is used
# to uniquely identify the feature sink, and must be included in the
# dictionary returned by the processAlgorithm function.
fichier_GTFS = self.parameterAsFile(parameters, self.INPUT, context)
debut_calendrier=self.parameterAsString(parameters,self.DEBUT_PERIODE,context)
fin_calendrier=self.parameterAsString(parameters,self.FIN_PERIODE,context)
fichier_Musliw=self.parameterAsFileOutput(parameters, self.OUTPUT,context)
# Compute the number of steps to display within the progress bar and
# get features from source
##a=fenetre.split(",")
##fenetre2=QgsRectangle(float(a[0]),float(a[2]),float(a[1]),float(a[3]))
os.chdir(fichier_GTFS)
date_debut=QDate.fromString(debut_calendrier, "d/M/yyyy").toPyDate()
date_fin=QDate.fromString(fin_calendrier, "d/M/yyyy").toPyDate()
sortie=fichier_Musliw
feedback.setProgressText(self.tr(u'Reading stops'))
google_stops = self.lit_google_stops("stops.txt")
feedback.setProgressText(self.tr(u'Reading routes'))
google_routes = self.lit_google_routes("routes.txt")
feedback.setProgressText(self.tr(u'Reading trips'))
google_trips = self.lit_google_trips("trips.txt")
feedback.setProgressText(self.tr(u"Reading calendars_dates"))
google_calendar_dates = self.lit_google_calendar_dates( "calendar_dates.txt")
feedback.setProgressText(self.tr(u'Reading calendars'))
google_calendars = self.lit_google_calendars( "calendar.txt", date_debut, date_fin, google_calendar_dates)
feedback.setProgressText(self.tr(u"Reading stop_times"))
google_stop_times = self.lit_google_stop_times( "stop_times.txt")
feedback.setProgressText(self.tr(u"Generating lines"))
google_chainages=self.cree_chainages(google_routes, google_trips, google_calendars, google_stop_times,feedback)
feedback.setProgressText(self.tr(u'Generation Musliw file'))
self.cree_musliw(sortie, google_routes, google_trips, google_calendars, google_stop_times, google_chainages, google_stops,feedback)
return {self.OUTPUT:self.OUTPUT}
示例14: convert_from_database
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def convert_from_database(row):
results = {}
for column in range(0, len(row)):
element = row[column]
if column == WalletItemModelType.INDEX_DATE.value:
date = QDate.fromString(element, WalletDatabase.WalletDatabaseConvertor.WALLET_DATE_DB_FORMAT)
data = date.toString(WalletDatabase.WalletDatabaseConvertor.WALLET_DATE_VIEW_FORMAT)
elif column == WalletItemModelType.INDEX_DESCRIPTION.value:
data = element
elif (column == WalletItemModelType.INDEX_INCOMING.value or
column == WalletItemModelType.INDEX_EXPENSE.value or
column == WalletItemModelType.INDEX_SAVINGS.value or
column == WalletItemModelType.INDEX_DEBT.value):
data = str() if element is None else STR_FLOAT_FORMAT % element
else:
raise Warning('Unexpected Column type: %d' % column)
results[column] = data
return tuple(results[e] for e in results)
示例15: _display_main_artist
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import fromString [as 别名]
def _display_main_artist(self, project):
is_compilation = project.compilation is True
self._compilation.setChecked(is_compilation)
self._main_artist.setDisabled(is_compilation)
self._main_artist.setText(self.tr("Various Artists") if is_compilation else project.lead_performer)
self._main_artist_caption.setDisabled(is_compilation)
self._main_artist_isni.setDisabled(is_compilation)
self._main_artist_isni.setText((project.isnis or {}).get(project.lead_performer))
self._main_artist_isni_caption.setDisabled(is_compilation)
self._main_artist_isni_help.setDisabled(is_compilation)
self._main_artist_region.setDisabled(is_compilation)
self._main_artist_region_caption.setDisabled(is_compilation)
self._main_artist_region_help.setDisabled(is_compilation)
self._main_artist_date_of_birth.setDisabled(is_compilation)
self._main_artist_date_of_birth_caption.setDisabled(is_compilation)
self._main_artist_date_of_birth.setDate(
QDate.fromString(project.lead_performer_date_of_birth, ISO_8601_FORMAT))
if project.lead_performer_region is not None:
self._main_artist_region.setText(
"{} {}".format(project.lead_performer_region[0], project.lead_performer_region[1]))
else:
self._main_artist_region.setText("")