Drawing with multiple panels
Here's something that I didn't mention in today's lecture about
working with Moveablepoints when you have multiple figures. Each
figure is contained in something called a JyPanel and
your Moveablepoint needs to be added to its
JyPanel explicitly.
Here's an example. Suppose you want something like this:
The typical way we have done this is to define two draw methods
and add them to a frame:
def graph(p):
....
def slider(p):
....
openframe({'c':[400, 400, graph], 's':[400, 40, slider]})
|
When add a Moveablepoint, we need to know
to which figure it belongs. Here's how we do that.
def graph(p):
....
def slider(p):
....
graphpanel = JyPanel(400, 400, graph)
sliderpanel = JyPanel(400, 40, slider)
def move(point, x, y):
....
refresh()
point = Moveablepoint(0, 0, move)
sliderpanel.addmoveable(point)
openframe({'c':graphpanel, 's':sliderpanel})
|
Also, note the refresh() in the move
function.
|