Closed kekeblom closed 5 years ago
Hi!
One idea would be:
while app.exit_requested:
app.main_loop_iteration()
# other stuff
But the exit_requested
would be absolutely useless in other use cases, not a fan. Then I thought I could turn exit()
into a property, so you could do stuff like
while not app.exit:
app.main_loop_iteration()
...
if thing: app.exit = 0 # Exit with a success return code
... but that feels to me like not being very intuitive / looking weird, and not following the C++ API at all. Then, what about having main_loop_iteration
return a bool, saying False
if the app is meant to exit? That could work well and fix the same issue on the C++ side too I think:
while app.main_loop_iteration():
# other stuff
Thoughts? :)
I feel the last one is probably the cleanest solution and this would support the use case nicely.
Yeah, that's my feeling too :) I'll do the changes and let you know once they hit master
on both the main magnum repo and this one.
The mainLoopIteration()
is currently only on Sdl2Application, not on GlfwApplication. Is that okay?
With mosra/magnum@82f53862e12a7318bb1e3c62e8307422290b36ab and 7068412b7c8d634b20471d6d312936a0ab32c5a0 this is now in master :)
Wow that was fast. Was actually planning to take a stab at this myself today.
Thanks a lot for the help!
Is it possible to have the main loop owned by the python application?
What I would like to do is something like this:
Now this could be achieved by just exposing the
mainLoopIteration
method onSdl2Application
. However, then the python application would have to check for the exit flag and the flags are not exposed outside the application class.Is there a way to do this that I'm overlooking or would this have to be implemented? If this would have to be implemented, what do you feel would be the appropriate way to change the api to support such a use case?