Initial commit
This commit is contained in:
commit
ff50ea6784
12 changed files with 509 additions and 0 deletions
82
views/catalog_view.py
Normal file
82
views/catalog_view.py
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
from PyQt6.QtWidgets import (
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QPushButton,
|
||||
QLabel,
|
||||
QTableWidget,
|
||||
QTableWidgetItem,
|
||||
)
|
||||
from PyQt6.QtGui import QColor
|
||||
from config import DISCOUNT_COLOR, OUT_OF_STOCK_COLOR
|
||||
|
||||
|
||||
class CatalogView(QWidget):
|
||||
def __init__(self, full_name: str, role: str):
|
||||
super().__init__()
|
||||
self.setWindowTitle("Каталог игрушек")
|
||||
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
self.user_label = QLabel(
|
||||
f"{full_name} ({role})"
|
||||
)
|
||||
|
||||
self.refresh_button = QPushButton("Обновить")
|
||||
self.sort_button = QPushButton("Сортировать по цене")
|
||||
self.logout_button = QPushButton("Выйти")
|
||||
|
||||
self.table = QTableWidget()
|
||||
|
||||
self.layout.addWidget(self.user_label)
|
||||
self.layout.addWidget(self.refresh_button)
|
||||
self.layout.addWidget(self.sort_button)
|
||||
self.layout.addWidget(self.table)
|
||||
self.layout.addWidget(self.logout_button)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
self.setFixedSize(860, 500)
|
||||
|
||||
def load_data(self, toys: list):
|
||||
headers = [
|
||||
"Название",
|
||||
"Категория",
|
||||
"Производитель",
|
||||
"Возраст",
|
||||
"Поставщик",
|
||||
"Цена",
|
||||
"Скидка",
|
||||
"Остаток",
|
||||
]
|
||||
|
||||
self.table.setColumnCount(len(headers))
|
||||
self.table.setHorizontalHeaderLabels(headers)
|
||||
self.table.setRowCount(len(toys))
|
||||
|
||||
for row, toy in enumerate(toys):
|
||||
values = [
|
||||
toy["toy_name"],
|
||||
toy["category_name"],
|
||||
toy["manufacturer_name"],
|
||||
toy["ages"],
|
||||
toy["suppliers"],
|
||||
str(toy["price"]),
|
||||
str(toy["discount"]),
|
||||
str(toy["quantity"]),
|
||||
]
|
||||
|
||||
for col, value in enumerate(values):
|
||||
item = QTableWidgetItem(value)
|
||||
self.table.setItem(row, col, item)
|
||||
|
||||
if toy["discount"] >= 25:
|
||||
for col in range(len(headers)):
|
||||
self.table.item(row, col).setBackground(
|
||||
QColor(DISCOUNT_COLOR)
|
||||
)
|
||||
|
||||
if toy["quantity"] == 0:
|
||||
for col in range(len(headers)):
|
||||
self.table.item(row, col).setBackground(
|
||||
QColor(OUT_OF_STOCK_COLOR)
|
||||
)
|
||||
38
views/login_view.py
Normal file
38
views/login_view.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from PyQt6.QtWidgets import (
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QLineEdit,
|
||||
QPushButton,
|
||||
QLabel,
|
||||
)
|
||||
|
||||
|
||||
class LoginView(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("Авторизация")
|
||||
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
self.login_input = QLineEdit()
|
||||
self.login_input.setPlaceholderText("Логин")
|
||||
|
||||
self.password_input = QLineEdit()
|
||||
self.password_input.setPlaceholderText("Пароль")
|
||||
self.password_input.setEchoMode(
|
||||
QLineEdit.EchoMode.Password
|
||||
)
|
||||
|
||||
self.login_button = QPushButton("Войти")
|
||||
self.guest_button = QPushButton("Войти как гость")
|
||||
self.status_label = QLabel()
|
||||
|
||||
self.layout.addWidget(self.login_input)
|
||||
self.layout.addWidget(self.password_input)
|
||||
self.layout.addWidget(self.login_button)
|
||||
self.layout.addWidget(self.guest_button)
|
||||
self.layout.addWidget(self.status_label)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
self.setFixedSize(240, 180)
|
||||
Loading…
Add table
Add a link
Reference in a new issue