Python PyQt5.QtCore.QDateTime() Examples
The following are 7
code examples of PyQt5.QtCore.QDateTime().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtCore
, or try the search function
.
Example #1
Source File: widgets.py From Lector with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: test_widgets_modal.py From wonambi with GNU General Public License v3.0 | 6 votes |
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'))
Example #3
Source File: models.py From Lector with GNU General Public License v3.0 | 5 votes |
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()
Example #4
Source File: mapillary_filter.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
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)
Example #5
Source File: mapillary_filter.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
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)
Example #6
Source File: qgisUtils.py From qgis-processing-trajectory with GNU General Public License v3.0 | 5 votes |
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
Example #7
Source File: database.py From Lector with GNU General Public License v3.0 | 4 votes |
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()