from PyQt5 import uic
from PyQt5.QtWidgets import QApplication
Form, Window = uic.loadUiType("test.ui")
app = QApplication([])
window = Window()
form = Form()
form.setupUi(window)
window.show()
count = 0
def clicked():
global count
count += 1
print(count)
if count == 1:
form.pushButtonR1.setStyleSheet('''
QPushButton {
background-color: rgb(255, 0, 0);
border: 3px solid black;
border-radius: 8px;
}
QPushButton:hover {
background-color: rgb(194, 0, 0);
}
QPushButton:pressed {
background-color: rgb(163, 0, 0);
}''') # red
elif count == 2:
form.pushButtonR1.setStyleSheet('''
QPushButton {
background-color: rgb(255, 255, 255);
border: 3px solid black;
border-radius: 8px;
}
QPushButton:hover {
background-color: rgb(208, 208, 208);
}
QPushButton:pressed {
background-color: rgb(159, 159, 159);
}''') # white
elif count == 3:
form.pushButtonR1.setStyleSheet('''
QPushButton {
background-color: rgb(255, 255, 0);
border: 3px solid black;
border-radius: 8px;
}
QPushButton:hover {
background-color: rgb(220, 220, 0);
}
QPushButton:pressed {
background-color: rgb(197, 197, 0);
}''') # yellow
elif count == 4:
form.pushButtonR1.setStyleSheet('''
QPushButton {
background-color: rgb(0, 55, 255);
border: 3px solid black;
border-radius: 8px;
}
QPushButton:hover {
background-color: rgb(0, 30, 202);
}
QPushButton:pressed {
background-color: rgb(0, 11, 170);
}''') # blue
elif count == 5:
form.pushButtonR1.setStyleSheet('''QPushButton {
background-color: rgb(0, 170, 0);
border: 3px solid black;
border-radius: 8px;
}
QPushButton:hover {
background-color: rgb(0, 140, 0);
}
QPushButton:pressed {
background-color: rgb(0, 106, 0);
}''') # green
elif count == 6:
form.pushButtonR1.setStyleSheet('''
QPushButton {
background-color: rgb(255, 85, 0);
border: 3px solid black;
border-radius: 8px;
}
QPushButton:hover {
background-color: rgb(211, 70, 0);
}
QPushButton:pressed {
background-color: rgb(186, 62, 0);
}''') # orange
count = 0
form.pushButtonR1.clicked.connect(clicked)
form.pushButtonR2.clicked.connect(clicked)
form.pushButtonR3.clicked.connect(clicked)
form.pushButtonR4.clicked.connect(clicked)
form.pushButtonR6.clicked.connect(clicked)
form.pushButtonR7.clicked.connect(clicked)
form.pushButtonR8.clicked.connect(clicked)
form.pushButtonR9.clicked.connect(clicked)
app.exec()