Pygame.event.Event (). type == pygame.QUIT, confusion

Consider these lines in a pygame loop:

ev = pygame.event.poll()
ev.type == pygame.QUIT

From: http://openbookproject.net/thinkcs/python/english3e/pygame.html

From what I understand, the function pygame.event.poll()creates an instance of the Event class in the event module of the pygame package.

I am. Now it ev.typeis an attribute call (?), But how do you know what values ​​it can have? How can you even tell from the pygame documentation that it has the ability to equal pygame.QUIT?

II. What is pygame.QUIT? How does he get value?

III. help('pygame.QUIT')says pygame.QUIT = class int(object). What do you call this construction?

+5
source share
3 answers
ev = pygame.event.poll()

- , ( , , , ). ( Event) ev.

ev.type

type Event, .

== pygame.QUIT

, , pygame.QUIT.

http://www.pygame.org/docs/ref/event.html - ( , ):

QUIT             none
ACTIVEEVENT      gain, state
KEYDOWN          unicode, key, mod
KEYUP            key, mod
MOUSEMOTION      pos, rel, buttons
MOUSEBUTTONUP    pos, button
MOUSEBUTTONDOWN  pos, button
JOYAXISMOTION    joy, axis, value
JOYBALLMOTION    joy, ball, rel
JOYHATMOTION     joy, hat, value
JOYBUTTONUP      joy, button
JOYBUTTONDOWN    joy, button
VIDEORESIZE      size, w, h
VIDEOEXPOSE      none
USEREVENT        code
+6

pygame.QUIT - int, pygame.

>>> import pygame
>>> pygame.QUIT
12

: http://www.pygame.org/docs/ref/event.html. ( ).

+4

pygame.QUITSent when the user clicks the X button, or when the system asks for the completion of the process. If ignored, it can still be killed by the system. It allows you to save before you exit.

+4
source

All Articles