Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jrieke
Copy link
Collaborator

@jrieke jrieke commented Dec 23, 2024

Describe your changes

Adds a parameter show_time to st.spinner. If set to True, the spinner shows the elapsed time in a small gray font next to the spinner text. Defaults to False (i.e. same behavior as today).

CleanShot 2024-12-24 at 01 11 31

If we're going towards minutes and hours, the timer text will be formatted nicely:

CleanShot 2024-12-24 at 01 12 40@2x

GitHub Issue Link (if applicable)

Closes #6805

Testing Plan

Added unit tests for JS and Python and one simple e2e test. I tried to make it not flaky but since that checks what's displayed after one second, we need to see in practice whether it's flaky and potentially adapt.


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@jrieke jrieke changed the title Show elapsed time on st.spinner [WIP] Show elapsed time on st.spinner Dec 23, 2024
@jrieke jrieke added security-assessment-completed Security assessment has been completed for PR impact:users PR changes affect end users change:feature PR contains new feature or enhancement implementation labels Dec 23, 2024
@jrieke jrieke changed the title [WIP] Show elapsed time on st.spinner Show elapsed time on st.spinner Dec 24, 2024
@jrieke jrieke marked this pull request as ready for review December 24, 2024 02:11
@jrieke jrieke requested a review from a team as a code owner December 24, 2024 02:11
@sfc-gh-dmatthews
Copy link
Collaborator

❤️ Just going from the screenshot, if we go into minutes, I think we should reduce the precision of seconds. (So, if we go past a minute, it would be "1 minute, 13 seconds" instead of "1 minute, 13.1 seconds" to avoid visual noise. Or maybe switch to a timer format after a minute, or ten minutes? (00:11:13 with seconds ticking up is clear.)

@jrieke
Copy link
Collaborator Author

jrieke commented Dec 26, 2024

if we go into minutes, I think we should reduce the precision of seconds.

Yeah I tried that but it looks so boring if it only updates once a second :D Looks like nothing is happening. I also don't want to use another style because it looks a bit annoying if the format suddenly switches while it's running.

@jrieke
Copy link
Collaborator Author

jrieke commented Jan 5, 2025

@lukasmasuch I think this is ready for a 2nd look and approval. There's one small open question around click_button, see the comment above.

Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

A couple of small things, but otherwise looks good 👍

@jrieke jrieke enabled auto-merge (squash) January 9, 2025 00:46
@jrieke jrieke merged commit 67b226d into develop Jan 9, 2025
33 checks passed
@jrieke jrieke deleted the feature/elapsed-time-spinner branch January 9, 2025 00:58
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
## Describe your changes

Adds a parameter `show_time` to `st.spinner`. If set to True, the
spinner shows the elapsed time in a small gray font next to the spinner
text. Defaults to False (i.e. same behavior as today).

![CleanShot 2024-12-24 at 01 11
31](https://github.com/user-attachments/assets/e947ccaf-f5e3-413c-ba4a-50e9aa7547f6)

If we're going towards minutes and hours, the timer text will be
formatted nicely:

![CleanShot 2024-12-24 at 01 12
40@2x](https://github.com/user-attachments/assets/bdca9793-d054-41b0-bab7-684523150b3e)

## GitHub Issue Link (if applicable)

Closes streamlit#6805

## Testing Plan

Added unit tests for JS and Python and one simple e2e test. I tried to
make it not flaky but since that checks what's displayed after one
second, we need to see in practice whether it's flaky and potentially
adapt.

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.

---------

Co-authored-by: Johannes Rieke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show elapsed time on st.spinner

6 participants