Observing a button press with RxPY

226 Views Asked by At

How can I "listen" to stream of key press events with Python?

I want to do something like this:

click_stream.map(lambda k: k.key)

But how can I create this click_stream?

1

There are 1 best solutions below

0
On

It depends on the UI framework, but basically you should:

  • create a Subject
  • call the Subject.on_next method in the event callback passing the required args
  • subscribe to the Subject

you can use the timeflies example as a guide.