commit d559fc128e07f5fd4a3199b648e3dc70472056e4 Author: helldh Date: Tue Jan 20 21:48:18 2026 +0300 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d17dae --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5836fb7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f0ade7b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/pyqtsix.iml b/.idea/pyqtsix.iml new file mode 100644 index 0000000..9e78691 --- /dev/null +++ b/.idea/pyqtsix.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/apple.webp b/apple.webp new file mode 100644 index 0000000..58b0f8a Binary files /dev/null and b/apple.webp differ diff --git a/task1.py b/task1.py new file mode 100644 index 0000000..1a424eb --- /dev/null +++ b/task1.py @@ -0,0 +1,87 @@ +import sys +from PyQt6.QtGui import QPixmap +from PyQt6.QtWidgets import ( + QApplication, QMainWindow, + QWidget, QLabel, + QHBoxLayout, QVBoxLayout +) +from PyQt6.QtCore import Qt + + +class TaskOne(QMainWindow): + def __init__(self, path_to_image: str): + super().__init__() + self.original_pixmap = QPixmap(path_to_image) + self._init_ui() + self.setFixedSize(900, 250) + + def _init_ui(self): + root = QWidget(self) + main_layout = QHBoxLayout(root) + + # Отступы как на макете + main_layout.setSpacing(15) + main_layout.setContentsMargins(15, 15, 15, 15) + + # ---------- Фото ---------- + self.image_label = QLabel() + self.image_label.setAlignment(Qt.AlignmentFlag.AlignCenter) + self.image_label.setMinimumSize(180, 180) + self.image_label.setStyleSheet("border: 1px solid black;") + + # ---------- Текстовая информация ---------- + info_layout = QVBoxLayout() + info_layout.setSpacing(5) + + title = QLabel("Категория товара | Наименование товара") + title.setStyleSheet("font-weight: bold;") + + info_layout.addWidget(title) + info_layout.addWidget(QLabel("Описание товара:")) + info_layout.addWidget(QLabel("Производитель:")) + info_layout.addWidget(QLabel("Поставщик:")) + info_layout.addWidget(QLabel("Цена:")) + info_layout.addWidget(QLabel("Единица измерения:")) + info_layout.addWidget(QLabel("Количество на складе:")) + info_layout.addStretch() + + # ---------- Скидка ---------- + discount_label = QLabel("Действующая\nскидка") + discount_label.setAlignment(Qt.AlignmentFlag.AlignCenter) + discount_label.setFixedWidth(120) + discount_label.setStyleSheet(""" + QLabel { + border: 1px solid black; + font-weight: bold; + } + """) + + # ---------- Добавление в основной layout ---------- + main_layout.addWidget(self.image_label, stretch=0) + main_layout.addLayout(info_layout, stretch=1) + main_layout.addWidget(discount_label, stretch=0) + + self.setCentralWidget(root) + self._update_pixmap() + + def resizeEvent(self, event): + self._update_pixmap() + super().resizeEvent(event) + + def _update_pixmap(self): + if self.original_pixmap.isNull(): + return + + scaled = self.original_pixmap.scaled( + self.image_label.size(), + Qt.AspectRatioMode.KeepAspectRatio, + Qt.TransformationMode.SmoothTransformation + ) + self.image_label.setPixmap(scaled) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + window = TaskOne("apple.webp") + window.show() + sys.exit(app.exec()) diff --git a/task2.py b/task2.py new file mode 100644 index 0000000..95c059a --- /dev/null +++ b/task2.py @@ -0,0 +1,22 @@ +from PyQt6.QtWidgets import ( + QApplication, + QLineEdit, + QLabel, + QMainWindow, + QWidget, + QFormLayout, + QGroupBox +) +from PyQt6.QtCore import Qt + +class TaskTwo(QMainWindow): + def __init__(self): + super().__init__() + self._init_ui() + + def _init_ui(self): + self.root = QWidget() + self.form = QFormLayout() + + self.group = QGroupBox("Калькулятор скидки") + self.form \ No newline at end of file