How to describe the function of changing the color of the button according to the condition in PyQT?

Have the front done on the PyQT widgets

In this code opisyvaetsya launch the browser and emulation clicks inside the page called by clicking a button. To simplify then cut JS scripts and number of buttons

from PyQt5 import QtWidgets
 from interface import Ui_MainWindow
 from selenium import webdriver
 from selenium.webdriver.common.keys import Keys
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.action_chains import ActionChains
 from selenium.webdriver.support import expected_conditions
 from selenium.webdriver.support.wait import WebDriverWait

 driver = webdriver.Chrome(executable_path='C:\chromedriver.exe')
 url = "https://www.google.com/"
 driver.get(url) 

 class ExampleApp(QtWidgets.QMainWindow, Ui_MainWindow):
 def __init__(self): #bind the function with the UI buttons
super().__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.NoAdress)
self.pushButton_2.clicked.connect(self.SpecTransp)
self.pushButton_3.clicked.connect(self.NoSvetofor)

 def NoAdress(self): #function for button 1
 driver.execute_script("'some js code 1"')

 def SpecTransp(self): #function for button 2
 driver.execute_script("'some js code 2"')

 def NoSvetofor(self): #function for button 3
 driver.execute_script("'some js code '3"')

 if __name__ == '__main__':
 app = QtWidgets.QApplication([])
 window = ExampleApp()
window.show()
 app.exec_()


Sticking this code in one of the functions of the buttons change its color

self.pushButton.setStyleSheet('QPushButton {background-color: red; color: white;}')


How to describe a function that will change the color of a button depending on the given conditions? Ie let's say if x == 1: button_1 is highlighted in red, if x = 2: then button 2 is highlighted in red, x == 3: button_3, etc.
April 3rd 20 at 18:46
0 answer

Find more questions by tags PythonQtQt CreatorPyQtFrontend