-
Notifications
You must be signed in to change notification settings - Fork 49
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
connecting event vs value outputs #173
Comments
totally agree, that's a strange case! ... I honestly can't event remember now why you need a double
I agree, that that one additional level is kind of annoying, and we could consider just calling callbacks with the new value (rather than the event object itself) ... but a fair amount of additional information about the event that triggered the change is unfortunately lost in that case. I'm not saying it's not a worthwhile loss, but it doesn't come without a cost to flexibility.
outside of the strange def my_callback(event):
new_widget_value = event.value
widget.changed.connect(my_callback) as for the user indicating what the callback should get passed... that seems rather complicated actually. It's pretty typical for a callback to be required to accept a standard argument. As mentioned above, we can definitely discuss & change what that argument(s) should be... but I'm not sure it should be user-adjustable. As for the lambda, that's purely optional syntax. No users have to make lambdas if they don't want to, they can always use a named function as shown above. So, thanks for opening this! I do think it's worth considering changing what the callback is given. That would be a relatively big breaking change though, so would require a major version change. In the meantime, I'll fix the FileEdit and you can generally assume (with this one exception) that the new value is at |
thanks for the discussion and the tips! My reading of magicgui's goal in life is to simplify gui programming so much that python programmers and scientists can hook up a quick gui without a bunch of pyqt syntax or specialized knowledge. In that spirit, I'm imagining a scenario where anyway, I appreciate your work on |
gonna leave this open because I think it's worth thinking about some more. I was already kinda leaning towards callbacks being given the |
I like the idea of different names for the connecting the full I agree that the people who want the full |
I found the
lambda e: callback(e.value.value)
here a little confusing, especially given the current docs where the callback is shown receiving theevent
from thecalled
signal and then pulling out theevent.value
to print it (or whatever).Idea: in addition to the lovely selection of signals, could
magicgui
provide a bare value returned by the decorated function? My feeling here is that someone usingmagicgui
should have some way of defining what gets passed to a callback without having to make alambda
or debug how many times to get a.value
attribute. Side benefit is that downstream code used as callbacks wouldn't have to modify the inputs either.The text was updated successfully, but these errors were encountered: