42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout, QPushButton
|
|
from PyQt5.QtCore import QTimer, Qt
|
|
import time
|
|
from logger import logger
|
|
|
|
|
|
class Imitator(QWidget):
|
|
def __init__(self, startImitate, imitate_point):
|
|
super().__init__()
|
|
|
|
self.imitate_point = imitate_point
|
|
self.startImitate = startImitate
|
|
|
|
self.initUI()
|
|
|
|
self.timer = QTimer()
|
|
self.timer.timeout.connect(self.updateState)
|
|
self.timer.start(int(100))
|
|
|
|
def initUI(self):
|
|
self.layout = QVBoxLayout()
|
|
self.setLayout(self.layout)
|
|
|
|
self.stepLabel = QLabel(f"Отправлено шагов {0}")
|
|
|
|
for l in [self.stepLabel]:
|
|
l.setWordWrap(True)
|
|
self.layout.addWidget(l)
|
|
|
|
self.updButton = QPushButton("Запустить имитацию")
|
|
self.updButton.clicked.connect(self.startImitate)
|
|
self.layout.addWidget(self.updButton)
|
|
|
|
def paintEvent(self, event):
|
|
# Установка цвета фона
|
|
self.setAutoFillBackground(True)
|
|
p = self.palette()
|
|
p.setColor(self.backgroundRole(), Qt.GlobalColor.lightGray)
|
|
self.setPalette(p)
|
|
|
|
def updateState(self):
|
|
self.stepLabel.setText(f"Отправлено шагов {self.imitate_point()}") |