import tkinter as tk #-- constants: width = 100 heigth = 100 max_iteraties = 30 groot = 1000 upperleft = complex(-1, 1) downright = complex(1, -1) #-- extra variables and functions: xfactor = (downright.real - upperleft.real) / width yfactor = (downright.imag - upperleft.imag) / heigth def world(i, j): return complex(i * xfactor + upperleft.real, j * yfactor + upperleft.imag) def screen(z): return ( int((z.real-upperleft.real)/xfactor), int((z.imag-upperleft.imag)/yfactor) ) #-- main program: root = tk.Tk() canvas = tk.Canvas(root, width=width, height=heigth) canvas.pack() #-- change this, if you like: z = complex(0.75,0.3) for i in range(20): z2 = z*z canvas.create_line(screen(z), screen(z2)) z = z2 #-- don't touch what's next usingIDLE = 0 if not usingIDLE: root.mainloop()