-
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
Adding uninteractive labels to @magicgui
functions
#567
Comments
hi @multimeric, if you want to add widgets to the layout that are not parameters to your function, then you're better off using the direct widget API You could create a |
Thanks for the suggestion! I just worry that that solution loses some of the elegance of a pure |
Thanks, point taken that there is no easy API for this. I like your def add_label(label: str) -> Callable[[FunctionGui], FunctionGui]:
def _decorator(f: FunctionGui) -> FunctionGui:
# Somehow return a copy of `f` with a new widget added,
# whose text is `label`, without actually modifying `f` itself
return _decorator
@add_label("Hello world")
@magic_factory(widget_init=add_label)
def my_func(x: int, y: str):
... One other suggestion is you could you use the docstring (ie |
docs strings are already parsed and used for tooltips (see the tooltips parameter to magicgui, which defaults to True). So if you're using numpy style docstrings, you should already be getting your But I do agree that it would be good to have a more immediately obvious visual indicator of that functionality (like a little info button icon you could hover on, or perhaps a flag to show them as labels) |
Cool, thanks, I didn't realise that. Is the docstring description part (ie the function's overall description, not the argument descriptions) used for anything though? |
nope, looks like it's only parameters at the moment |
would you want a feature that makes the first line of the docstring a label at the top? |
If you think it suits the design of the project, then yes. Probably defaulting to disabled for backwards compatibility. |
❓ Questions and Help
Let's say I have a simple function that I want made into a GUI, but I want to display some text to the user as a label that isn't treated as a user input. For example it might be instructions to the user. I'm not sure how to do this with
magicgui
. It doesn't seem to use the docstring, nor is there any argument to@magicgui
that helps here. I could created aLabel
widget as a string argument that is immutable, but that gives me a confusing function signature.With this example, how could I add the label
"Here is some descriptive text I want to show my users"
to the top of the form?The text was updated successfully, but these errors were encountered: