Nov-21-2020, 07:19 AM
(Nov-20-2020, 11:17 PM)deanhystad Wrote: This is a scope problem and has nothing to do event_request being in another file. You would have the same probem if this were all in one file.THANK YOU SO MUCH! IT WORKED!!!
The problem is you have two exit_request variables. One in events and one in events.update_events. If you want these to reference the same thing you need to rewrite update_events like this:
def update_events(): global exit_request for event in pygame.event.get(): if(event.type == pygame.QUIT): exit_request = eventThis tells Python to use events.exit_request instead of creating events.update_events.exit_request when you do this:
exit_request = eventBy default assignment inside a function creates a new variable. If this were not the case there would be no way to make "local" variables. To prevent this from happening you need to define the variable as "global".