upwart
Sep 03, 2016 - 10:20
Maybe a stupid question, but I can't find how to stop a Scene based program. Of course, there's the cross at the upper righthand corner, but how can I force a stop by code?
Maybe a stupid question, but I can't find how to stop a Scene based program. Of course, there's the cross at the upper righthand corner, but how can I force a stop by code?
use self.view.close()
import scene, ui
class MyScene(scene.Scene):
def setup(self):
self.test_label = scene.LabelNode('Hello World',
position=self.size/2.0, parent=self)
self.close_label = scene.LabelNode('Close scene',
position=(self.size[0]/2, self.size[1]/2-100),
parent=self)
def touch_began(self, touch):
if touch.location in self.close_label.frame:
self.view.close()
scene.run(MyScene())