Re: cleaning up

Aaron Mavrinac <[email protected]>
Newsgroups gmane.comp.python.visualpython.user
Message-ID <CAJqNogeEbOT+gD2kq2bnidbqZKP_BTu+-h7BinXso9DA1Wj5rg@mail.gmail.com>
On Thu, Aug 25, 2011 at 8:04 AM, Ben Axelrod <[email protected]> wrote:
> 1. is there a way to delete all objects in the scene?  i don't see a
> scene.clear() type of function.

The visual.ui.display object (by default, the active one is
visual.scene) maintains a tuple with references to all visible objects
called (oddly enough) 'objects'. You can clear the scene by making
them all invisible.

for obj in visual.scene.objects:
    obj.visible = False

If there are no external references to the objects, since 'objects'
only refers to *visible* objects, this will also (I think) remove the
last reference and the objects will be GC'd by Python, so this
shouldn't be leaky.

> 2. is there a way to programatically close the visual python window?

The visual.ui.display object has a 'visible' property also; setting
display.visible = False closes the window.

Strangely, however, display.visible.objects continues to refer to all
previously visible objects, yet setting display.visible = True does
not bring them back (and even attempting to manually make them visible
via these references doesn't appear to work). Thus, it is probably
prudent to at least do the above "clearing" if you're going to do
this, as it is evidently leaky otherwise.

-- 
Aaron Mavrinac
www.mavrinac.com

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Visualpython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/visualpython-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.