0

I am writing a script in python/pygame, and I run the program (below) but I get an error saying:

if event.type == pygame.QUIT():

TypeError: 'int' object is not callable

Here is the script

def disp_startmenu():
    logo_label = 'WIZARD DEFENSE'
    opt1_label = '(1) START GAME'
    opt2_label = '(2) OPTIONS'
    opt3_label = '(3) QUIT'
    screen.fill(dark_blue)

    render_logo = font3.render(logo_label, 1, green)
    logo_size = render_logo.get_size()
    render_opt1 = font.render(opt1_label, 1, color1)
    opt_size = render_opt1.get_size()
    render_opt2 = font.render(opt2_label, 1, color2)
    render_opt3 = font.render(opt3_label, 1, color3)
    running = True
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT():
                quit()

(I did all the imports and pygame.init() before)

1
  • 1
    The error tells you what is wrong. You can't call pygame.QUIT. It's an integer, not a function. Why are you calling it? Commented Nov 5, 2014 at 19:37

2 Answers 2

2

Since you didn't include the stacktrace, I am unsure if you have more than one issue. However, this is wrong:

if event.type == pygame.QUIT():

It should be,

if event.type == pygame.QUIT:

As QUIT is an integer, not a function.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to change this.

if event.type == pygame.QUIT()

To:

if event.type == pygame.QUIT

Because pygame.QUIT is not a function it is int (value of 256)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.