I should mention that I've read these but I'm still unable to achieve my goal:
[Using a dictionary in a for loop to create buttons doesn't work
[QtCore.QObject.connect in a loop only affects the last instance
My goal is to make a linux 'launcher' application. Button creation, placement, etc. is working like a charm but there's one problem - all buttons trigger the same callback - the last one to be connected in the button creation loop.
Here's a basic version of the script to illustrate what I'm trying to do:
class App(QMainWindow):
    def launch(self, filepath):
        subprocess.run(filepath)
    def __init__(self):
        super(App, self).__init__()
        for btn in matrix:
            filepath = matrix[btn]['path']
            icon = matrix[btn]['setIcon']
            posx = matrix[btn]['posx']
            posy = matrix[btn]['posy']
            matrix[btn] = QToolButton(self)
            matrix[btn].setIcon(QIcon(icon))
            matrix[btn].setIconSize(QSize(64, 64))
            matrix[btn].resize(100, 100)
            matrix[btn].move(posx, posy)
            matrix[btn].clicked.connect(lambda launch: self.launch(filepath))
        self.initUI()
    def initUI(self):
        self.setGeometry(150, 150, 1250, 650)
        self.setWindowTitle('LinuxLauncher')
        self.show()
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        ex = App()
        sys.exit(app.exec_())
I know there's an answer but I've been at it for hours - I'd appreciate it someone could help me out of this jam - Thanks!
 
    