本文整理匯總了Python中PyQt5.QtCore.QDateTime方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QDateTime方法的具體用法?Python QtCore.QDateTime怎麽用?Python QtCore.QDateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QDateTime方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update_last_accessed_time
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDateTime [as 別名]
def update_last_accessed_time(self):
self.metadata['last_accessed'] = QtCore.QDateTime().currentDateTime()
start_index = self.main_window.lib_ref.libraryModel.index(0, 0)
matching_item = self.main_window.lib_ref.libraryModel.match(
start_index,
QtCore.Qt.UserRole + 6,
self.metadata['hash'],
1, QtCore.Qt.MatchExactly)
try:
self.main_window.lib_ref.libraryModel.setData(
matching_item[0],
self.metadata['last_accessed'], QtCore.Qt.UserRole + 12)
except IndexError: # The file has been deleted
pass
示例2: test_widget_labels
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDateTime [as 別名]
def test_widget_labels(qtbot):
d = DateTimeDialog('lights out', start_time, duration)
qtbot.addWidget(d)
d.idx_seconds.setValue(-10)
assert d.idx_seconds.value() == 0
d.idx_seconds.setValue(duration + 10)
assert d.idx_seconds.value() == duration
new_datetime = QDateTime(2018, 1, 1, 11, 30, 0)
d.changed_datetime(new_datetime)
assert d.idx_seconds.value() == 0
# how to test this explicitly?
d.button_clicked(d.idx_ok)
d.button_clicked(d.idx_cancel)
d.grab().save(str(GUI_PATH / 'analysis_02_timedialog.png'))
示例3: data
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDateTime [as 別名]
def data(self, index, role):
source_index = self.mapToSource(index)
item = self.sourceModel().item(source_index.row(), 0)
if role == QtCore.Qt.TextAlignmentRole:
if index.column() in (3, 4):
return QtCore.Qt.AlignHCenter
if role == QtCore.Qt.DecorationRole:
if index.column() == 5:
return_pixmap = None
file_exists = item.data(QtCore.Qt.UserRole + 5)
position_percent = item.data(QtCore.Qt.UserRole + 7)
if not file_exists:
return pie_chart.pixmapper(
-1, None, -1, QtCore.Qt.SizeHintRole + 10)
if position_percent:
return_pixmap = pie_chart.pixmapper(
position_percent, self.temp_dir,
self.consider_read_at,
QtCore.Qt.SizeHintRole + 10)
return return_pixmap
elif role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
if index.column() in (0, 5): # Cover and Status
return QtCore.QVariant()
if index.column() == 4:
last_accessed = item.data(self.role_dictionary[index.column()])
if last_accessed:
right_now = QtCore.QDateTime().currentDateTime()
time_diff = last_accessed.msecsTo(right_now)
return self.time_convert(time_diff // 1000)
return item.data(self.role_dictionary[index.column()])
else:
return QtCore.QVariant()
示例4: setFilter
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDateTime [as 別名]
def setFilter(self):
users_list = []
userkeys_list = []
for row in range(0,self.userFiltersTable.rowCount()):
users_list.append(self.userFiltersTable.item(row,0).text())
userkeys_list.append("'%s'" % self.userFiltersTable.item(row,1).text())
self.filter = {
'byDate':{
'enabled': self.date_group.isChecked(),
'from': self.fromDateWidget.dateTime().toTime_t()*1000, #QDateTime(self.fromDateWidget.date()).toTime_t()*1000,
'to': self.toDateWidget.dateTime().toTime_t()*1000 #QDateTime(self.toDateWidget.date()).toTime_t()*1000
},
'byUser':{
'enabled': self.users_group.isChecked(),
'users': users_list,
'userkeys': userkeys_list,
},
'lookAt':{
'enabled': self.looking_at_group.isChecked(),
'lat':float(self.lat_widget.text() or '0'),
'lon':float(self.lon_widget.text() or '0')
},
'onlyPanorama': self.onlyPanorama.isChecked()
}
for level in ['images','sequences','overview']:
self.applySqlFilter(level)
示例5: populateSearch
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDateTime [as 別名]
def populateSearch(self):
layer = getattr(self.module.coverage, self.level + 'Layer')
userkeys = []
max = 0
min_timestamp = sys.maxsize
max_timestamp = 0
for feat in layer.getFeatures():
if feat['captured_at'] < min_timestamp:
min_timestamp = feat['captured_at']
if feat['captured_at'] > max_timestamp:
max_timestamp = feat['captured_at']
if max<100 and not feat['userkey'] in userkeys:
userkeys.append(feat['userkey'])
max += 1
user_search = self.mapillaryApi.users(userkeys=','.join(userkeys))
if user_search:
usermap = {}
for user in user_search:
usermap[user['username']] = user['key']
self.usersSearchFilter.clear()
for user in sorted(usermap.keys()):
self.usersSearchFilter.addItem(user, usermap[user])
if not self.date_group.isChecked():
mintime = QDateTime()
mintime.setTime_t(min_timestamp/1000)
self.fromDateWidget.setDateTime(mintime)
maxtime = QDateTime()
maxtime.setTime_t(max_timestamp/1000)
self.toDateWidget.setDateTime(maxtime)
示例6: trajectories_from_qgis_point_layer
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDateTime [as 別名]
def trajectories_from_qgis_point_layer(layer, time_field_name, trajectory_id_field, time_format):
names = [field.name() for field in layer.fields()]
data = []
for feature in layer.getFeatures():
my_dict = {}
for i, a in enumerate(feature.attributes()):
if names[i] == time_field_name:
if type(a) == QtCore.QDateTime:
my_dict[names[i]] = a.toPyDateTime()
else:
my_dict[names[i]] = datetime.strptime(a, time_format)
else:
my_dict[names[i]] = a
x = feature.geometry().asPoint().x()
y = feature.geometry().asPoint().y()
my_dict['geometry'] = Point((x, y))
data.append(my_dict)
df = pd.DataFrame(data).set_index(time_field_name)
crs = CRS(int(layer.sourceCrs().geographicCrsAuthId().split(':')[1]))
geo_df = GeoDataFrame(df, crs=crs)
df_by_id = dict(tuple(geo_df.groupby(trajectory_id_field)))
trajectories = []
for key, value in df_by_id.items():
traj = Trajectory(key, value)
trajectories.append(traj)
return trajectories
示例7: add_to_database
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDateTime [as 別名]
def add_to_database(self, data):
# data is expected to be a dictionary
# with keys corresponding to the book hash
# and corresponding items containing
# whatever else needs insertion
# Haha I said insertion
# Add the current datetime value to each file's database entry
# current_time = datetime.datetime.now()
current_datetime = QtCore.QDateTime().currentDateTime()
current_datetime_bin = sqlite3.Binary(pickle.dumps(current_datetime))
for i in data.items():
book_hash = i[0]
title = i[1]['title']
author = i[1]['author']
year = i[1]['year']
path = i[1]['path']
cover = i[1]['cover_image']
isbn = i[1]['isbn']
addition_mode = i[1]['addition_mode']
tags = i[1]['tags']
if tags:
# Is a list. Needs to be a string
tags = ', '.join([str(j) for j in tags])
else:
# Is still a list. Needs to be None.
tags = None
sql_command_add = (
"INSERT OR REPLACE INTO \
books (Title, Author, Year, DateAdded, Path, \
ISBN, Tags, Hash, CoverImage, Addition) \
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
cover_insert = None
if cover:
cover_insert = sqlite3.Binary(cover)
self.database.execute(
sql_command_add,
[title, author, year, current_datetime_bin,
path, isbn, tags, book_hash, cover_insert,
addition_mode])
self.database.commit()
self.database.close()