![]() |
| ||
| Drawing a moving circle with Python Tkinter + good GUI tutorial Hello, 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 * 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, Ilya |
| ||
| Re: Drawing a moving circle with Python Tkinter + good GUI tutorial Hi Ilya, If you want to do interactive simulations, I think you might be better off checking out pygame, which is designed for games but can easily be adapted for this kind of thing. I have written simple 2D epithelial tumor growth simulations in pygame - I can't imagine how you could accomplish such a thing in Tkinter, short of setting up a separate thread to mess with the Tkinter root or canvas, and from what I remember that introduces all kinds of synchronization issues. The pygame tutorials and API documentation are also available on the site I linked. Hope this helps! |
| ||
| Re: Drawing a moving circle with Python Tkinter + good GUI tutorial I agree with G-Do's advice, but if you are stuck using Tkinter, then you want to think like this: events instead of timeline. In other words, something has to trigger your application to move the circle. Here's a version that fixes a bug and also moves the circles on every mouse click. from Tkinter import * |
| ||
| Re: Drawing a moving circle with Python Tkinter + good GUI tutorial All right, thank you. Ilya |
| All times are GMT -4. The time now is 5:51 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC