Table Of Contents
New in version 1.1.0.
This part of Kivy is still experimental and this API is subject to change in a future version.
This is a class that can record and replay some input events. This can be used for test cases, screen savers etc.
Once activated, the recorder will listen for any input event and save its properties in a file with the delta time. Later, you can play the input file: it will generate fake touch events with the saved properties and dispatch it to the event loop.
By default, only the position is saved (‘pos’ profile and ‘sx’, ‘sy’, attributes). Change it only if you understand how input handling works.
The best way is to use the “recorder” module. Check the Modules documentation to see how to activate a module.
Once activated, you can press F8 to start the recording. By default, events will be written to <currentpath>/recorder.kvi. When you want to stop recording, press F8 again.
You can replay the file by pressing F7.
Check the Recorder module module for more information.
You can manually open a recorder file, and play it by doing:
from kivy.input.recorder import Recorder rec = Recorder(filename='myrecorder.kvi') rec.play = True
If you want to loop over that file, you can do:
from kivy.input.recorder import Recorder def recorder_loop(instance, value): if value is False: instance.play = True rec = Recorder(filename='myrecorder.kvi') rec.bind(play=recorder_loop) rec.play = True
Recording more attributes¶
You can extend the attributes to save on one condition: attributes values must be simple values, not instances of complex classes.
Let’s say you want to save the angle and pressure of the touch, if available:
from kivy.input.recorder import Recorder rec = Recorder(filename='myrecorder.kvi', record_attrs=['is_touch', 'sx', 'sy', 'angle', 'pressure'], record_profile_mask=['pos', 'angle', 'pressure']) rec.record = True
Or with modules variables:
$ python main.py -m recorder,attrs=is_touch:sx:sy:angle:pressure, profile_mask=pos:angle:pressure
- Unable to save attributes with instances of complex classes.
- Values that represent time will not be adjusted.
- Can replay only complete records. If a begin/update/end event is missing, this could lead to ghost touches.
- Stopping the replay before the end can lead to ghost touches.
Recorder class. Please check module documentation for more information.
Fired when the playing stops.
Changed in version 1.10.0: Event on_stop added.
Number of events recorded in the last session.
Filename to save the output of the recorder.
Boolean to start/stop the replay of the current file (if it exists).
Boolean to start/stop the recording of input events.
Attributes to record from the motion event.
Profile to save in the fake motion event when replayed.