Il 07/07/2010 9.11, Alan Gauld wrote:
"Francesco Loffredo" <ilcomputertraspare...@gmail.com> wrote
... What's the
difference between the two methods?
Its a little bit subtle but I believbe update() updates all widgets
whereas update_idle_tasks will only update those widgets that
have changed since the last update. In a complex GUI this can
be notably faster. Most of the books I've seen recommend not
using update() as it can cause race conditions but I have no experience
of that - because I use update_idle_tasks! :-)
Ok, now I'm using update_idletasks() too (update_idle_tasks() doesn't
exist) and I like it. Thanks a lot!
...
where would you put the
automatic move call, if not where I did? I need an automatic move be
performed at the proper moment, when it's the computer player turn.
Create the auto move in an event handler of its own and associate
with an event. Then raise that event when your players move is finished.
Tkinter will then call the automove for you, updating the screeen
automatically. In an event driven environment control is passed
around by means of events.
I prefer not to make this project fully event driven, because while it's
fairly easy to translate a mouse click into the game coordinates of the
hex that's being clicked, I don't like translating a pair of integers to
some point (maybe the center) of an hexagon, creating an Event
structure, raising that Event and handling it, just to figure out...the
same couple of integers I started with. No, I prefer not to create fake
Events when there's none involved... at least in this little game. I'll
remember your advice for some serious project!
How do you raise an event in Tkinter?
Use the event_generate() method.
And this would have been my next question, thanks for mind-reading!
Alternatively use the after() method with a short delay - say 10ms...
That's what I actually did. It plays like a charm! THANK YOU!
HTH,
SID!
Francesco
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor