Closing windows programmatically

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc or Python
Post Reply
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Closing windows programmatically

Post by mctavish »

How can I close a GUI window (as if I hit the "close" button) programmatically?
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

destroying, unmapping, and mapping graphical objects

Post by ted »

If you want to destroy an object, re-initialize all objrefs that point to it. Works for objects
spawned from any of NEURON's object classes, not just Graphs.
Example:

Code: Select all

objref gr
gr // hoc will print NULLobject
gr = new Graph() // creates a new Graph object and maps it to the screen
gr // this will print the "real" name of the Graph
objref gr // gr no longer points to the Graph object, which is destroyed
gr // hoc prints NULLobject again
gr = new Graph() // another new Graph object
objref foo
foo = gr // now both gr and foo reference the same Graph
objref gr // the Graph persists because foo still points to it
ojbref foo // the Graph vanishes
For more information about hoc's object model, see chapter 13 of The NEURON Book,
or this fragment from the old "reference manual":
http://www.neuron.yale.edu/neuron/stati ... n/obj.html

An alternative to destroying a Graph is to unmap it (in the above example, gr.unmap()).
It can then be displayed on the screen with the Graph class's view() method. Other
classes of graphical objects, e.g. VBox, have map and unmap methods. To learn more,
see the relevant entries in the Programmer's Reference.
Post Reply