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

gui: add WaiterOverlay. To display processing wheel on top of another widget #3876

Merged
merged 36 commits into from
Nov 21, 2023

Conversation

payno
Copy link
Member

@payno payno commented Jun 23, 2023

Changelog:

add a silx.gui.widgets.WaitingOverlay

TODO

  • add a silx.gui.widgets.WaitingOverlay
    • display the 'waiting wheel' on top of the parent widget
    • reuse 'silx.gui.widgets.WaitingPushButton.WaitingPushButton' behind
    • remove silx.gui.plot.ImageStack._PlotWithWaitingLabel to use the WaitingOverlay instead
  • add test
  • add example

extra

close #3807

screenshot

Screenshot from 2023-10-24 10-26-17

@vallsv
Copy link
Contributor

vallsv commented Jun 24, 2023

Please remember to remove this poor vvalls from your commit message. It's not me.

@vallsv
Copy link
Contributor

vallsv commented Jun 24, 2023

As reminder

  • Also if we are about to use getWidgetHandle(), this widget is recreated when we change the silx backend. I suggest to create a sigBackendChanged in the PlotWidget. That's something i also have to clean up in Flint, so it would make my life easier. What do you think @t20100
  • The popup widget could also be better centered to the plot, in case it's a plot. @t20100 shows me that it exists an API to reach the rect collation inside the axes.

@vallsv
Copy link
Contributor

vallsv commented Jul 10, 2023

I think it would be better to deprecate _PlotWithWaitingLabel as you did in a previous commit.
That's a way to allow us to drop some code in the future.

@payno
Copy link
Member Author

payno commented Jul 10, 2023

Originally I wanted to deprecate it (_PlotWithWaitingLabel) but at the end I find it more convenient to keep it to handle autoResetWoom and connection with the new WaiterOverlay

src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/utils/waiteroverlay.py Outdated Show resolved Hide resolved
src/silx/gui/utils/waiteroverlay.py Outdated Show resolved Hide resolved
@t20100
Copy link
Member

t20100 commented Jul 10, 2023

it exists an API to reach the rect inside the axes.

Yes it is here:

def getPlotBoundsInPixels(self):
"""Plot area bounds in widget coordinates in pixels.
:return: bounds as a 4-tuple of int: (left, top, width, height)
"""
return self._backend.getPlotBoundsInPixels()

And could be used as a special case for handling resize.

@payno payno changed the title Draft: gui: add WaiterOverlay. To dispaly processing wheel on top of another… Draft: gui: add WaiterOverlay. To display processing wheel on top of another… Jul 20, 2023
@payno payno force-pushed the fix_3807 branch 3 times, most recently from 28da0ee to 941aeea Compare July 20, 2023 08:05
@payno payno changed the title Draft: gui: add WaiterOverlay. To display processing wheel on top of another… gui: add WaiterOverlay. To display processing wheel on top of another… Jul 20, 2023
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/utils/waiteroverlay.py Outdated Show resolved Hide resolved
src/silx/gui/utils/waiteroverlay.py Outdated Show resolved Hide resolved
# register to resize event
parent.installEventFilter(self)

def setText(self, text: str):
Copy link
Member

Choose a reason for hiding this comment

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

For completeness, it would be good to have a getText method and docstrings for the public API

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 For 'homogeneity' I might go for a text() -> str if this is fine with you

src/silx/gui/utils/waiteroverlay.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Show resolved Hide resolved
src/silx/gui/utils/test/test_waiter_overlay.py Outdated Show resolved Hide resolved
Comment on lines 15 to 16
if isinstance(parent, PlotWidget):
parent = parent.getWidgetHandle()
Copy link
Member

Choose a reason for hiding this comment

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

I think we can simplify the parenting, I'll make you a PR if I have a working solution

Copy link
Member

Choose a reason for hiding this comment

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

And parenting by with getWidgetHandle(), the change of backend needs to be handled, or the widget will disappear

@vallsv
Copy link
Contributor

vallsv commented Jul 20, 2023

Finally you have to use plot.sigBackendChanged to update the parent, else i am afraid it will not work when we switch from matplotlib/opengl. I can be wrong.

I can to the job if you like.

As you already have a setParent it's probably not so difficult.

@t20100
Copy link
Member

t20100 commented Jul 21, 2023

Finally you have to use plot.sigBackendChanged to update the parent

This is done (with other things) in #3912

@payno payno changed the title gui: add WaiterOverlay. To display processing wheel on top of another… Draft: gui: add WaiterOverlay. To display processing wheel on top of another… Aug 28, 2023
@t20100
Copy link
Member

t20100 commented Oct 23, 2023

What is the status of this PR?
Is it still a draft?

@payno payno changed the title Draft: gui: add WaiterOverlay. To display processing wheel on top of another… Draft: gui: add WaiterOverlay. To display processing wheel on top of another widget Oct 24, 2023
@payno payno changed the title Draft: gui: add WaiterOverlay. To display processing wheel on top of another widget gui: add WaiterOverlay. To display processing wheel on top of another widget Oct 24, 2023
@payno
Copy link
Member Author

payno commented Oct 24, 2023

What is the status of this PR? Is it still a draft?

I think it is ready for review now :)

payno and others added 24 commits October 24, 2023 17:01
Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

It would be good to add the example to the doc, here: https://github.com/silx-kit/silx/blob/main/doc/source/sample_code/index.rst
And to add the WaitingOverlay to the API doc: https://github.com/silx-kit/silx/tree/main/doc/source/modules/gui/widgets

examples/waiterOverlay.py Outdated Show resolved Hide resolved
examples/waiterOverlay.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Show resolved Hide resolved
src/silx/gui/widgets/WaitingOverlay.py Show resolved Hide resolved
payno and others added 2 commits October 25, 2023 14:19
@t20100 t20100 merged commit e3b5eab into main Nov 21, 2023
8 checks passed
@t20100 t20100 deleted the fix_3807 branch November 21, 2023 13:47
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.

move _PlotWithWaitingLabel to public
3 participants