… the program plots all the lines (26) …
Actually, the lines are 23 because of course
>>> len(range(5, 50, 2))
23
That said… I really wouldn’t know… on my windows box the code you posted runs smoothly, and I can’t see a reason why it shouldn’t. Could there possibly be something you left out of the code you posted? I see a few loose ends and unused bits that make me think that perhaps your real code does a few other things… or your execution environment could be messed up for some reason… but I can’t guess why…
AFAIK, floatcanvas has no particular problem binding many objects at a time. For instance, this will draw and bind 200 lines, and you can increase the number at will:
class MainFrame(wx.Frame):
def __init__(self, *a, **k):
wx.Frame.__init__(self, *a, **k)
self.wincanvas = NavCanvas.NavCanvas(self)
self.canvas = self.wincanvas.Canvas
self.draw()
wx.CallAfter(self.canvas.ZoomToBB)
def draw(self):
center = (0, 0)
step = 200 # will draw 200 lines
radius = 500
points = [(center[0] + (math.cos(2 * math.pi / step * x) * radius),
center[1] + (math.sin(2 * math.pi / step * x) * radius))
for x in range(0, step)]
for n, point in enumerate(points):
self.canvas.AddLine([center, point], LineWidth=2)
label = self.canvas.AddScaledTextBox(str(n), point, Size=5)
label.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.onclic)
def onclic(self, obj):
print(obj.String)
if __name__ == "__main__":
app = wx.App(False)
frame = MainFrame(None)
frame.Maximize()
frame.Show()
app.MainLoop()