yield b
while True:
    a, b = b, a + b
yield b


class Clickonacci(PyMouseEvent):

    def __init__(self):
        PyMouseEvent.__init__(self)
self.fibo = fibo()

def click(self, x, y, button, press):
    """Print Fibonacci numbers when the left click is pressed."""
if button == 1:
    if press:
        print(next(self.fibo))
else:
    self.stop()
C = Clickonacci()
C.run()
How to detect mouse click in python 3 on linux?