def createEditor(self): editor = QDateEdit() editor.setMinimumDate(self.minimumDate) # editor.setSpecialValueText(self.placeholderText) editor.setCalendarPopup(True) style = self.style() editor.setStyleSheet(style) # setup connections editor.dateChanged[QDate].connect(self.onActivated) return editor
def __init__(self, parent=None): QWidget.__init__(self, parent) # Creating and setting the components and their characteristics size = QSize(400, 370) self.setFixedSize(size) self.main_layout = QVBoxLayout() title: str = centralize_text("Добавление прихода продукта:") self.title = QLabel(title, parent=self) self.data_layout = QHBoxLayout() self.price_quantity_layout = QVBoxLayout() self.price_title = QLabel("Цена:", parent=self) self.price_value = QSpinBox() self.price_value.setValue(0) self.price_value.setRange(0, 1000000) self.price_value.setSingleStep(1000) self.quantity_title = QLabel("Кол-во:", parent=self) self.quantity_value = QDoubleSpinBox(parent=self) self.quantity_value.setSingleStep(1.0) self.quantity_value.setRange(0.0, 1000000.0) self.quantity_value.setDecimals(3) self.agreement_title = QLabel("Информация о доверенности:", parent=self) self.agreement_info = QPlainTextEdit(parent=self) self.date_layout = QVBoxLayout() self.date_title = QLabel("Выберите дату:", parent=self) self.today_radio = QRadioButton("Сегодня", parent=self) self.today_radio.setChecked(True) self.today_radio.clicked.connect(self.disable_date_edit) self.otherday_radio = QRadioButton("Другой день", parent=self) self.otherday_radio.clicked.connect(self.enable_date_edit) self.otherday_edit = QDateEdit(date=date.today(), parent=self) self.otherday_edit.setDisabled(True) self.invoice_title = QLabel("Информация о счёт-фактуре:", parent=self) self.invoice_info = QPlainTextEdit(parent=self) self.button = QPushButton("Добавить &приход", parent=self) # Locating the components in the widget self.setLayout(self.main_layout) self.main_layout.addWidget(self.title) self.main_layout.addLayout(self.data_layout) self.data_layout.addLayout(self.price_quantity_layout) self.price_quantity_layout.addWidget(self.price_title) self.price_quantity_layout.addWidget(self.price_value) self.price_quantity_layout.addWidget(self.quantity_title) self.price_quantity_layout.addWidget(self.quantity_value) self.price_quantity_layout.addWidget(self.agreement_title) self.price_quantity_layout.addWidget(self.agreement_info) self.data_layout.addLayout(self.date_layout) self.date_layout.addWidget(self.date_title) self.date_layout.addWidget(self.today_radio) self.date_layout.addWidget(self.otherday_radio) self.date_layout.addWidget(self.otherday_edit) self.date_layout.addWidget(self.invoice_title) self.date_layout.addWidget(self.invoice_info) self.main_layout.addWidget(self.button)
def __init__(self, recovered, parent=None): super().__init__(parent) self.label.setText("Date:") self.date_edit = QDateEdit(QDate.currentDate()) self.date_edit.setCalendarPopup(True) self.date_edit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) if recovered: self.date_edit.setEnabled(False) self.layout.addWidget(self.label) self.layout.addWidget(self.date_edit) self.setLayout(self.layout)
def __init__(self, user=None): self.form_layout = QFormLayout() self.second_name = QLineEdit() self.first_name = QLineEdit() self.birthday = QDateEdit() self.notes = QTextEdit() self.phones = list() if user is not None and user['id'] is not None: self.user_id = user['id'] if user is not None and user['second_name'] is not None: self.second_name.setText(user['second_name']) second_name_label = QLabel('Фамилия:') if user is not None and user['first_name'] is not None: self.first_name.setText(user['first_name']) first_name_label = QLabel('Имя:') self.birthday.setCalendarPopup(True) self.birthday.setDisplayFormat('dd MMMM yyyy') if user is not None and user['birthday'] is not None: self.birthday.setDate( QDate.fromString(user['birthday'], "d.M.yyyy")) birthday_label = QLabel('Дата рождения:') notes_label = QLabel('Примечание:') if user is not None and user['notes'] is not None: self.notes.setText(user['notes']) self.form_layout.addRow(second_name_label, self.second_name) self.form_layout.addRow(first_name_label, self.first_name) self.form_layout.addRow(birthday_label, self.birthday) self.form_layout.addRow(notes_label, self.notes) phone_label = QLabel('Телефон') self.form_layout.addRow(phone_label) if user is not None and user['phone'] is not None: for phone_row in user['phone']: phone = QLineEdit() phone.setText(phone_row['phone']) phone_type = QComboBox() phone_type.addItem('Домашний') phone_type.addItem('Рабочий') if phone_row['type'] == 'home': phone_type.setCurrentIndex(0) if phone_row['type'] == 'work': phone_type.setCurrentIndex(1) self.phones.append({'phone': phone, 'type': phone_type}) self.form_layout.addRow(phone_type, phone) phone = QLineEdit() phone_type = QComboBox() phone_type.addItem('Домашний') phone_type.addItem('Рабочий') self.phones.append({'phone': phone, 'type': phone_type}) self.form_layout.addRow(phone_type, phone)
def createEditor(self, parent: QWidget, options: QStyleOptionViewItem, index: QModelIndex) -> QDateEdit: """ Creates an editor. :param parent: Parent widget. :param options: Options. :param index: Model's index. :return: Created editor. """ editor = QDateEdit(parent) editor.setDisplayFormat(Resources.FORMAT_DATE_DISPLAY) return editor
def create_make_order_layout(self): self.make_order_layout = QVBoxLayout(self) self.make_order_grid = QGridLayout() self.make_order_info = QLabel('Make an order: ', self) self.make_order_info_font = QFont() self.make_order_info_font.setPixelSize(16) self.make_order_info_font.setBold(True) self.make_order_info.setFont(self.customer_profile_info_font) self.make_order_layout.addWidget(self.make_order_info) self.due_date_label = QLabel('Due date:', self) self.due_date_field = QDateEdit(self) self.filename_label = QLabel('File: ', self) self.filename_field = QLineEdit(self) self.filament_type_label = QLabel('Filament type:', self) self.filament_type_field = QListWidget(self) self.filament_type_field.addItem('ABS') self.filament_type_field.addItem('PLA') self.filament_color_label = QLabel('Filament color:', self) self.filament_color_field = QListWidget(self) self.filament_color_field.addItem('red') self.filament_color_field.addItem('green') self.filament_color_field.addItem('blue') self.filament_color_field.addItem('black') self.filament_color_field.addItem('white') self.filament_color_field.addItem('yellow') self.filament_color_field.addItem('pink') self.make_order_apply_button = QPushButton('Make order', self) self.make_order_apply_button.clicked.connect( self.apply_make_order_button_trigger) self.make_order_grid.addWidget(self.due_date_label, 0, 0) self.make_order_grid.addWidget(self.due_date_field, 0, 1) self.make_order_grid.addWidget(self.filename_label, 1, 0) self.make_order_grid.addWidget(self.filename_field, 1, 1) self.make_order_grid.addWidget(self.filament_type_label, 2, 0) self.make_order_grid.addWidget(self.filament_type_field, 2, 1) self.make_order_grid.addWidget(self.filament_color_label, 3, 0) self.make_order_grid.addWidget(self.filament_color_field, 3, 1) self.make_order_grid.addWidget(self.make_order_apply_button, 4, 1) self.make_order_layout.addLayout(self.make_order_grid) self.make_order_layout.addStretch() self.main_layout.addLayout(self.make_order_layout) self.hide_make_order_layout()
def CreateInvoiceForms(self): # Layout layInvoiceForms = QFormLayout() # Text Fields self.leCompanyName = QLineEdit() self.leCompanyAdress1 = QLineEdit() self.leCompanyAdress2 = QLineEdit() self.leCompanyNIP = QLineEdit() self.deDate = QDateEdit() self.deInvoiceCreateDate = QDateEdit() self.leOwnInvoiceNumber = QLineEdit() # CheckBox self.cbOwnInvoiceNumber = QCheckBox("Własny numer faktury:") # ComboBox self.comboPayment = QComboBox() self.comboPayment.addItem("gotówka") self.comboPayment.addItem("przelew") # minimum dates self.deDate.setDate(datetime.date.today()) self.deInvoiceCreateDate.setDate(datetime.date.today()) # Form fields layInvoiceForms.addRow("Nazwa firmy: ", self.leCompanyName) layInvoiceForms.addRow("Ulica, numer budynku: ", self.leCompanyAdress1) layInvoiceForms.addRow("Kod pocztowy, miasto: ", self.leCompanyAdress2) layInvoiceForms.addRow("NIP: ", self.leCompanyNIP) layInvoiceForms.addRow("Data badania: ", self.deDate) layInvoiceForms.addRow("Data wystawienia faktury: ", self.deInvoiceCreateDate) layInvoiceForms.addRow("Forma płatności:", self.comboPayment) layInvoiceForms.addRow("Własny numer faktury:", self.leOwnInvoiceNumber) #layInvoiceForms.addRow("", self.cbOwnInvoiceNumber) #layInvoiceForms.addRow("Termin płatności: ", self.dePayDate) self.gbInvoiceData.setLayout(layInvoiceForms)
def _centerUI(self): self.query_name = QLineEdit() self.query_name.setPlaceholderText("请输入要查询的名字") self.query_name.setObjectName("center name") self.date1 = QDateEdit(QDate.currentDate()) self.date1.setCalendarPopup(True) self.date2 = QDateEdit(QDate.currentDate()) self.date2.setCalendarPopup(True) self.job_combox = QComboBox(minimumWidth=100) self.job_combox.addItems(["业务员", "操作员"]) self.button = QPushButton("运行") self.button.clicked.connect(self._opendialog) self.center_layout.addWidget(QLabel("姓名:"), 0, 0, 2, 1) self.center_layout.addWidget(self.query_name, 0, 1, 2, 3) self.center_layout.addWidget(QLabel("类型:"), 3, 0, 2, 1) self.center_layout.addWidget(self.job_combox, 3, 1, 2, 3) #self.center_layout.addWidget(QLabel("起始:"), 3, 0, 2, 1) #self.center_layout.addWidget(self.date1, 3, 1, 2, 3) #self.center_layout.addWidget(QLabel("结束:"), 5, 0, 2, 1) #self.center_layout.addWidget(self.date2, 5, 1, 2, 3) self.center_layout.addWidget(self.button, 7, 1, 1, 3)
def _centerUI(self): self.query_name = QLineEdit() self.query_name.setPlaceholderText("请输入要查询的名字") self.query_secret = QLineEdit() self.query_secret.setPlaceholderText("请输入密码") self.query_secret.setEchoMode(QLineEdit.Password) self.date1 = QDateEdit(QDate.currentDate()) self.date1.setCalendarPopup(True) self.date2 = QDateEdit(QDate.currentDate()) self.date2.setCalendarPopup(True) self.job_combox = QComboBox(minimumWidth=100) self.job_combox.addItems(["业务员", "操作员"]) self.button = QPushButton("运行") self.button.clicked.connect(self._opendialog) self.center_layout.addWidget(QLabel("姓名:"), 0, 0, 2, 1) self.center_layout.addWidget(self.query_name, 0, 1, 2, 3) self.center_layout.addWidget(QLabel("密码:"), 3, 0, 2, 1) self.center_layout.addWidget(self.query_secret, 3, 1, 2, 3) self.center_layout.addWidget(QLabel("类型:"), 6, 0, 2, 1) self.center_layout.addWidget(self.job_combox, 6, 1, 2, 3) self.center_layout.addWidget(self.button, 9, 1, 1, 3)
def createEditor(self, parent, option, index): editor = QDateEdit(parent=parent) editor.setMinimumDate(datetime.datetime(year=2017, month=9, day=1)) editor.setMaximumDate(datetime.datetime(year=2020, month=9, day=1)) editor.setDisplayFormat("yyyy-MM-dd") editor.setCalendarPopup(True) # setFrame(): tell whether the line edit draws itself with a frame. # If enabled (the default) the line edit draws itself inside a frame, otherwise the line edit draws itself without any frame. editor.setFrame(False) return editor
def initUI(self): label = QLabel('QTimeEdit') label.setAlignment(Qt.AlignCenter) time = QTimeEdit(self) time.setTime(QTime.currentTime()) time.setTimeRange(QTime(00, 00, 00), QTime.currentTime()) time.setDisplayFormat('a:hh:mm:ss.zzz') label2 = QLabel('QDateEdit') label2.setAlignment(Qt.AlignCenter) self.date_edit = QDateEdit(self) self.date_edit.setDate(QDate.currentDate()) self.date_edit.setDateRange(QDate(2000, 1, 1), QDate.currentDate()) # self.date_edit.setDisplayFormat('yyyy년 MMMM d일') self.date_edit.dateChanged.connect(self.dateChange) self.label3 = QLabel('이곳에 QDateEdit에서 선택된 값이 나타납니다.') self.label3.setAlignment(Qt.AlignCenter) label4 = QLabel('QDateTimeEdit') label4.setAlignment(Qt.AlignCenter) label5 = QLabel(self) label5.setAlignment(Qt.AlignCenter) label5.setText( f'QDateTime \n 현재 시간은 {QDateTime.currentDateTime().toString("yyyy년 MMMM d일 ap hh시 mm분 ss초.zzz")} 입니다.' ) dt_edit = QDateTimeEdit(self) dt_edit.setDateTimeRange(QDateTime(2020, 1, 1, 00, 00, 00),\ QDateTime(2021, 1, 1, 00, 00, 00)) dt_edit.setDisplayFormat('yyyy.MM.dd hh:mm:ss') vbox = QVBoxLayout() vbox.addWidget(label) vbox.addWidget(time) vbox.addWidget(label2) vbox.addWidget(self.date_edit) vbox.addWidget(self.label3) vbox.addWidget(label4) vbox.addWidget(label5) vbox.addWidget(dt_edit) self.setLayout(vbox) self.setWindowTitle('QTime, QDateEdit, QDateTimeEdit') self.setGeometry(300, 300, 400, 300) self.show()
def __init__(self): super().__init__() self.title = 'grafiko_kreator' self.left = 20 self.top = 50 self.width = 2600 self.height = 1000 self.number_of_hours = 0 self.number_of_days = QDate.daysInMonth(QDate.currentDate()) self.workers_number = 3 self.slaveowners_number = 3 self.date_box = QDateEdit() self.date = QDate.currentDate() self.initUI()
def __init__(self, layout_dir: str, title, initial_date): super().__init__(layout_dir) self.prefix = lab_title = QLabel(text=title) path_layout = QHBoxLayout() path_layout.addWidget(lab_title) self.ctrl = QDateEdit() path_layout.addWidget(self.ctrl) calendar_widget = QCalendar() self.ctrl.setCalendar(calendar_widget) self.central_layout.addLayout(path_layout) self.set_value(initial_date)
def __init__(self, parent=None): super(RegisterWidget, self).__init__(parent) self.kik_client = KikClient() self.interceptor = RequestInterceptor(self) self.error_label = QLabel() self.webview = QWebEngineView() self.login_button = QPushButton() self.birthday_edit = QDateEdit() self.password_edit = QLineEdit() self.email_edit = QLineEdit() self.username_edit = QLineEdit() self.last_name_edit = QLineEdit() self.first_name_edit = QLineEdit() self.init_ui()
def __init__(self, update): super().__init__() self.update = update self.model = AddRigModel() self.controller = AddRigController(self, self.model) self.v_layout = QVBoxLayout() self.technique_combo_box = QComboBox() self.location_combo_box = QComboBox() self.user_combo_box = QComboBox() self.time_line = QLineEdit() self.date = QDateEdit() self.init_gui() self.init_main_layout() self.init_inputs_forms()
def createLayout(self): layout = QFormLayout() self.date = QDateEdit() self.date.setDate(QDate.currentDate()) self.date.setCalendarPopup(True) self.date.setFocusPolicy(Qt.StrongFocus) layout.addRow("Data", self.date) self.description = QLineEdit() self.description.setMaxLength(40) completer = QCompleter(DATABASE.getDescriptions()) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setCompletionMode(QCompleter.PopupCompletion) self.description.setCompleter(completer) layout.addRow("Descrição", self.description) self.account1 = QComboBox() self.account2 = QComboBox() self.account1.setEditable(False) self.account2.setEditable(False) accounts = DATABASE.getAccounts() for item in accounts: self.account1.addItem(item) self.account2.addItem(item) self.account2.setCurrentIndex(1) layout.addRow("De", self.account1) layout.addRow("Para", self.account2) self.value = QDoubleSpinBox() self.value.setDecimals(2) self.value.setPrefix("R$ ") self.value.setSingleStep(100) self.value.setRange(0, 1000000000) layout.addRow("Valor", self.value) sublayout = QHBoxLayout() self.ok = QPushButton("Adicionar") self.ok.clicked.connect(self.accept) if not accounts: self.ok.setEnabled(False) cancel = QPushButton("Cancelar") cancel.clicked.connect(self.reject) sublayout.addWidget(self.ok) sublayout.addWidget(cancel) layout.addRow(sublayout) self.setLayout(layout)
def _handleDate(self, name, parameterType, tooltip, defaultVal, minVal=None, maxVal=None): if (minVal is not None): minDate = QDate.fromString(minVal, 'yyyy-MM-dd') if (maxVal is not None): maxDate = QDate.fromString(maxVal, 'yyyy-MM-dd') defaultDate = QDate.fromString(defaultVal.strftime('%Y-%m-%d'), 'yyyy-MM-dd') widget = QDateEdit(self.parameterTable) widget.setDate(defaultDate) widget.setToolTip(tooltip) widget.setCalendarPopup(True) self.parameters[name] = [parameterType, widget] if (minVal is not None and maxVal is not None): self.parameters[name][1].setDateRange(minDate, maxDate)
def period(self): self.txt_per_1 = QDateEdit(self) self.txt_per_2 = QDateEdit(self) self.save_but = QPushButton('Save data') self.exit_but = QPushButton('Exit') self.txt_per_1.setDisplayFormat('dd/MM/yyyy') self.txt_per_2.setDisplayFormat('dd/MM/yyyy') self.lab_per = QLabel('Period of time:', self) self.lab_code = QLabel('Valute:', self) self.send_but = QPushButton('Send') self.send_but.clicked.connect(self.req_dynamic_rate) self.save_but.clicked.connect(self.save_dynamic) self.exit_but.clicked.connect(self.close) self.combo_val_code=QComboBox(self) self.val_code={'R01500':'Молдавский лей', 'R01235':'Доллар США','R01810':'Южноафриканский рэнд', 'R01710':'Туркменский манат','R01670':'Таджикский сомони','R01010':'Австралийский доллар', 'R01035':'Фунт стерлингов Соединенного королевства','R01060':'Армянский драм', 'R01100':'Болгарский лев','R01115':'Бразильский реал','R01135':'Венгерский форинт', 'R01215':'Датская крона','R01239':'Евро','R01270':'Индийская рупия','R01335':'Казахстанский тенге', 'R01350':'Канадский доллар','R01370':'Киргизский сом','R01375':'Китайский юань','R01535':'Норвежская крона','R01565':'Польский злотый', 'R01585':'Румынский лей','R01589':'СДР (специальные права заимствования)', 'R01625':'Сингапурский доллар','R01717':'Узбекский сум','R01720':'Украинская гривна', 'R01760':'Чешская крона','R01770':'Шведская крона','R01775':'Швейцарский франк', 'R01815':'Вон Республики Корея','R01820':'Японская иена'} for key in sorted(list(self.val_code.keys())): self.combo_val_code.addItem(self.val_code[key]) grid = QGridLayout() grid.setSpacing(1) grid.addWidget(self.lab_per, 1, 0, 1, 1) grid.addWidget(self.txt_per_1, 1, 1, 1, 1) grid.addWidget(self.txt_per_2, 1, 2, 1, 1) grid.addWidget(self.lab_code, 2, 0, 1, 1) grid.addWidget(self.combo_val_code, 2, 1, 3, 3) grid.addWidget(self.send_but, 1, 3, 1, 1) grid.addWidget(self.save_but, 5, 2) grid.addWidget(self.exit_but, 5, 3) self.setLayout(grid)
def createLayout(self): base = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) monthBox = QHBoxLayout() self.date = QDateEdit(QDate.currentDate()) self.date.setCalendarPopup(True) self.date.setDisplayFormat("MMMM yyyy") self.date.setAlignment(Qt.AlignCenter) def dateChanged(): msg = "Exibindo transações de %s" % ( self.date.date().toString("MM-yyyy")) self.mainWindow.showMessage(msg) self.mainWindow.loadInfo() self.date.dateChanged.connect(dateChanged) left = QToolButton() left.setArrowType(Qt.LeftArrow) left.clicked.connect( lambda: self.date.setDate(self.date.date().addMonths(-1))) right = QToolButton() right.setArrowType(Qt.RightArrow) right.clicked.connect( lambda: self.date.setDate(self.date.date().addMonths(1))) monthBox.addStretch(1) monthBox.addWidget(left) monthBox.addWidget(self.date, 1) monthBox.addWidget(right) monthBox.addStretch(1) self.view = Tree(6) self.view.setResizeColumn(2) self.view.setColumnWidth(0, 75) self.view.setColumnWidth(1, 175) self.view.setColumnWidth(2, 200) self.view.setColumnWidth(3, 100) self.view.setColumnWidth(5, 10) self.view.itemDoubleClicked.connect(self.editItem) layout.addLayout(monthBox) layout.addWidget(self.view, 1) base.setLayout(layout) self.setWidget(base) self.setFocusPolicy(Qt.StrongFocus)
def createEditor(self, parent, option, index): if (index.column() == ACTIONID and index.model().data( index, Qt.DisplayRole) == ACQUIRED): # Acquired is read-only return if index.column() == DATE: editor = QDateEdit(parent) editor.setMaximumDate(QDate.currentDate()) editor.setDisplayFormat("yyyy-MM-dd") if PYQT_VERSION_STR >= "4.1.0": editor.setCalendarPopup(True) editor.setAlignment(Qt.AlignRight | Qt.AlignVCenter) return editor else: return QSqlRelationalDelegate.createEditor(self, parent, option, index)
def _second_story(self, h2_wlayout): # 第二层布局 self.h2_date1 = QDateEdit(QDate.currentDate()) self.h2_date1.setCalendarPopup(True) self.h2_date2 = QDateEdit(QDate.currentDate()) self.h2_date2.setCalendarPopup(True) self.h2_button = QPushButton("运行") self.h2_button2 = QPushButton("停止") h2_wlayout.addItem(QSpacerItem(20, 20)) h2_wlayout.addWidget(QLabel("起始"), 0) h2_wlayout.addWidget(self.h2_date1) h2_wlayout.addItem(QSpacerItem(50, 20)) h2_wlayout.addWidget(QLabel("结束"), 0) h2_wlayout.addWidget(self.h2_date2) h2_wlayout.addItem(QSpacerItem(70, 20)) h2_wlayout.addWidget(self.h2_button) h2_wlayout.addWidget(self.h2_button2) h2_wlayout.setAlignment(Qt.AlignLeft) # 事件绑定 self.h2_button.clicked.connect(lambda: self._start_func()) self.h2_button2.clicked.connect(lambda: self._stop_func())
def add_row(self): self.gender_combo = QComboBox() self.medium_combo = QComboBox() self.gender_combo.addItems(self.gender) self.medium_combo.addItems(self.medium) self.dob_edit = QDateEdit() self.dob_edit.setDisplayFormat('dd/MM/yyyy') self.dob_edit.setCalendarPopup(True) self.dob_edit.setDate(QDate.currentDate()) self.insertRow(self.rowCount()) self.setCellWidget(self.rowCount() - 1, 1, self.gender_combo) self.setCellWidget(self.rowCount() - 1, 2, self.dob_edit) self.setCellWidget(self.rowCount() - 1, 3, self.medium_combo)
def clock(self, layout): self.verticalLayoutClock = QVBoxLayout(self) self.dateEdit = QDateEdit(self) self.dateEdit.setDisplayFormat("MMM dd yyyy") self.dateEdit.setDisabled(True) self.verticalLayoutClock.addWidget(self.dateEdit) self.timeEdit = QTimeEdit(self) self.timeEdit.setDisplayFormat("hh:mm:ss AP") self.timeEdit.setDisabled(True) self.verticalLayoutClock.addWidget(self.timeEdit) self.updateTime() self.timer = QTimer(self) self.timer.timeout.connect(self.updateTime) self.timer.start(1000) layout.addLayout(self.verticalLayoutClock)
def __init__(self, delta_days, *args, **kwargs): super(FinanceCalendarPage, self).__init__(*args, **kwargs) layout = QVBoxLayout(margin=0, spacing=2) # 日期选择 date_widget = QWidget(parent=self, objectName='dateWidget') date_widget.setFixedHeight(22) message_button_layout = QHBoxLayout(margin=0, spacing=0) self.date_edit = QDateEdit(QDate.currentDate().addDays(delta_days), parent=date_widget, dateChanged=self.getCurrentFinanceCalendar, objectName='dateEdit') self.date_edit.setDisplayFormat('yyyy-MM-dd') self.date_edit.setCalendarPopup(True) message_button_layout.addWidget(QLabel('日期:')) message_button_layout.addWidget(self.date_edit) message_button_layout.addStretch() # 伸缩 date_widget.setLayout(message_button_layout) layout.addWidget(date_widget, alignment=Qt.AlignTop) # 当前数据显示表格 self.finance_table = FinanceCalendarTable() layout.addWidget(self.finance_table) # 无数据的显示 self.no_data_label = QLabel('暂无相关数据...', styleSheet='color:rgb(200,100,50)', alignment=Qt.AlignHCenter | Qt.AlignTop) self.no_data_label.hide() layout.addWidget(self.no_data_label) self.setLayout(layout) self.setStyleSheet(""" #dateWidget{ background-color: rgb(178,200,187) } #dateWidget #dateEdit{ background-color: rgb(250,250,250); margin:0; padding:0; border: 1px solid rgb(250,250,250); } #dateWidget #dateEdit::drop-down{ border:2px; background-color:rgb(178,210,197); } #dateWidget #dateEdit::down-arrow{ image:url("media/more.png"); width: 15px; height:15px; } """)
def group_date_spinbox(self): lbl = QLabel('QDateEdit') group2 = QGroupBox('QDateEdit') self.dateedit = QDateEdit(self) self.dateedit.setDate(QDate.currentDate()) self.dateedit.setMinimumDate(QDate(1900, 1, 1)) self.dateedit.setMaximumDate(QDate(2100, 12, 31)) self.dateedit.setDisplayFormat('yyyy-MM-dd') self.dateedit.dateChanged.connect(self.date_value_change) # dateedit.setDateRange(QDate(1900, 1, 1), QDate(2100, 12, 31)) self.lbl3 = QLabel(QDate.toString(self.dateedit.date(), 'yyyy-MM-dd')) layout_group3 = QHBoxLayout() layout_group3.addWidget(lbl) layout_group3.addWidget(self.dateedit) layout_group3.addWidget(self.lbl3) return layout_group3
def createExpensesLayout(self): self.expensesWidget = QWidget() self.expensesWidget.setGeometry(QRect(10, 10, 550, 300)) self.expensesWidget.size = (570, 320) expenseDoubleSpinBox_label = QLabel("Value", self.expensesWidget) expenseDoubleSpinBox_label.setGeometry(QRect(30, 80, 40, 20)) expenseDoubleSpinBox_label.setAlignment(Qt.AlignBottom | Qt.AlignHCenter) self.expenseDoubleSpinBox = QDoubleSpinBox(self.expensesWidget) self.expenseDoubleSpinBox.setMaximum(10000) self.expenseDoubleSpinBox.setDecimals(2) self.expenseDoubleSpinBox.setMinimum(0) self.expenseDoubleSpinBox.setGeometry(QRect(10, 100, 80, 20)) expenseDateEdit_label = QLabel("Date", self.expensesWidget) expenseDateEdit_label.setGeometry(QRect(120, 80, 40, 20)) expenseDateEdit_label.setAlignment(Qt.AlignBottom | Qt.AlignHCenter) self.expenseDateEdit = QDateEdit(self.expensesWidget) self.expenseDateEdit.setCalendarPopup(True) self.expenseDateEdit.setDisplayFormat("dd/MM/yy") self.expenseDateEdit.setDate(QDate.currentDate()) self.expenseDateEdit.setGeometry(QRect(100, 100, 80, 20)) expenseCategoriesComboBox_label = QLabel("Category", self.expensesWidget) expenseCategoriesComboBox_label.setGeometry(QRect(210, 80, 60, 20)) expenseCategoriesComboBox_label.setAlignment(Qt.AlignBottom | Qt.AlignHCenter) self.expenseCategoriesComboBox = QComboBox(self.expensesWidget) self.expenseCategoriesComboBox.setGeometry(QRect(190, 100, 100, 20)) expenseSpecificationLine_label = QLabel("Specification", self.expensesWidget) expenseSpecificationLine_label.setGeometry(QRect(320, 80, 70, 20)) expenseSpecificationLine_label.setAlignment(Qt.AlignBottom | Qt.AlignHCenter) self.expenseSpecificationLine = QLineEdit(self.expensesWidget) self.expenseSpecificationLine.setGeometry(QRect(300, 100, 115, 20)) expenseObservationLine_label = QLabel("Observation", self.expensesWidget) expenseObservationLine_label.setGeometry(QRect(440, 80, 80, 20)) expenseObservationLine_label.setAlignment(Qt.AlignBottom | Qt.AlignHCenter) self.expenseObservationLine = QLineEdit(self.expensesWidget) self.expenseObservationLine.setGeometry(QRect(420, 100, 115, 20)) self.nonRecurringExpenseBox = QCheckBox("Non-recurring expense", self.expensesWidget) self.nonRecurringExpenseBox.setGeometry(QRect(10, 140, 130, 20)) submitbutton = QPushButton("Submit Expense", self.expensesWidget) submitbutton.clicked.connect(self.submitExpenseButtonClicked) submitbutton.setGeometry(QRect(10, 170, 520, 25))
def initUI(self): self.no_edit = QLineEdit() self.name_edit = QLineEdit() self.protocol_edit = QLineEdit() self.exam_date_edit = QDateEdit() self.age_edit = QSpinBox() self.sex_edit = QComboBox() self.instn_edit = QLineEdit() self.scanner_edit = QLineEdit() reg_ex = QRegExp('.*\-.*') self.scanner_validator = RegExpValidator(reg_ex, self.scanner_edit) self.scanner_edit.setValidator(self.scanner_validator) self.scanner_edit.setAlignment(Qt.AlignLeft) self.scanner_edit.setPlaceholderText('Manufacturer-Model') self.sex_edit.addItems(['M', 'F', 'Unspecified']) self.sex_edit.setPlaceholderText('Unspecified') self.sex_edit.setCurrentIndex(2) self.exam_date_edit.setDisplayFormat('dd/MM/yyyy') self.exam_date_edit.setButtonSymbols(QAbstractSpinBox.NoButtons) self.age_edit.setButtonSymbols(QAbstractSpinBox.NoButtons) self.age_edit.setSpecialValueText('-') self.age_edit.setMinimum(-1) self.age_edit.setValue(-1) l_layout = QFormLayout() l_layout.setVerticalSpacing(1) l_layout.addRow(QLabel('ID'), self.no_edit) l_layout.addRow(QLabel('Name'), self.name_edit) l_layout.addRow(QLabel('Age'), self.age_edit) l_layout.addRow(QLabel('Sex'), self.sex_edit) r_layout = QFormLayout() r_layout.setVerticalSpacing(1) r_layout.addRow(QLabel('Exam Date'), self.exam_date_edit) r_layout.addRow(QLabel('Institution'), self.instn_edit) r_layout.addRow(QLabel('Scanner'), self.scanner_edit) r_layout.addRow(QLabel('Protocol'), self.protocol_edit) main_layout = QHBoxLayout() main_layout.addLayout(l_layout) main_layout.addLayout(r_layout) self.setLayout(main_layout) self.setMaximumHeight(100) self.setContentsMargins(0, 0, 0, 0)
def set_layout(self): #Set up basic Stuff here vbox = QVBoxLayout() group1 = QGroupBox("Employee Update") form1 = QFormLayout() group1.setLayout(form1) #Set Nane self.namelabel = QLabel("Name") self.nameLineEdit = QLineEdit("") self.nameLineEdit.setEnabled(False) form1.setWidget(0, QFormLayout.LabelRole, self.namelabel) form1.setWidget(0, QFormLayout.FieldRole, self.nameLineEdit) #Set Date Label self.datelabel = QLabel("Date Started") self.dateLineEdit = QDateEdit() self.dateLineEdit.setDate(QDate(2021, 1, 1)) self.dateLineEdit.setCalendarPopup(True) form1.setWidget(1, QFormLayout.LabelRole, self.datelabel) form1.setWidget(1, QFormLayout.FieldRole, self.dateLineEdit) # set Time Started self.timestartlabel = QLabel("Time Started") self.updatestartLineEdit = QTimeEdit() # Set time constrain self.updatestartLineEdit.timeChanged.connect(self.connect_start_end) #Add to form Widget form1.setWidget(2, QFormLayout.LabelRole, self.timestartlabel) form1.setWidget(2, QFormLayout.FieldRole, self.updatestartLineEdit) # set Time Ended self.timeendedlabel = QLabel("Time Ended") self.updateendeLineEdit = QTimeEdit() # connect min time of endtime as starttime self.updateendeLineEdit.timeChanged.connect( self.connect_min_time) #you can use lambda function to get 1 line # Add to form Widget form1.setWidget(3, QFormLayout.LabelRole, self.timeendedlabel) form1.setWidget(3, QFormLayout.FieldRole, self.updateendeLineEdit) ##ADD BUTTON self.updatebtn = QPushButton("Update Employee") self.updatebtn.clicked.connect(self.saved_messagebox) ## ADD ITEMS TO LAYOUT vbox.addWidget(group1) vbox.addWidget(self.updatebtn, 0, Qt.AlignHCenter) self.setLayout(vbox)
def init_input_fields(self): start_row = 1 self._data_grid.addWidget(QLabel("Loan Amount"), start_row + 0, 0) self._data_grid.addWidget(QLabel("Down Payment [%]"), start_row + 1, 0) self._data_grid.addWidget(QLabel("Nominal Interest [%]"), start_row + 2, 0) self._data_grid.addWidget(QLabel("Start Date"), start_row + 3, 0) self._kredit_summe_edit = QLineEdit() self._tilgung_prozent_edit = QLineEdit() self._zins_prozent_edit = QLineEdit() self._start_month_edit = QDateEdit(QDate.currentDate()) self._start_month_edit.setDisplayFormat(conf.DATE_FORMAT) self._start_month_edit.currentSection = QDateTimeEdit.MonthSection # self._start_month_edit.setCalendarPopup(True) self._data_grid.addWidget(self._kredit_summe_edit, start_row + 0, 1) self._data_grid.addWidget(self._tilgung_prozent_edit, start_row + 1, 1) self._data_grid.addWidget(self._zins_prozent_edit, start_row + 2, 1) self._data_grid.addWidget(self._start_month_edit, start_row + 3, 1)
def initUI(self): lbl = QLabel('QDateEdit') dateedit = QDateEdit(self) dateedit.setDate(QDate.currentDate()) dateedit.setMinimumDate(QDate(1900, 1, 1)) dateedit.setMaximumDate(QDate(2100, 12, 31)) # dateedit.setDateRange(QDate(1900, 1, 1), QDate(2100, 12, 31)) vbox = QVBoxLayout() vbox.addWidget(lbl) vbox.addWidget(dateedit) vbox.addStretch() self.setLayout(vbox) self.show_basic()