Forum Archive

NavigationView misses pops

Arcilla

The following reduced program

import ui

nav_view = ui.NavigationView(ui.View(background_color='red'))
nav_view.present('sheet')
nav_view.push_view(ui.View(background_color='white'))
nav_view.push_view(ui.View(background_color='blue'))
nav_view.push_view(ui.View(background_color='orange'))
nav_view.pop_view()
nav_view.pop_view()
nav_view.pop_view()

ends with a blue area, not with the expected red one. I wonder what goes on here.
In my full program, it pops (only) twice.
Can anyone help, please?

JonB
import ui,time

nav_view = ui.NavigationView(ui.View(background_color='red'))
nav_view.present('sheet')
nav_view.push_view(ui.View(background_color='white'))
nav_view.push_view(ui.View(background_color='blue'))
nav_view.push_view(ui.View(background_color='orange'))

time.sleep(3.)
v1=nav_view.pop_view()
time.sleep(1.)
v2=nav_view.pop_view()
time.sleep(1.)
v3=nav_view.pop_view()
time.sleep(1.)

the problem is that because nav_view push/pop, etc are run in the python thread, not the main thread, you end up calling pop before anything is even presented.

there is not a simple way around this without the ugly sleep, that i could discover. ui.delay or on_main_thread didnt work the way i had hoped.

Arcilla

Thank you! In my actual script, timings are a bit different, and that must be why 2 pops come through! I’ll have to experiment a bit to get it right then. Thanks again.