I have declared a variable of a class in the def __init__()
but when I create an instance of that class and try to access one of the variables I created it says "object has no attribute"
from pyglet.gl import *
from pyglet.window import Window
from Renderer import Renderer
class Window(Window):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.renderer = Renderer()
self.test = 1
glClearColor(255, 0, 0, 255)
window = pyglet.window.Window(400, 300, "Window", resizable=True)
print(window.test)
Renderer is a class I've made, but pyglet is a library
The problem here is that I can't access window.renderer
, nor window.test
.
Error: AttributeError: 'Win32Window' object has no attribute 'test'
How can I solve this?
window = Window(400, 300, "Window", resizable=True)
would create an instance of your custom Window
.