Search code examples
pythonpyqtqtgui

Passing arguments through QtGui.QAction to the triggered method


Let's say I have a method like:

def open(self, opt):
    if opt == True:
    ...
    if opt == False:
    ...

how do I pass the argument to it with QtGui.QAction like:

self.openAct = QtGui.QAction("O&pen", self, shortcut="Ctrl+O",
            statusTip="Opens a location", triggered=self.open)

Solution

  • I found the answer it is from functools import partial. It was in This thread.