@@ -175,7 +175,9 @@ class Viewer(pyglet.window.Window):
175175
176176 def __init__ (self , scene , viewport_size = None ,
177177 render_flags = None , viewer_flags = None ,
178- registered_keys = None , run_in_thread = False , ** kwargs ):
178+ registered_keys = None , run_in_thread = False ,
179+ auto_start = True ,
180+ ** kwargs ):
179181
180182 #######################################################################
181183 # Save attributes and flags
@@ -188,6 +190,7 @@ def __init__(self, scene, viewport_size=None,
188190 self ._is_active = False
189191 self ._should_close = False
190192 self ._run_in_thread = run_in_thread
193+ self ._auto_start = auto_start
191194
192195 self ._default_render_flags = {
193196 'flip_wireframe' : False ,
@@ -346,7 +349,11 @@ def __init__(self, scene, viewport_size=None,
346349 self ._thread = Thread (target = self ._init_and_start_app )
347350 self ._thread .start ()
348351 else :
349- self ._init_and_start_app ()
352+ if auto_start :
353+ self ._init_and_start_app ()
354+
355+ def start (self ):
356+ self ._init_and_start_app ()
350357
351358 @property
352359 def scene (self ):
@@ -557,7 +564,7 @@ def on_draw(self):
557564 if self ._renderer is None :
558565 return
559566
560- if self .run_in_thread :
567+ if self .run_in_thread or not self . _auto_start :
561568 self .render_lock .acquire ()
562569
563570 # Make OpenGL context current
@@ -592,7 +599,7 @@ def on_draw(self):
592599 align = caption ['location' ]
593600 )
594601
595- if self .run_in_thread :
602+ if self .run_in_thread or not self . _auto_start :
596603 self .render_lock .release ()
597604
598605 def on_resize (self , width , height ):
0 commit comments