import tkinter as tk #-- constants: width = 100 heigth = 100 max_iterations = 30 groot = 1000 upperleft = complex(-2, 1.25) downright = complex(1, -1.25) #-- extra variables and functions: xfactor = (downright.real - upperleft.real) / width yfactor = (downright.imag - upperleft.imag) / heigth def world(i, j): """screen coordinates are transformed to world coordinates (couple of ints is transformed in one complex number)""" return complex(i * xfactor + upperleft.real, j * yfactor + upperleft.imag) def screen(z): """world coordinates are transformed to screen coordinates (complex number is transformed in couple of ints)""" 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 want another effect: canvas.create_line(0,0,width/2,heigth/2) canvas.create_rectangle(20, 30, 25, 35, fill="black", outline="") #-- stop here; don't change what's next usingIDLE = 0 if not usingIDLE: root.mainloop()