hi;
I created a graphical application with Qtdesigner and pyqt5. To finalize it completely, I started the creation some retouches concerning the coloring of some particular lines of the widget table.here is a reduced part of the code the application of my project
creation of the base and table :
![[Image: 7lnt.jpg]](https://zupimages.net/up/19/32/7lnt.jpg)
The problem I encountered and I do not have to find a solution: I want the row of the table containing the confirmation information to be entirely according to the state of the checkbutton: to have green background for each row of the table widget when checkbutton is checked.: (that is to say each row that whose confirmation column contains the OK string
thanks for help
I created a graphical application with Qtdesigner and pyqt5. To finalize it completely, I started the creation some retouches concerning the coloring of some particular lines of the widget table.here is a reduced part of the code the application of my project
creation of the base and table :
def create_database_ils35R(self): #creating the path to the current folder : os.chdir('D:\\workspace_python\\Application_ddm') #directory creation 'data_base' os.makedirs("D:\\workspace-python\\Application ddm\\data_base", exist_ok=True) #values recovered and introduced into the table date_reading = str(time.strftime("%d-%m-%Y")) time_reading = str(time.strftime('%H:%M:%S')) mon1_reading = self.lineEdit_mon1_reading.text() mon2_reading = self.lineEdit_mon2_reading.text() confirmation = self.lineEdit_confirmation.text() #creation and connexion to the database "ils35R" connexion = sqlite3.connect('data_base/ils35R.db') # Get a cursor object curseur = connexion.cursor() # Check if table loc35R does not exist and create it curseur.execute('''CREATE TABLE IF NOT EXISTS loc35R (date text, time text,mon1 text, mon2 text,declaration text ) ''') #inserting data into table "loc35R" : curseur.execute('''INSERT INTO loc35R VALUES (?,?,?,?,?) ''',(date_reading,time_reading, mon1_reading, mon2_reading, confirmation)) # Commit the change connexion.commit() #fermeture du cursor curseur.close() #fermeture de la connexion à la bdd connexion.close()display the contents of the data table in a widget table :
def display_contents_table_loc35R(self): os.chdir('D:\\workspace-python\\Application_ddm') conn = sqlite3.connect ('data_base/ils35R.db') curseur=conn.cursor() c=curseur.execute("SELECT * FROM loc35R") liste_loc35R=c.fetchall() # set row count self.tableWidget_loc35R.setRowCount(len(liste_loc35R)) for nb in range(len(liste_loc35R)): for nombre in range(5): self.tableWidget_loc35R.setItem(nb,nombre, QTableWidgetItem(liste_loc35R[nb][nombre])) self.tableWidget_loc35R.resizeRowsToContents() self.tableWidget_loc35R.resizeColumnsToContents() #closing the cursor curseur.close() #closing the connection to the bdd conn.close()state checkbutton confirmation :
def state checkbutton_for_correction_loc35R(self): if self.checkBox_loc35R.isChecked()==True : self.lineEdit_confirmation.setText("OK") else: self.lineEdit_confirmation.setText("NO")the insertion of the data in the table and recovery of this information and the display is done successfully on a table wiget pyqt5.
![[Image: 7lnt.jpg]](https://zupimages.net/up/19/32/7lnt.jpg)
The problem I encountered and I do not have to find a solution: I want the row of the table containing the confirmation information to be entirely according to the state of the checkbutton: to have green background for each row of the table widget when checkbutton is checked.: (that is to say each row that whose confirmation column contains the OK string
thanks for help