Connor Burleson
Connor Burleson

Reputation: 25

screen.fill() not working to generate white box, NameError 'self' is not defined?

I began my program by setting up a small window to be filled with a white background. I am unsure why I am getting a NameError from 'self', when my RealTimeDraw.py file creates an instance of PYGAME_WINDOW, which initializes self.screen. A simple fix I am sure, but I have overlooked this for way too long now..NameError message My Code

Upvotes: 0

Views: 118

Answers (1)

arcano
arcano

Reputation: 11

Prepare and Reveal class should be a methods not class

import pygame

class PYGAME_WINDOW:
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((300, 100))
    def Prepare(self):
        self.screen.fill((255,255,255))
    def Reveal(self):
        pass

Upvotes: 1

Related Questions