So I have been messing around with Navigation Menus and I have a script that will open up various pages back to back to back. I wished to regulate this with buttons, and that the buttons would allow the various pages to pop up. I had it set so that the buttons would set a global variable to True or False, and the script would recognize that once the variable was True, it would open up a new page on the nav menu. However the script does not recognize any of the global variables. Here is the code below. Any Ideas for the variables or am I trying to do this incorrectly?
import ui
from scene import *
global push2
push2 = False
global push3
push3 = False
global push4
push4 = False
global push5
push5 = False
def waterbottle_pressed(Water_Bottle): #custom UI Buttons
global push2
push2 = True
def cardboardbox_pressed(Cardboard_Box):
global push3
push3 = True
def glass_pressed(Glass):
global push4
push4 = True
def paper_pressed(Paper):
global push5
push5 = True
class RecycleMenu():
def __init__(self):
self.background_color = 'white'
self.start_NavView()
def start_NavView(self):
self.view = ui.load_view('RecycleMenuOptions') #custom UI View
self.view.background_color='white'
self.view.name='View1'
nav = ui.NavigationView(self.view)
nav.present(hide_title_bar=True)
if push2==True: #the following are filler tests
view2 = ui.View()
view2.name='View2'
view2.background_color='blue'
nav.push_view(view2)
if push3==True:
view3 = ui.View()
view3.name='View3'
view3.background_color='#e5ffaa'
nav.push_view(view3)
if push4==True:
view4 = ui.View()
view4.name='View4'
view4.background_color='#717171'
nav.push_view(view4)
RecycleMenu() #Code execute