Example:
from neuron import h, gui from math import sin, cos deck = h.Deck() deck.intercept(1) # all following windows will be placed in the deck ncard = 10 # there will be 10 cards in the deck def mkgraph(n): """make a new graph""" g = h.Graph() # the new graph is declared g.size(-4, 4, -4, 4) # and given a size g.begin() for i in xrange(629): t = 0.01 * i g.line(3 * cos(t), 3 * sin(n * t)) g.flush() # draw the plot def flip_function(i): """return a function that flips to the ith card""" return lambda: deck.flip_to(i) mkgraph(1) # make the first graph, so it will appear while the other deck.intercept(0) # 9 graphs are being made deck.map() # put the deck on the screen deck.flip_to(0) # show the first plot of the deck h.xpanel('flip to') # create a panel titled "flip to" for i in xrange(ncard): # create radio buttons which will bring each card to the front h.xradiobutton('card %d' % (i + 1), flip_function(i), i == 0) h.xpanel() # close off the set of panel commands for i in xrange(1, ncard): # now that the first card appears on the screen, make the rest deck.intercept(1) # reopen the deck mkgraph(i + 1) # make a plot for each other card deck.intercept(0) # close the deck![]()
makes a deck of windows showing the plots \(\{(3\cos(t), 3\sin(i\,t)): 0 \le t \le 2\pi \}\), where \(i=1 \ldots 10\). You can see in this example how the panel of radio buttons enhances your ability to access a particular plot.
.map("label")
.map("label", left, top, width, height)
Example:
from neuron import h, gui d = h.Deck() d.map() # actually draws the deck window on the screencreates an empty deck window on the screen.
Warning
The labeling argument does not produce a title for a deck under Microsoft Windows.
h.HBox()
h.HBox(frame)
h.VBox()
h.VBox(frame)
h.VBox(frame, 0or1)
A box usually organizes a collection of graphs and command panels, which would normally take up several windows, into a single window. Anything which can have its own window can be contained in a box.
As with all classes, a box must have an object reference pointer, and can be manipulated through this pointer. You must use the .map command to make a box appear on the screen.
A VBox with a second arg of 1 makes a vertical scrollbox.
HBox() tiles windows horizontally.
VBox() tiles windows vertically.
The default frame is an inset frame. The available frames are:
Example:
from neuron import h, gui b = h.VBox(2) b.map()creates an empty box on the screen with a light gray inset frame.
box.intercept(1)
box.intercept(0)
Example:
from neuron import h, gui vbox = h.VBox() vbox.intercept(1) # all following creations go into the "vbox" box g = h.Graph() h.xpanel("") x = h.ref(3) h.xpvalue('x', x) def on_button_press(): print 'you pressed the button' h.xbutton("press me", on_button_press) h.xpanel() vbox.intercept(0) # ends intercept mode vbox.map() # draw the box and its contents![]()
.map("label")
.map("label", left, top, width, height)
Example:
from neuron import h, gui b = h.VBox(2) b.map() # actually draws the box on the screencreates an empty box on the screen with a light gray inset frame.
b.unmap()
b.unmap(accept)
Dismiss the last mapped window depicting this box. This is called automatically when the last hoc object variable reference to the box is destroyed.
If the box is in a VBox.dialog() the argument refers to the desired return value of the dialog, 1 means accept, 0 means cancel.
Example:
from neuron import h, gui import neuron import numpy def size(obj): if obj.ismapped(): s = numpy.array([0, 0, 0, 0], 'd') obj.size(neuron.numpy_element_ref(s, 0)) print obj.hname(), s[0], s[1], s[2], s[3] # create two vboxes, but only map 1 vb1, vb2 = h.VBox(), h.VBox() vb1.map() def show_all_sizes(): vboxes = h.List('VBox') for i in xrange(int(vboxes.count())): size(vboxes.object(i)) show_all_sizes() # can now manually resize the mapped VBox and call show_all_sizes again, # if desired
box.save("proc_name")
box.save("string")
box.save(str, 1)
box.save(str, obj)
Execute the procedure when the box is saved.
The default save procedure is to recursively save all the items in the box. This is almost always the wrong thing to do since all the semantic connections between the items are lost.
Generally a box is under the control of some high level object which implements the save procedure.
box.save("string") writes stringn to the open session file.
box.save(str, 1) returns the open session file name in str.
The object is referenced by the box. When the box is dismissed then the object is unreferenced by the box. This provides a way for objects that control a box to be automatically destroyed when the box is dismissed (assuming no other objectvar references the object). When .ref is used, the string in .save is executed in the context of the object.
Note: When objects are inaccessible to hoc from a normal objref they can still be manipulated from the interpreter through use of their instance name, ie the class name followed by some integer in brackets. As an alternative one may also use the dismiss_action() to properly set the state of an object when a box it manages is dismissed from the screen.
b = box.dialog("label")
b = box.dialog("label", "Accept label", "Cancel label")
Put the box in a dialog and grabs mouse input until the user clicks on Accept (return 1) or Cancel (return 0).
The box may be dismissed under program control by calling b.unmap(boolean) where the argument to VBox.unmap() is the desired value of the return from the dialog.
b.adjust(size)
b.adjust(size, index)
When a session file is created, the windows with higher priority (larger integer) precede windows with lower priority in the file. This allows windows that define things required by other windows to be saved first. For example, a CellBuild window has a larger priority than a PointProcessManager which needs a section declared by the cell builder. A MulRunFitter has even lower priority since it may refer to the point process managed by the manager. Default priority is 1.
The priority scheme, of course, does not guarantee that a session file is consistent in isolation since it may depend on windows not saved.
Priority range is -1000 to 10000
Some existing priorities are:
SingleCompartment 1000
CellBuild 1000
PointProcessManager 990
Electrode 990
PointGroupManager 980
NetworkReadyCell 900
ArtificialCell 900
NetGUI 700
SpikePlot 600
Inserter 900
RunFitter 100
FunctionFitter 100
MulRunFitter 100