|
From: Nihat <ng...@gm...> - 2008-07-03 00:13:32
|
Hi,
In a part of my code I use
----
thisline = CL.CustomLine([x1, x2], [y1, y2], color='black', linestyle='--',
picker=2, zorder=20, id=lbl)
self.ax.add_line(thisline)
if (cfg.linedraw_label):
self.ax.text(x2, y2, lbl, fontname='Sans', fontsize=9, picker=2,
zorder=20)
----
In another part of the code I act on pick events
----
def OnPick(self, event):
self.picked = event.artist
if isinstance(self.picked, CL.CustomLine):
if (cfg.select_mode):
<SNIP>
if(cfg.delete_mode):
self.picked.remove()
self.canvas.draw()
if isinstance(self.picked, Text):
if(cfg.delete_mode):
self.picked.remove()
self.canvas.draw()
----
Here are my questions:
1. I have extended the Line2D class as I am using _nolegend_ in the label.
I still wanted to differentiate between lines using something called id. Is
there a better way of doing it with built-in attributes?
2. I can remove the line but somehow the text added to the axes does not
respond to pick events. Anybody has any thoughts?
3. The neat thing would be to add the text into the CustomLine class so
line's label is contained in the class. Not sure how I can do it because
text needs an axis and axis is nor associated with Line2D until you add the
line to axis...
4. How can I add a constant offset like (2 pixels right, 2 pixels up) at the
right end of the line for its text label.
Thanks in advance.
Nihat
|