> def move_panel(self, evt): > def gen(): > for x in range(200): > yield x > for x in range(200, 0, -1): > yield x > for x in gen(): > self.square.SetPosition((x, 30)) > time.sleep(0.005) >
I can't help with the performance problem, but you don't really need a generator for your x-values. This works: def move_panel(self, evt): for i in xrange(400): x = 200-abs(i-200) self.square.SetPosition((x, 30)) time.sleep(0.005) The generator *does* make for clearer code, though! -John -- http://mail.python.org/mailman/listinfo/python-list