Dec-29-2017, 03:25 PM
(Dec-29-2017, 08:03 AM)DPaul Wrote: Your e.g. windows app ("object-oriented"), sits there and does nothing until you press a button. My device with python always wants to halt, i have to explicitely keep it running with a while loop. Hardware buttons don't behave like software buttons :-)
Hardware is always there. Software runs until it's done, then stops. There's no such thing as software that does nothing until something happens. The "does nothing" step IS a while loop. That's the only construct available. Even if somehow the button had a kernel module that caused an Interrupt Signal to be sent out, so your program could respond immediately to the button press... it'd still be sitting within a
while True
loop. Otherwise, the program would reach the end, and stop. And if it stops, then it can't still be around to respond to events.