Skip to content Skip to sidebar Skip to footer

Typeerror: Accept Missing 2 Required Arguments (still Functional)

This is a curiosity question. I have a block of code that executes upon an accepted.connect(). It throws out this error but when I check the results they still work. And from wha

Solution 1:

This simplified snippets below does work as expected, so your problem is elsewhere. Just a wildguess - if you copy/pasted you code, there are tabs in it and if you have a mix of tabs and spaces you can get really weird results - like having def accept actually being defined in __init__ itself instead of being a proper method, in which case self is not automagically passed to the function. Doesn't really match your error message but that might be worth checking....

from functools import partial

classButton(object):
    def__init__(self):
        self.callbacks = []
    defconnect(self, callback):
        self.callbacks.append(callback)
    defclick(self):
        for callback in self.callbacks:
            callback()

classUI(object):
    """The Dialog for initiation"""def__init__(self, player, window):
        self.window = window
        self.player = player
        self.button = Button()
        self.button.connect(  # the important part
            partial(self.accept, player, window))
        self.button.connect( 
            lambda: self.accept(player, window))

    defaccept(self, player, window):
        print"accept %s %s" % (player, window)

    defexec_(self):
        self.button.click()
player = "p"
window = "w"
dia = UI(player, window)
dia.exec_()

Solution 2:

It seems that it has to do with me overwriting the dialog's accept function. Once I changed the accept() to GoNinjaGoNinjaGo() everything worked just fine.

Post a Comment for "Typeerror: Accept Missing 2 Required Arguments (still Functional)"