[Tutor] Event loop logic question

Alan Gauld alan.gauld at yahoo.co.uk
Sat Jun 25 18:59:40 EDT 2022


On 24/06/2022 01:57, Phil wrote:
> Problem solved.
> 
> I suddenly realised, while watching the output of the print statements, 
> that I don't need the update function. Instead the control statements 
> should be in the keyboard reading functions.

I don't know your particular framework but as a general rule UI
changes should be in the paint/draw/update function and only
state data changes in the event handlers. So based purely on
general principles I'd say you are completely wrong and ALL
of the print tatements should be in the update and none of
them in the key hanling functions.

But that assumes that somewhere your framework calls update
regularly to redraw the UI. If that's not the case then all
bets are off. But if it is true you will save yourself an
awful lot of grief later by keeping the print statements
in one place.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list