def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() qt = self.ui qt.setupUi(self) qt.deNaissance.setDate(QDate(np.random.randint(1950, 2001), np.random.randint(1, 13), np.random.randint(1, 29))) auj = QDate().currentDate() qt.deDebut.setDate(auj) qt.deFin.setDate(auj.addDays(7)) self.afficheCentres("""SELECT * FROM centre ORDER BY id_c;""") listPays = reqOnePostgresql("""SELECT DISTINCT pays FROM centre ORDER BY pays;""") qt.cbPays.addItems(listPays) listRegion = reqOnePostgresql("""SELECT DISTINCT region FROM centre ORDER BY region;""") qt.cbRegion.addItems(listRegion) listNom = reqOnePostgresql("""SELECT nom FROM centre ORDER BY nom;""") qt.cbNom.addItems(listNom) qt.cbCentreRes.addItems(["Tous les noms"] + listNom) qt.leRech.textChanged.connect(self.entreeRech) qt.cbPays.currentIndexChanged.connect(self.cbpaysChanged) qt.cbRegion.currentIndexChanged.connect(self.cbregionChanged) qt.cbNom.currentIndexChanged.connect(self.cbnomChanged) qt.tableWidget.cellDoubleClicked.connect(self.selecCentre) qt.cbCentreRes.currentIndexChanged.connect(self.selecAffImage) qt.pbValidRes.clicked.connect(self.reservation)
def convert_simple_dats_filter_to_query_format(a_filter): """ Convert a human readable filter to a machine friendly one. Example of input filter: ['Departs', 'Earth', 'On', '01-05-2020'] """ # TODO: Warning! if-else labyrinth following... Not efficient but not needed at this stage. action = a_filter[0] planet = a_filter[1] # No importa, the calling function knows if the spc is departing/arriving to/from Earth/Mars. operator = a_filter[2] date = a_filter[3] # Convert action to query format (e.g. the table column's name). if action == 'Departs': action = 'DepDates' elif action == 'Arrives': action = 'ArrivDates' # Convert planet to query format. pass # Convert operator to query format. if operator == 'On': operator = '==' elif operator == 'Before': operator = '<=' elif operator == 'After': operator = '>=' # Convert date to query format. date = QDate.toJulianDay(QDate.fromString(date, 'dd-MM-yyyy')) return [action, planet, operator, date]
def createMailModel(parent): model = QStandardItemModel(0, 3, parent) model.setHeaderData(SUBJECT, Qt.Horizontal, "Subject") model.setHeaderData(SENDER, Qt.Horizontal, "Sender") model.setHeaderData(DATE, Qt.Horizontal, "Date") addMail(model, "Happy New Year!", "Grace K. <*****@*****.**>", QDateTime(QDate(2006, 12, 31), QTime(17, 3))) addMail(model, "Radically new concept", "Grace K. <*****@*****.**>", QDateTime(QDate(2006, 12, 22), QTime(9, 44))) addMail(model, "Accounts", "*****@*****.**", QDateTime(QDate(2006, 12, 31), QTime(12, 50))) addMail(model, "Expenses", "Joe Bloggs <*****@*****.**>", QDateTime(QDate(2006, 12, 25), QTime(11, 39))) addMail(model, "Re: Expenses", "Andy <*****@*****.**>", QDateTime(QDate(2007, 1, 2), QTime(16, 5))) addMail(model, "Re: Accounts", "Joe Bloggs <*****@*****.**>", QDateTime(QDate(2007, 1, 3), QTime(14, 18))) addMail(model, "Re: Accounts", "Andy <*****@*****.**>", QDateTime(QDate(2007, 1, 3), QTime(14, 26))) addMail(model, "Sports", "Linda Smith <*****@*****.**>", QDateTime(QDate(2007, 1, 5), QTime(11, 33))) addMail(model, "AW: Sports", "Rolf Newschweinstein <*****@*****.**>", QDateTime(QDate(2007, 1, 5), QTime(12, 0))) addMail(model, "RE: Sports", "Petra Schmidt <*****@*****.**>", QDateTime(QDate(2007, 1, 5), QTime(12, 1))) return model
def itemClicked(self, index): task: Task = self.model.itemFromIndex(index).data() self.selected_task = task checked = self.model.itemFromIndex(index).checkState() if not checked: self.dialog = dialog.Display_dialog() self.dialog.setupUi(self.dialog, task.topic) self.dialog.show() self.start_date = QDate.fromString( task.start_at.strftime("%d/%m/%Y"), 'dd/MM/yyyy') self.end_date = QDate.fromString(task.end_at.strftime("%d/%m/%Y"), 'dd/MM/yyyy') self.start_time = QTime.fromString( task.start_at.strftime("%H:%M:%S"), 'hh:mm:ss') self.end_time = QTime.fromString(task.end_at.strftime("%H:%M:%S"), 'hh:mm:ss') self.topic = task.topic self.location = task.location self.desc = task.description self.dialog.title.setText(self.topic) self.dialog.location.setText(self.location) self.dialog.from_dateEdit.setDate(self.start_date) self.dialog.to_dateEdit.setDate(self.end_date) self.dialog.textEdit_desc.setText(self.desc) self.dialog.timeEdit.setTime(self.start_time) self.dialog.to_timeEdit.setTime(self.end_time) self.dialog.edit_btn.clicked.connect(self.edit_dialog) else: details = task.get_detail() details['status'] = True self.system.update_task(task.id, details)
def get_departure_arrival_date(self, p_trip='', p_trip_event='') -> int: """ Getter method. Returns the s/c's departure or arrival date, for the selected p_trip, and for the passed p_trip_event. Example: - p_trip = 'Earth - Mars' - p_trip_event = 'Launching' @param p_trip: 'Earth - Mars' or 'Mars - Earth' @param p_trip_event: 'Launching' or 'Landing' @return: the date """ # Are there selected trajectories for this s/c? There should be. if self.get_trajectory_selection_status() != 0: # Get the trajectory/ies. the_trajectory = [] if self.get_has_return_trajectory(): if p_trip == 'Earth - Mars': the_trajectory = list(self._trajectory1) elif p_trip == 'Mars - Earth': the_trajectory = list(self._trajectory2) else: if p_trip == 'Earth - Mars': the_trajectory = list(self._trajectory) # Get the departure/arrival date. the_date = 0 if p_trip_event == 'Launching': the_date = QDate.toJulianDay(the_trajectory[0]) elif p_trip_event == 'Landing': the_date = QDate.toJulianDay(the_trajectory[1]) return the_date
def testQDate(self): date = datetime.date(2010, 4, 23) other = QDate(date) self.assertEqual(date.year, other.year()) self.assertEqual(date.month, other.month()) self.assertEqual(date.day, other.day()) self.assertEqual(date, other.toPython())
def setDate(self, year: int, month: int, day: int, format: str = "yyyy-MM-dd"): dt = QDate(year, month, day) ds = dt.toString(format) self.setText(ds)
def testQDateNull(self): '''QDataStream <<>> QDate - null''' self.stream << QDate() res = QDate() self.read_stream >> res self.assertEqual(res, QDate()) self.assertFalse(res.isValid()) self.assertTrue(res.isNull())
def testQDateValid(self): '''QDataStream <<>> QDate - valid''' self.stream << QDate(2012, 12, 21) res = QDate() self.read_stream >> res self.assertEqual(res, QDate(2012, 12, 21)) self.assertTrue(res.isValid()) self.assertFalse(res.isNull())
def visualize_bone_age_data( self, data: Data, data_viewer_sub_windows: List[DataViewerSubWindow]): print('visualize_bone_age_data', type(data)) if isinstance(data, LayeredImage): first_layer = data.layers[0] default_gender_is_male = True image = first_layer.image predicted_bone_age, activation_map = self.predictor.predict( image, default_gender_is_male) record = PatientBoneAgeRecord( image, default_gender_is_male, QDate(2010, 1, 1), QDate.currentDate(), date.months_to_days(predicted_bone_age)) record.male_changed.connect( partial(self._on_record_male_changed, record)) self.journal.add_record(record) self.records_image_sub_windows[record] = data_viewer_sub_windows for sub_window in data_viewer_sub_windows: sub_window.layout_anchors = np.array([[0.6, 0], [1, 1]]) sub_window.lay_out_to_anchors() # Add a layer with the activation map activation_map = skimage.transform.resize(activation_map, image.array.shape[:2], order=3) activation_map = image_converter.normalized_uint8(activation_map) activation_map_color_transfer_function = ColorTransferFunction.default_jet( ) activation_map_color_transfer_function.points[ 0].color_array = np.array([0, 0, 255, 0]) activation_map_palette = color_converter.color_transfer_function_to_palette( activation_map_color_transfer_function) activation_map_layer = data.add_layer_from_image( FlatImage(array=activation_map, palette=activation_map_palette), name=self.ACTIVATION_MAP_LAYER_NAME) activation_map_layer_views = [] for sub_window in data_viewer_sub_windows: activation_map_layer_view = sub_window.viewer.layer_view_by_model( activation_map_layer) activation_map_layer_view.opacity = 0.5 activation_map_layer_views.append(activation_map_layer_view) activation_map_visibility_widget = LayerVisibilityWidget( activation_map_layer_views, embedded=True) # activation_map_visibility_widget.slider_bar_color = QColor(240, 206, 164) # activation_map_visibility_widget.toggle_button_checked_color = QColor(240, 206, 164) self.journal_viewer.add_record_activation_map_visibility_widget( record, activation_map_visibility_widget)
def _show_calendar(self): start = self._model.value.start if start.year >= 100: self._calendar.setSelectedDate(QDate(start.year, start.month, start.day)) else: self._calendar.setSelectedDate(QDate.currentDate()) button_position = self._ui.calendar_button.mapToGlobal(QPoint(0, 0)) calendar_x = button_position.x() calendar_y = button_position.y() + self._ui.calendar_button.height() self._calendar.move(calendar_x, calendar_y) self._calendar.show()
def __init__(self): super().__init__() self.started = False self.current_user = User() self.current_user.get_user_data() self.ui = Ui_ImportDateDialog() self.ui.setupUi(self) self.ui.date_start.setDate(QDate.currentDate()) self.ui.date_end.setDate(QDate.currentDate().addDays(1)) self.setModal(True) self.threadpool = QThreadPool() self.setup_signals()
def date_str(self, sql: str): """ 此函数只运用于字符串转日期 :param sql: 日期字符串2020/01/01 :return: """ if sql != "": date = QDate(int(sql.split('/')[0]), int(sql.split('/')[1]), int(sql.split('/')[2])) self.lineEdit().setText(date.toString()) super().setDate(date) else: self.clear()
def set_calendar(self): """Setup Calendar widget""" calendar = self._window.calendar calendar.setGridVisible(True) calendar.setMinimumDate(QDate(1900, 1, 1)) calendar.setMaximumDate(QDate.currentDate()) calendar.setFirstDayOfWeek(Qt.Thursday) weekend_format = QTextCharFormat() weekend_format.setForeground(QBrush(Qt.green, Qt.SolidPattern)) calendar.setWeekdayTextFormat(Qt.Saturday, weekend_format) calendar.setWeekdayTextFormat(Qt.Sunday, weekend_format) weekend_format.setForeground(QBrush(QColor('#8800BB'), Qt.SolidPattern)) calendar.setDateTextFormat(QDate.currentDate(), weekend_format) calendar.clicked.connect(self._window.date_edit.setDate)
def __init__(self): super().__init__() self.ui = Ui_ImportDateDialog() self.ui.setupUi(self) self.ui.dateinput_button.setDate(QDate.currentDate()) self.setModal(True) self.setup_signals()
def set_date_edit(self): date_edit = self._window.date_edit date_edit.setDisplayFormat('yyyy-MM-dd') date_edit.setDate(QDate(2020, 1, 1)) # This will make calendar as a pop window # date_edit.setCalendarPopup(True) date_edit.setCalendarWidget(self._window.calendar)
def verify_inputs(self): if (self.view.date_of_entry.date().toJulianDay() > QDate.currentDate().toJulianDay()): View.show_message("Selected date should not exceed today date", "error") return False if self.view.trans_type.currentIndex() <= 1: if self.view.money.text() != "": if self.source_table == "CASH": return True elif self.view.source_btn_group.checkedId() > 1: if self.view.cheque_number.text() != "": return True View.show_message("Enter Cheque Number", "error") else: View.show_message("Select money Source", "error") else: View.show_message("Please Enter money", "error") else: if self.source_table is not None: if self.view.money.text() != "": return True else: View.show_message("Please Enter money", "error") else: View.show_message("Select money Source", "error") return False
def setDateRange(self, start, end=0): self._begin = start if end: self._end = end else: self._end = QDate.currentDate().endOfDay(Qt.UTC).toSecsSinceEpoch() self.prepareData()
def __init__(self): super().__init__() zeile = qw.QHBoxLayout() vonDate = date2QDate(offsetVonDate(datetime.date.today())) self.vonPicker = germanDatePicker(vonDate) bisDate = vonDate.addMonths(2) self.bisPicker = germanDatePicker( QDate(bisDate.year(), bisDate.month(), bisDate.daysInMonth())) ensureBeforeAfter(self.vonPicker, self.bisPicker) zeile.addWidget(qw.QLabel("von")) zeile.addWidget(self.vonPicker) zeile.addWidget(qw.QLabel("bis")) zeile.addWidget(self.bisPicker) self.gruppe = GruppeCombo() zeile.addWidget(self.gruppe) zeile.addWidget(qw.QLabel("Umfang")) self.umfang = percentSpinner() zeile.addWidget(self.umfang) zeile.addStretch(1) zeile.setContentsMargins(-1, 0, -1, 0) self.setLayout(zeile)
def __init__(self, mainwindow): super(self.__class__, self).__init__() self.setupUi(self) self.setStyleSheet(qss) self.mainwindow = mainwindow self.k_thread = QThreadPool() # calendar self.start.setCalendarPopup(True) self.end.setCalendarPopup(True) self.start.setDisplayFormat('yyyy-MM-dd HH:mm:ss') self.end.setDisplayFormat('yyyy-MM-dd HH:mm:ss') now = datetime.now() - timedelta(days=30) self.start.setDate(QDate(now.year, now.month, now.day)) self.end.setDateTime(QDateTime.currentDateTime()) # for local_symbol in sorted(G.all_contracts): self.symbol_list.addItem(local_symbol + contract_space + G.all_contracts[local_symbol]) # 添加下拉框 self.symbol_list.currentIndexChanged.connect(self.symbol_change_slot) self.frq.addItems(['1min', '3min', '15min', '30min', '60min']) # table self.tick_table.setRowCount(0) self.tick_row = len(G.order_tick_row_map) self.tick_table.horizontalHeader().setStretchLastSection(True) # 最后一列自适应表格宽度 # self.tick_table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # 所有列自适应表格宽度 self.tick_table.setEditTriggers(QTableWidget.NoEditTriggers) # 单元格不可编辑 self.tick_table.horizontalHeader().setVisible(False) # 水平表头不可见 self.tick_table.verticalHeader().setVisible(False) # 垂直表头不可见 # btn self.source_btn.clicked.connect(self.source_btn_slot) self.hide_btn.clicked.connect(self.hide_btn_slot) self.reload_btn.clicked.connect(self.k_line_reload) self.hide_btn_slot() # 默认隐藏 self.mainwindow.job.kline_tick_signal.connect(self.set_tick_slot) self.ready_action()
def __init__(self): super(Demo, self).__init__() self.resize(300, 300) self.my_date = MyDateEdit(QDate(), self) self.my_date.show_signal.connect(self.show_calendar_func) self.calendar = MyCalendar(self) self.calendar.date_signal.connect(self.set_calendar_date_func)
def exportDipsToURL(self, dipoles, directoryURL, fileName, addDateToExport=True): dateStr = ("-" + QDate.currentDate().toString(Qt.ISODate) ) if addDateToExport else "" filename = QUrl(directoryURL).toLocalFile() + ( QDir.separator() + fileName + dateStr + ".csv").replace(" ", "_") file = QSaveFile(filename) file.open(QIODevice.WriteOnly) file.write( QByteArray( bytearray("x,y,z,phi (°),theta (°),moment (mu_B)\n", 'utf-8'))) for dip in dipoles: angles = anglesQuaternionToSph(dip.quaternion) line = str(dip.position.x()) + "," + str( dip.position.y()) + "," + str(dip.position.z()) + "," + str( degrees(angles[0])) + "," + str(degrees( angles[1])) + "," + str(dip.moment) + "\n" line = QByteArray(bytearray(line, 'utf-8')) file.write(line) file.commit() if (file.errorString() == "Unknown error"): return True else: return False
def set_value(self, value: str): value = value or '' if value != self.get_value(): date = value.split('-') if len(date) != 3: raise ValueError('Date format is invalid') self.setDate(QDate(int(date[0]), int(date[1]), int(date[2])))
def __init__(self, parent=None): # + parent=None super().__init__(parent) # + parent self.setLayout(QFormLayout()) self.inputs = dict() self.inputs['Customer Name'] = QLineEdit() self.inputs['Customer Address'] = QPlainTextEdit() self.inputs['Invoice Date'] = QDateEdit(date=QDate.currentDate(), calendarPopup=True) self.inputs['Days until Due'] = QSpinBox() for label, widget in self.inputs.items(): self.layout().addRow(label, widget) self.line_items = QTableWidget(rowCount=10, columnCount=3) self.line_items.setHorizontalHeaderLabels(['Job', 'Rate', 'Hours']) self.line_items.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.layout().addRow(self.line_items) for row in range(self.line_items.rowCount()): for col in range(self.line_items.columnCount()): if col > 0: w = QSpinBox() self.line_items.setCellWidget(row, col, w) submit = QPushButton('Create Invoice', clicked=self.on_submit) # + vvvvvv vvvvvvvvvvvvv _print = QPushButton('Print Invoice', clicked=self.window().printpreviewDialog) # + _print, + self.window() self.layout().addRow(submit, _print) # + _print
def test_wizard(mocker, qtbot, os, bits, wizard_class, pages): mozinfo = mocker.patch('mozregui.wizard.mozinfo') mozinfo.os = os mozinfo.bits = bits wizard = wizard_class() qtbot.addWidget(wizard) wizard.show() qtbot.waitForWindowShown(wizard) for page_class in pages: assert isinstance(wizard.currentPage(), page_class) wizard.next() # everything has been visited assert wizard.visitedPages() == wizard.pageIds() fetch_config, options = wizard.options() now = QDate.currentDate() assert isinstance(fetch_config, CommonConfig) assert fetch_config.app_name == 'firefox' # this is the default assert fetch_config.os == os assert fetch_config.bits == bits assert fetch_config.build_type == 'shippable' assert not fetch_config.repo assert options['profile'] == '' if isinstance(wizard, SingleRunWizard): assert options['launch'] == now.addDays(-3).toPython() else: assert options['good'] == now.addYears(-1).toPython() assert options['bad'] == now.toPython()
def from_string(self, text, original_value): if isinstance(original_value, QColor): match = self.color_exp.match(text) return QColor(min(int(match.captured(1)), 255), min(int(match.captured(2)), 255), min(int(match.captured(3)), 255), min(int(match.captured(4)), 255)) if isinstance(original_value, QDate): value = QDate.fromString(text, Qt.ISODate) return value if value.isValid() else None if isinstance(original_value, QDateTime): value = QDateTime.fromString(text, Qt.ISODate) return value if value.isValid() else None if isinstance(original_value, QTime): value = QTime.fromString(text, Qt.ISODate) return value if value.isValid() else None if isinstance(original_value, QPoint): match = self.point_exp.match(text) return QPoint(int(match.captured(1)), int(match.captured(2))) if isinstance(original_value, QRect): match = self.rect_exp.match(text) return QRect(int(match.captured(1)), int(match.captured(2)), int(match.captured(3)), int(match.captured(4))) if isinstance(original_value, QSize): match = self.size_exp.match(text) return QSize(int(match.captured(1)), int(match.captured(2))) if isinstance(original_value, list): return text.split(',') return type(original_value)(text)
def __init__(self, action, parent=None): super(EditIncomingActs, self).__init__(parent) self.path = os.path.join('faces', 'edit_invoicing.ui') self.ui_file = QFile(self.path) self.ui_file.open(QFile.ReadOnly) self.loader = QUiLoader() self.dialog = self.loader.load(self.ui_file, self) self.ui_file.close() self.action = action # определим элементы управления self.date_edit = self.dialog.findChild(QDateEdit, 'date_edit') self.table_service = self.dialog.findChild(QTableWidget, 'table_service') self.comment_edit = self.dialog.findChild(QLineEdit, 'comment_edit') self.table_total = self.dialog.findChild(QTableWidget, 'table_total') self.cmbox_company = self.dialog.findChild(QComboBox, 'cmbox_company') self.btn_save = self.dialog.findChild(QPushButton, 'btn_save') self.btn_add = self.dialog.findChild(QPushButton, 'btn_add') self.btn_changed = self.dialog.findChild(QPushButton, 'btn_changed') self.btn_delete = self.dialog.findChild(QPushButton, 'btn_delete') # назначим подсказки для элементов self.btn_save.setToolTip('Сохранить акт') self.btn_add.setToolTip('Добавить услугу, товар') self.btn_changed.setToolTip('Изменить услугу, товар') self.btn_delete.setToolTip('Удалить услугу, товар') # задаём специальные размеров колонок основной таблицы self.table_service.setColumnWidth(0, 329) # наименование услуг self.table_service.setColumnWidth(1, 100) # количество self.table_service.setColumnWidth(2, 100) # цена self.table_service.setColumnWidth(3, 100) # сумма # задаём специальные размеров колонок итоговой таблицы self.table_total.setColumnWidth(0, 549) # наименование услуг self.table_total.setColumnWidth(1, 80) # количество # замена имени колонки в форме self.table_total.horizontalHeaderItem(0).setText('Итого по актам') # добавляем значения по умолчанию: текущую дату self.date_edit.setDate(QDate.currentDate()) # список контроагентов result = conn.query(Counterparties).all() if result: for elem in result: self.cmbox_company.addItem(str(elem.name_c)) # назначим подсказки для элементов self.btn_add.setToolTip('Добавить') self.btn_delete.setToolTip('Удалить') # назначим действия для объектов self.btn_save.clicked.connect(self.save_service) self.btn_add.clicked.connect(self.insert_service) self.btn_changed.clicked.connect(self.edit_service) self.btn_delete.clicked.connect(self.dell_service)
def __init__(self, parent: QWidget = None): super(ShadowCalendar, self).__init__(parent) self.__bgColor: QColor = QColor("#212425") # 背景颜色 self.__textColor: QColor = QColor("#FFFFFF") # 文字颜色 self.__shadowColor: QColor = QColor("#FFFFFF") # 光晕颜色 self.__selectColor: QColor = QColor("#0078D7") # 选中颜色 self.__selectDate: QDate = QDate() # 今天日期 self.__dateItem: List[List[ShadowCalendar.DateItem], ] self.__dateItem = [[ShadowCalendar.DateItem() for column in range(7)] for row in range(6)] # 日期数组 [6][7] # 首次主动设置日期 self.updateCalendar(QDate.currentDate()) # 开启鼠标追踪 self.setMouseTracking(True)
def setEditorData(self, editor: QWidget, index: QModelIndex): #currentDate = datetime.date(index.data(Qt.EditRole)) if (index.data(Qt.EditRole) != None): currentDate = (index.data(Qt.EditRole)).toPython() day = currentDate.day month = currentDate.month year = currentDate.year editor.setDate(QDate(year, month, day))
def clear_all(self): self.ui.le_dni.setText("") self.ui.le_apellido.setText("") self.ui.le_edad.setText("") self.ui.le_nombre.setText("") self.ui.cb_provincia.setCurrentIndex(0) self.ui.cb_sexo.setCurrentIndex(0) self.ui.le_fecha_registro.setDate(QDate().currentDate())
def getQDateFromIsoString( isostr:str ) -> QDate: """ Liefert ein QDate - Objekt zurück, das aus isostring erzeugt wurde :param isostring: ein Datum im Format "yyyy-mm-dd" :return: QDate """ parts = isostr.split( "-" ) return QDate( int(parts[0]), int(parts[1]), int(parts[2]) )
def set_db_entry_button_script(self): db_name_fixed = self.avail_db_combo.currentText() + ".db" self.db = DatabaseInteraction(db_name_fixed) extr = Extractor(self.db.name) # Create datetime objects of the first and last strings of date self.datetime_first = datetime.strptime(extr.select_first_row()[ 0][0], "%Y-%m-%dT%H:%M:%S.%fZ") self.datetime_last = datetime.strptime(extr.select_last_row()[ 0][0], "%Y-%m-%dT%H:%M:%S.%fZ") self.first_row = QDate.fromString(str(self.datetime_first.date()), "yyyy-MM-dd") self.last_row = QDate.fromString(str(self.datetime_last.date()), "yyyy-MM-dd") self.calendar.setMinimumDate(self.first_row) self.calendar.setMaximumDate(self.last_row) self.first_row = QDate.fromString(str(self.datetime_first.date()), "yyyy-MM-dd") self.last_row = QDate.fromString(str(self.datetime_last.date()), "yyyy-MM-dd") self.calendar.setMinimumDate(self.first_row) self.calendar.setMaximumDate(self.last_row)
def row_changed(self, row: int): if (row > -1 and row < self.ui.lw_liabilities_list.count()): self.ui.lineEdit_Name.setText(self.__liabilities[row].name) self.ui.comboBox_brokers.setCurrentIndex( self.get_broker_index(self.__liabilities[row].broker)) year_pd = self.__liabilities[row].purchase_day.year month_pd = self.__liabilities[row].purchase_day.month day_pd = self.__liabilities[row].purchase_day.day self.ui.dateEdit_purchase_day.setDate( QDate(year_pd, month_pd, day_pd)) year_ed = self.__liabilities[row].expiration_day.year month_ed = self.__liabilities[row].expiration_day.month day_ed = self.__liabilities[row].expiration_day.day self.ui.dateEdit_expiration_day.setDate( QDate(year_ed, month_ed, day_ed)) self.ui.lineEdit_interest.setText(self.__liabilities[row].interest) self.ui.lineEdit_borrowed_money.setText( str(self.__liabilities[row].borrowed_money))
def nextImageFileName(self): picturesLocation = QStandardPaths.writableLocation(QStandardPaths.PicturesLocation) dateString = QDate.currentDate().toString("yyyyMMdd") pattern = picturesLocation + "/pyside2_camera_" + dateString + "_{:03d}.jpg" n = 1 while True: result = pattern.format(n) if not os.path.exists(result): return result n = n + 1 return None
def testInsert(self): myHash = {} qdate = QDate.currentDate() qdatetime = QDateTime.currentDateTime() qtime = QTime.currentTime() qurl = QUrl("http://www.pyside.org") qpoint = QPoint(12, 42) myHash[qdate] = "QDate" myHash[qdatetime] = "QDateTime" myHash[qtime] = "QTime" myHash[qurl] = "QUrl" myHash[qpoint] = "QPoint" self.assertEqual(myHash[qdate], "QDate") self.assertEqual(myHash[qdatetime], "QDateTime") self.assertEqual(myHash[qtime], "QTime") self.assertEqual(myHash[qurl], "QUrl") self.assertEqual(myHash[qpoint], "QPoint")