I created 9 QPushButtons which objectName's are E1, E2, E3, ..., E9. Now, I want to update their text field with strings I get from a database, so I want to do something like this:
query="SELECT evento FROM eventos;"
cur.execute(query)
i=1
for fetch in cur:
evento=str(fetch)
objectname="E"+str(i)
self.objectname.setText(evento)
i+=1
This loops fetches 9 lines (9 strings) and updates the buttons' display text. The problem is that I have to tell it which button to update and I can't figure out how to do it dynamically since the lines: objectname="E"+str(i)
and self.objectname.setText(evento)
won't work because AtributeError: 'MyWindowClass' object has no attribute 'objectname'