I have a loop in the code that is supposed to keep executing a command until the user presses a button. The problem is, I cannot figure out what I should make the command of the button in order to break out of the loop. Here is a simplified version of the code I have right now:
import direct.directbase.DirectStart
from direct.gui.DirectGui import *
gbl = 0
def loop():
global gbl
while(gbl):
print "loop go"
def toggle():
if gbl: gbl = 0
else: gbl = 1
b = DirectButton(text = ("toogle"), command = toggle, scale=.05)