Pythonista-Issues
Pythonista-Issues copied to clipboard
Displaying modal Scene from Scene that has no children gives `max() arg is an empty sequence` error
This is quite simple problem in the scene.py.
Replication: I'm writing an app that will present a series of Scenes based on timing or user actions (mostly tapping to skip, like in the Stories on social apps). The app is managed by the base Scene that just sets the background colour and manages the timing in the did_evaluate_actions method. This base scene has no children. And when the Base.show_modal_scene(otherScene) is called it gives max() arg is an empty sequence, because the scene.py code assumes (line 125) that the base Scene that displays a modal has other children, as seen on the screenshot:
Fix: add a check if for children existing:
other_scene.z_position = 1 + max(n.z_position for n in self.children) if self.children else 0
if self.children:
self.present_model_scene(...
I did other workaround, but the points are:
- nowhere in the docs it says that Scene should have children first to display a modal scene on top;
- it would be an illogical design decision to make it that way;
- the fix is trivial, I gave one at the end of my report.