From: Bruce S. <Bru...@nc...> - 2009-06-28 15:59:46
|
There does seem to be a bug, but it's easy to make it work properly. Consider this: d = display() box() my_scene = visual.display.get_selected() my_scene.mouse.getclick() my_scene.visible = False # makes invisible but does not delete print my_scene del my_scene # should get rid of it completely ##d = display() sphere(pos=(2,0,0)) # this should create a new scene, but no window appears print visual.display.get_selected() # shows the same ID as before The cure is to uncomment the second display() statement, and then it works as expected. In other words, don't rely on the default "scene" mechanism but make your own displays if you are going to manipulate those displays. I'm worried that something's apparently wrong with the del statement, which should have gotten rid of the first display completely. I'll look into that. Setting all the objects to invisible before making the display invisible doesn't change anything. Bruce Sherwood Guy K. Kloss wrote: > Hi, > > as some may have noticed, I also run VPython with many things in batch mode. > Unfortunately I've just hit a bump doing so. I introduced another layer for > batching some computations/visualisations. So I'm wrapping my module and > calling it repeatedly with changing parameters in a batch. Unfortunately when > I'm doing that for me VPython "misbehaves". I cannot seem to find a way to > discard a previous scene to create a new one. Whenever I just do it naively, I > get this error: > > RuntimeError: Cannot change parameters of an active window > > As the new scene is being initialised with window title, size, ... > > I've already tried to retrieve the current scene with > > my_scene = visual.display.get_selected() > > And then set its visibility to False: > > my_scene.visible = False > > In this case the program just stalls and needs to be killed from another > console. Or I try to delete the scene instance using: > > del my_scene > > or > > del visual.scene > > Which doesn't do anything as apparently visual.scene is a static module > variable that cannot be discarded. > > Any ideas on how to make use of it in a sensible way without having to > manually create new processes for each sample just to discard the scene? > > Guy > > |