@timjhinton a few key points which will probably let you understand better what is happening:
- button actions functions must return, before anything is displayed on the screen. That is because button actions are called in the main thread, and the UI, touch handling, etc all stops until your action returns.
- present_modal_scene is NON Blocking. This isn't necessarily obvious from the docs, and often when one thinks of a modal dialogue, you think of something that waits until the dialogue is closed before proceeding.
Since it returns immediately, your update label function gets called immediately, before you have pressed the button in your modal scene
The way to handle this sort of thing is via a completion handler function, which is defined in your main scene, but the modal scene is responsible for calling when it is done. So you would set my_modal_scene.completion = self.update_labels (or, a local function that does whatever other cleanup needs to happen, unpaying your scene ,etc) then in your button handling method in your modal scene, you would call self.completion().
def update_weekly(self):
self.paused = True
self.run_weekly_scene = BudgetClasses.WeeklySubMenuScene("Weekly Payout", "Who gets paid?",["Both", "Maddex", "Ryker", "Back"])
def completion():
self.run_weekly_scene = None
self.update_labels()
self.pause = False
self.present_modal_scene(self.run_weekly_scene)
# weekly_scene must call completion on close or button press
You could also block waiting for the scene to close by using a threading.Lock, but then you need to make sure that your button action is decorated with in_background, so that the action returns immediately (in_background schedules the action on the background thread, exiting the main thread immediately). But this pattern can lead to unexpected behavior, since the background thread is shared sometimes, and you have to be careful to only ever use ont thing at a time on it. You can create your own threading.Thread, but that is more complicated. The "completion handler callback" shown above is thread safe and easy (which is why a lot of apple frameworks use that pattern as well). You just have to handle the "cleanup" code in a the completion handler, rather than after the call to present_modal_scene, and it will be called later by the modal scene.