Z
Z
zaordu2021-05-12 00:34:01
PyQt
zaordu, 2021-05-12 00:34:01

Can widgets be stored in an array?

I have a table in the database with tables and their status "busy" or "free",
let's say I have a window where there is a button for each table and I want the buttons with the status "busy" to be red,
I can do something like this ?

a = (self.pushbutton, self.pushbutton_2, self.pushbutton_3,..... )
a[0] = setStyleSheet("Background-colord: red")

So that I can loop through the buttons and compare the button index in the array with the status tuple that I request from the database
. If not, then tell me alternative solutions, thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-05-30
@zaordu

Can widgets be stored in an array?

Can.
can i do something like this?

So you can't. First, a tuple is immutable. Secondly, you are trying to replace the first button in the collection with the result of calling a function called setStyleSheet, rather than setting the button's color.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question