Page 1 of 1

Closing windows programmatically

Posted: Fri Oct 06, 2006 3:39 pm
by mctavish
How can I close a GUI window (as if I hit the "close" button) programmatically?

destroying, unmapping, and mapping graphical objects

Posted: Fri Oct 06, 2006 10:15 pm
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.