I'm trying to initialize the class (extraropt) from another .py but it gives me an error, I've searched but I haven't found a solution.
Heres the code of the one py I'm calling from:
main.py:
class GameWindow(ui.ScriptWindow):
def __init__(self, stream):
import extraop
exec 'extraop.extraropt().Show(stream)'
And here's the code of the one py I'm trying to call(init and del only):
extraop.py
class extraropt(ui.Window):
def __init__(self, stream):
ui.Window.__init__(self)
self.BuildWindow()
self.stream=stream
def __del__(self):
ui.Window.__del__(self)
It gives this error:
Error - __init__() takes exactly 2 arguments (1 given)
In the line
exec 'extraop.extraropt().Show(stream)'
You are implicitly calling extraropt.__init__() by creating a new instance of extraopt. In your code, you show that extraropt.__init__() takes a second (stream) argument, so you have to pass that in.
extraop.extraropt(stream).Show()
Incidentally, there is no reason why you should be doing an exec rather than explicitly calling it as I did above. There is also no reason for you to have a __del__() method defined as you only call the parent __del__() method anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With