from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout, QPushButton from PyQt5.QtCore import QTimer, Qt import time from logger import logger class Informer(QWidget): def __init__(self, updateData, world_coord, axis_coord, command_count): super().__init__() self.world_coord = world_coord self.axis_coord = axis_coord self.command_count = command_count self.updateData = updateData # Инициализация пользовательского интерфейса self.initUI() def initUI(self): self.layout = QVBoxLayout() self.setLayout(self.layout) self.wLabel = QLabel(f'Мировые координаты {self.world_coord()}') self.aLabel = QLabel(f'Поворот осей {self.axis_coord()}') self.cLabel = QLabel(f'Количество команд в стеке {self.command_count()}') for l in [self.wLabel, self.aLabel, self.cLabel]: l.setWordWrap(True) self.layout.addWidget(l) self.updButton = QPushButton('Обновить данные') self.updButton.clicked.connect(self.updateState) self.layout.addWidget(self.updButton) def paintEvent(self, event): # Установка цвета фона self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), Qt.lightGray) self.setPalette(p) def updateState(self): self.updateData() time.sleep(1) self.wLabel.setText(f'Мировые координаты {self.world_coord()}') self.aLabel.setText(f'Поворот осей {self.axis_coord()}') self.cLabel.setText(f'Количество команд в стеке {self.command_count()}')