I have just started playing around a bit with Python/Tkinter. What I'd like to happen is to draw a circle and then have the circle change its coordinate. The way I was thinking is to have some integer i to be defined 0 and then be updated every frame (ie i+=1), with the drawing algorithm modified appropriately. However, since mainloop() seems to act as a sort of global while(1) loop, this doesn't seem possible. What I have now:
from Tkinter import * root = Tk() def drawcircle(canv,x,y,rad): canv.create_oval(x-rad,y-rad,x+rad,y+rad,width=0,fill='blue') canvas = Canvas(width=600, height=200, bg='white') canvas.pack(expand=YES, fill=BOTH) text = canvas.create_text(50,10, text="tk test") #i'd like to recalculate these coordinates every frame circ1=drawcircle(canvas,100,100,20) circ2=drawcircle(canvas,500,100,20) root.mainloop()
So, how do I go about doing this?
Another question, could anyone suggest a good Tkinter/Python tutorial? What I need is maximally simple and relatively short tutorial that will allow me to make *simple* 2D simulations (ie, my goal for a first Python algorithm is a 1D molecular dynamics simulation using Lennard-Jones potential).
Thank you very much in advance,