Hello,
ok, I guess that I have to go with 1 (ignore problem) and 2 (file issue) at this time:
https://github.com/kivy/kivy/issues/7098
Note that delaying the call to `self.window.close()` triggers the error too, but if ESC is pressed before the delay has elapsed, the app exits cleanly.
The issue contains self-contained example code. I also copy it below for completeness.
Best regards,
Carsten
#!/usr/bin/env python3
import kivy
kivy.require('1.11.1')
from
kivy.app import App
from kivy.clock import Clock
from kivy.input.recorder import Recorder
from kivy.uix.togglebutton import ToggleButton
class CustomPlayer(Recorder):
def on_play(self, instance, value):
super().on_play(instance, value)
if not value:
# The direct call triggers the error:
# self.window.close()
# The delayed call triggers the error, too. If however ESC is
# pressed before the delay has elapsed, the error does not occur.
Clock.schedule_once(lambda dt: self.window.close(), 3.0)
class MyApp(App):
"""An app with automatic playback of previously recorded input events."""
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.player = CustomPlayer(filename="/tmp/test.events")
def build(self):
return ToggleButton(text='Hello')
def on_start(self):
super().on_start()
self.player.play = True
def on_stop(self):
super().on_stop()
self.player.play = False
print("on_stop()")
if __name__ == '__main__':
with open('/tmp/test.events', 'w') as f:
f.write("#RECORDER1.0\n")
f.write("(1.0, 'begin', 1, {'is_touch': True, 'sx': 0.22875, 'sy': 0.12, 'profile': ['pos']})\n")
f.write("(1.0, 'end', 1, {'is_touch': True, 'sx': 0.22875, 'sy': 0.12, 'profile': ['pos']})\n")
MyApp().run()
Am 19.09.20 um 14:19 schrieb ZenCODE:
> Hmmm. That happens here, in the idle loop..
>
>
https://github.com/kivy/kivy/blob/master/kivy/base.py#L408
>
> It seems as if the stoping has removed the event listeners but the idle loop still expects them to be there,. You can:
>
> 1. ignore it
> 2. investigate further and report the bug if it's valid.
> 3. investigate further, fix the issue and submit a PR for the fix.
>
> Thanks
>
> On Friday, September 18, 2020 at 2:18:22 PM UTC+2
carste...@cafu.de wrote:
>
> Dear Kivy group,
>
> I'm using the Recorder <
https://kivy.org/doc/stable/api-kivy.input.recorder.html> class to record and playback input events. The recording works well, but I cannot figure out how I can stop the app properly when the playback has reached its end: Whatever I do, the log always end with the these lines with errors:
>
> |
> [INFO ][Recorder ]Playingfinished.
> [INFO ][Recorder ]Stopplaying 'tests/test_pause_buttons.events'
> [ERROR ][Base ]Noeventlisteners have been created
> [ERROR ][Base ]Applicationwill leave
> [INFO ][WindowSDL ]exiting mainloop andclosing.
> |
>
> This is the code that I use to add playback to my app:
>
> |
> #!/usr/bin/env python3
> fromkivy.input.recorder importRecorder
> fromLoSTimportLoSTApp
>
>
> classCustomPlayer(Recorder):
> defon_play(self,instance,value):
> super().on_play(instance,value)
> ifnotvalue:
> self.window.close() # Close the window at the end of the playback.
> return
>
>
> classPlayingLoSTApp(LoSTApp):
> """
> This class adds automatic playback of previously recorded input events to our LoST app.
> """
>
> def__init__(self,**kwargs):
> self.player =CustomPlayer(filename="tests/test_pause_buttons.events")
> super().__init__(**kwargs)
>
> defon_start(self):
> super().on_start()
> self.player.play =True
>
> defon_stop(self):
> super().on_stop()
> self.player.play =False
> print("on_stop()")
>
>
> if__name__ =='__main__':
> PlayingLoSTApp().run()
> |
>
> But whatever I do (e.g. putting the `self.window.close()` into `CustomPlayer.on_stop()`), there are always the above ERROR lines in the log.
>
> Any ideas how I can gracefully stop the app when the playback has finished?
>
> Best regards,
> Carsten
>
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
https://groups.google.com/d/topic/kivy-users/eM_0e-c2ykc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
kivy-users+...@googlegroups.com <mailto:
kivy-users+...@googlegroups.com>.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/kivy-users/ce7f0075-0b46-4a14-ba6e-e72a4b67ededn%40googlegroups.com <
https://groups.google.com/d/msgid/kivy-users/ce7f0075-0b46-4a14-ba6e-e72a4b67ededn%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Dipl.-Inf. Carsten Fuchs
Industriegebiet 3 ℅ Rofu
55768 Hoppstädten-Weiersbach
https://www.cafu.de