I’ve been having issues with the base.movie() function, and I want to know how to fix them.
I’ve been using this function as follows:
base.movie(self.render,namePrefix=‘HA’, duration=49, fps=30, format=‘png’, sd=4,source=None)
but no matter what i do or what i change, i get this error when i try to run the program!
File “ffdjkdsjkdsf.py”, line 149, in CameraTask
base.movie(self.render,namePrefix=‘HA’, duration=49, fps=30, format=‘png’, sd=4,source=None)
TypeError: movie() got multiple values for argument ‘namePrefix’
I’m deeply sorry if this is a silly question, i just dont know how to do this sort of thing.
In short, “self.render” should be omitted from the call to “movie”, I believe.
In slightly less short: That first parameter that you’re providing–“self.render”–is being assumed by position to fill the “namePrefix” slot–but then you’re also explicitly assigning a parameter to the “namePrefix” slot, thus giving the method two values for “namePrefix”.
To explain:
If we look at the manual, the signature for the “movie” method looks like so:
movie(self, namePrefix='movie', duration=1.0, fps=30, format='png', sd=4, source=None)
Now, that signature gives “namePrefix” as the second parameter.
However, ShowBase is a class, and “movie” is an instance-method of that class–that is, a method that will be available to any individual instance of that class. And in Python, when a method belonging to such an instance is called, it’s automatically passed a reference to that instance as the first parameter.
(Hence I daresay that parameter usually being named “self”: it’s the instance from which the method is being called, itself.)
As a result, when you call “movie”, the ShowBase instance from which you’re calling it is automatically passed in as the first parameter.
Thus, whatever you pass in first will actually be the second parameter–in this case, “namePrefix”.
do i replace self.render with self, or omit this first call entirely? many thanks for your help
You omit it entirely.
As I said, that first parameter should be filled in automatically by Python, and thus doesn’t need to be filled in by you.
Which is to say: whatever you provide as the first parameter will really become the second parameter.
i did as you said,and i sadly have gotten yet another error ![]()
Traceback (most recent call last):
File “C:\Panda3D-1.10.14-x64\direct\showbase\ShowBase.py”, line 2758, in screenshot
saved = source.saveScreenshot(filename, imageComment)
AttributeError: ‘str’ object has no attribute ‘saveScreenshot’
Hopefully this isnt because ive yet again botched the installation, because ive had multiple issues in the past that were caused by me trying to put two versions of python and/or panda3d on the same system
Hmm, no, I don’t think it’s an installation problem–I’d guess that it’s most likely an issue with one of your parameters.
Could you do me a favour, please? Could you copy-paste the line in which you call the “movie” method into this thread?
Literally copy-paste, please–don’t re-type it. I want to check what you’re actually running, if I may.
I realised my error as i was copy pasting it, i used a “MainWindow” as my last source instead of None, so what i shouldve been running was this:
self.movie(namePrefix=‘HA’, duration=49, fps=30, format=‘png’, sd=4,source=None)
it runs now, and all i need to know now is where it’s saving these images, or if its even saving them at all LOL
tysm for all your help btw!
Not a problem! I’m glad that you found the issue, and found a solution to it! ![]()
By the way, note that when the default value for a parameter is already what you want–as in the case of “source=None”–you don’t have to fill it in.
So, in this case, your call to “movie” could be written like this:
self.movie(namePrefix='HA', duration=49)
(Since the values that you give for “fps”, “format”, “sd”, and “source” all match their defaults, as described in the manual.)
As to where it’s saving these images, that I don’t know, I’m afraid! ^^;