i am trying to make a screenshot function, but everytime i try, it gives me this error:
Traceback (most recent call last):
File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 61, in eventLoop
Task
self.doEvents()
File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 122, in processE
vent
messenger.send(eventName, paramList)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 482, in __dispatch
method (*(extraArgs + sentArgs))
File "C:\Panda3D-1.8.1\direct\showbase\ShowBase.py", line 2317, in __oobeButto
n
messenger.send(button + suffix)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 482, in __dispatch
method (*(extraArgs + sentArgs))
TypeError: Screenie() takes exactly 1 argument (0 given)
:task(error): Exception occurred in PythonTask eventManager
Traceback (most recent call last):
File "Play.py", line 791, in <module>
run()
File "C:\Panda3D-1.8.1\direct\showbase\ShowBase.py", line 2921, in run
self.taskMgr.run()
File "C:\Panda3D-1.8.1\direct\task\Task.py", line 502, in run
self.step()
File "C:\Panda3D-1.8.1\direct\task\Task.py", line 460, in step
self.mgr.poll()
File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 61, in eventLoop
Task
self.doEvents()
File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 122, in processE
vent
messenger.send(eventName, paramList)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 482, in __dispatch
method (*(extraArgs + sentArgs))
File "C:\Panda3D-1.8.1\direct\showbase\ShowBase.py", line 2317, in __oobeButto
n
messenger.send(button + suffix)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 482, in __dispatch
method (*(extraArgs + sentArgs))
TypeError: Screenie() takes exactly 1 argument (0 given)
Heres the part which does the screenshots
def Screenie(self):
file_name = Filename('whatever.png')
self.win.saveScreenshot(file_name)
base.accept('f9', Screenie)
Can someone tell me whats wrong with it? I'm trying to fix it but can't figure out what to do...
The error is quite clear
TypeError: Screenie() takes exactly 1 argument (0 given)
Your
Screenie
function takes one argument (self
), but whatever is calling it, did so without giving any argument (i.e.Screenie()
instead ofScreenie(obj)
).Your choice of
self
as argument toScreenie
makes me think it is a class method. In that case you should have something like this.This makes sure that the
self
argument ofScreenie
is bound to theinstance
object, and your code should work.