Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute error when registering events #40

Closed
kpj opened this issue Jul 23, 2017 · 2 comments
Closed

Attribute error when registering events #40

kpj opened this issue Jul 23, 2017 · 2 comments

Comments

@kpj
Copy link

kpj commented Jul 23, 2017

Hello,

consider the following functional code:

import mpv

player = mpv.MPV()
def foo(ev):
    print(ev) 
player.register_event_callback(foo)

This works as expected.

If however, I try to register not a function, but a (class-)method instead, I get an AttributeError:

class Bar:                               
    def baz(self, ev):
        print(ev)
player.register_event_callback(Bar().baz)
~/.local/lib/python3.6/site-packages/mpv.py in register_event_callback(self, callback)
    816         my_handler.unregister_mpv_events()
    817         """
--> 818         callback.unregister_mpv_events = partial(self.unregister_event_callback, callback)
    819         self._event_callbacks.append(callback)
    820 

AttributeError: 'method' object has no attribute 'unregister_mpv_events'

Is there a way of fixing this?

@jaseg
Copy link
Owner

jaseg commented Jul 23, 2017

I've removed that now. Try again with the current master or v0.2.7 from PyPI and it should work.

@kpj
Copy link
Author

kpj commented Jul 23, 2017

That worked, thanks a lot!

@kpj kpj closed this as completed Jul 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants