Re: Event-driven / callback programming of mouse or keyboard

Jerzy Karczmarczuk <[email protected]> Mon, 21 May 2012 22:52:31 +0200
Newsgroups gmane.comp.python.visualpython.user
Organization UCBN
Message-ID <[email protected]>
Bruce Sherwood answers :
> I can't think of a way to do that within the existing structure.
to:
> Sophie:
>> Is there any way to do event-driven programming, with callbacks for mouse or keyboard events? I would rather not use the polling style shown in example on the web site.
>>
Event-driven style is not magic, and if you will to pay the price of 
some indirections, YOU CAN implement it yourself. You may also introduce 
"user events" not related to any hardware action, but which implement 
asynchronous loops.

This small program is a very primitive "planetary system", with looping 
and mouse/keyboard control based on "events". Alt-click adds a random 
planet, just click stops the motion. There is nothing more.

http://users.info.unicaen.fr/~karczma/TEACH/Anima/Progs/psystem.py

Good luck.

Jerzy Karczmarczuk


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/