Skip to content

Added decorators for adding callbacks to menus #134

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

Merged
merged 2 commits into from
Jul 1, 2016
Merged

Added decorators for adding callbacks to menus #134

merged 2 commits into from
Jul 1, 2016

Conversation

Mahi
Copy link
Contributor

@Mahi Mahi commented Jun 29, 2016

This allows one to define the menu before its callbacks while keeping the code clean.

Mahi added 2 commits June 29, 2016 08:24
This allows one to define the menu before its callbacks while keeping the code clean.
@Ayuto
Copy link
Member

Ayuto commented Jun 29, 2016

This just moves a single line...

def my_callback(...):
    pass
menu.select_callback = my_callback
menu.register_select_callback
def my_callback(...)
    pass

I would rather update the menus package to support overrideable methods instead of callbacks.

@Mahi
Copy link
Contributor Author

Mahi commented Jun 30, 2016

You're right and it's just a feature suggestion instead of an actual improvement. But I find it much more beautiful and clear than the current version (think of a very long function where menu.select_callback = my_callback will get lost in the clutter quite easily, unless you separate it with an empty line or two). And it comes at the cost of nothing! But you guys decide :)

I would rather update the menus package to support overrideable methods instead of callbacks.

Absolutely. But until someone has enough time and patience to do that...

@Ayuto Ayuto merged commit 56b8876 into Source-Python-Dev-Team:master Jul 1, 2016
@Mahi Mahi deleted the patch-1 branch July 1, 2016 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants