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

Add manual and docstring-parsed tooltips #100

Merged
merged 1 commit into from
Jan 16, 2021

Conversation

tlambert03
Copy link
Member

@tlambert03 tlambert03 commented Jan 14, 2021

This closes #94 by adding an option to provide a tooltip parameter to any widget. When using with a magicgui decorator, tooltips will be parsed (by default) from the first sentence of the corresponding parameter description in the docstring (ReST, google and numpy docstrings supported). Auto-tooltips can be turned off using magicgui(tooltips=False), or overridden for each parameter specifically.

# during widget creation:
widget = LineEdit(tooltip="Enter a value")

# with magicgui
@magicgui(x={"tooltip": "override tooltip"}, z={"tooltip": None})
def func(x: int, y: str = "hi", z=None):
    """Do a little thing.

    Parameters
    ----------
    x : int
        An integer for you to use
    y : str, optional
        A greeting, by default 'hi'. Only the first sentence
        will be used. Even if the docstring is very long, etc...
    z : Any, optional
        No tooltip for me please.
    """
    pass

assert func.x.tooltip == "override tooltip"
assert func.y.tooltip == "A greeting"  # the "by default" part is also stripped
assert not func.z.tooltip

@@ -293,28 +294,6 @@ def native(self):
"""Return native backend widget."""
return self._widget._mgui_get_native_widget()

def show(self, run=False):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of this is just moved in this PR... only new things is the tooltip property

@codecov
Copy link

codecov bot commented Jan 14, 2021

Codecov Report

Merging #100 (8c9030c) into master (50f6829) will decrease coverage by 0.13%.
The diff coverage is 89.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
- Coverage   86.16%   86.03%   -0.14%     
==========================================
  Files          15       14       -1     
  Lines        1728     1740      +12     
==========================================
+ Hits         1489     1497       +8     
- Misses        239      243       +4     
Impacted Files Coverage Δ
magicgui/widgets/_protocols.py 75.14% <66.66%> (-0.30%) ⬇️
magicgui/widgets/_bases.py 88.43% <84.37%> (+0.15%) ⬆️
magicgui/function_gui.py 94.81% <94.44%> (-0.06%) ⬇️
magicgui/widgets/_concrete.py 81.70% <95.65%> (+0.88%) ⬆️
magicgui/backends/_qtpy/widgets.py 81.88% <100.00%> (+0.26%) ⬆️
magicgui/types.py 100.00% <100.00%> (ø)
magicgui/signature.py 95.18% <0.00%> (-2.41%) ⬇️
magicgui/type_map.py 89.40% <0.00%> (+0.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50f6829...2858311. Read the comment docs.

@tlambert03
Copy link
Member Author

@haesleinhuepf, you had expressed an interest in this. have a look at the API above and let me know if you have any thoughts

Copy link
Contributor

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@tlambert03 tlambert03 merged commit 699b9a4 into pyapp-kit:master Jan 16, 2021
@tlambert03 tlambert03 deleted the tooltips branch January 16, 2021 14:49
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

Successfully merging this pull request may close these issues.

Tooltips
2 participants