Answer the question
In order to leave comments, you need to log in
Incorrect dynamic background color change PyQt5 | OS Rasbian (debian 10) Can this problem be solved?
When testing on windows and kali, everything worked correctly. The background changes at the click of a button. What is the essence of the program, first a message is displayed stating that it is impossible to enter and is highlighted in red, and when you switch to green, the inscription will change, but when you return to the first state, the background is filled incorrectly.
1.
2.
3. (Wrong display)
from pynput import mouse
from PyQt5 import QtWidgets, uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton
from PyQt5.QtCore import pyqtSlot
import sys
app = QtWidgets.QApplication([])
class MainWindow(QMainWindow):
state = 1
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi('QueueControlScoreboard.ui', self)
self.label.resize(800, 600)
self.label.setMinimumSize(1, 1)
def resizeEvent(self, event):
self.label.resize(self.width(), self.height())
# переключатель состояния главного табло
def BoardChangeState(self, id = 0):
if(id == 0):
self.label.setText("ЗАХОДЬТЕ!")
self.setStyleSheet("background-color: lime;")
elif(id == 1):
self.label.setText("ЗАЧЕКАЙТЕ!")
self.setStyleSheet("background-color: red;")
main_window = MainWindow()
#функционал кнопки для теста смены состояния
@pyqtSlot()
def btn_click():
if(main_window.state == 1):
main_window.BoardChangeState(0)
main_window.state = 0
else:
main_window.BoardChangeState(1)
main_window.state = 1
main_window.pushButton.clicked.connect(btn_click)
main_window.show()
main_window.resize(800, 600)
sys.exit(app.exec())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question