Suppose we have a list of the form:
[ [id, name, pixmap] [id, name, pixmap] ... ] The task is to create a toolbar with buttons from this list. Now I just go around the list and add a button, like this:
for item in items: action = QAction(QIcon(item[2]), item[1], actionG, triggered=lambda: print(item[0])) toolbar.addAction(action) I assumed that when the button was pressed, the id of each button would be displayed in the console, and only the last one would be displayed.
The question is: how to properly implement the ability to call a function, let's say print as in the example, so that it knows which button is pressed. Provided that the toolbar is created dynamically based on the list.