Answer the question
In order to leave comments, you need to log in
How to describe the button color changing function by condition in PyQT?
There is a front made on PyQT widgets.
This code describes how to launch the browser and the functions of emulating clicks inside the page, called by button clicks. To simplify, I cut JS scripts and the number of buttons here
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): #связываем функции с UI кнопками
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): #функция для кнопки 1
driver.execute_script('''some js code 1''')
def SpecTransp(self): #функция для кнопки 2
driver.execute_script('''some js code 2''')
def NoSvetofor(self): #функция для кнопки 3
driver.execute_script('''some js code 3''')
if __name__ == '__main__':
app = QtWidgets.QApplication([])
window = ExampleApp()
window.show()
app.exec_()
self.pushButton.setStyleSheet('QPushButton {background-color: red; color: white;}')
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