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

Don't use a magicgui widget as a global store for attributes #30

Open
jni opened this issue May 11, 2021 · 0 comments
Open

Don't use a magicgui widget as a global store for attributes #30

jni opened this issue May 11, 2021 · 0 comments

Comments

@jni
Copy link
Owner

jni commented May 11, 2021

Somehow the code evolved to use a magicgui function not for a gui but for its ability to have bound variables, here:

# make a bindable function to shut things down
@magicgui
def close_affinder(layers, callback):
for layer in layers:
layer.events.data.disconnect(callback)
layer.mode = 'pan_zoom'

and here:

close_affinder.layers.bind(points_layers)
close_affinder.callback.bind(callback)

This is generally a gross abuse of magicgui and the Python programming language. 😂 Since the main widget is stateful, the correct thing to do is to make a class subclassing FunctionGui.

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

1 participant