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 keyboard hint to button (streamlit-extras) #7

Closed
github-actions bot opened this issue Apr 27, 2024 · 10 comments · Fixed by #13
Closed

add keyboard hint to button (streamlit-extras) #7

github-actions bot opened this issue Apr 27, 2024 · 10 comments · Fixed by #13
Labels
good first issue Good for newcomers todo

Comments

@github-actions
Copy link

https://arnaudmiribel\.github\.io/streamlit\-extras/extras/keyboard\_text/

# TODO add keyboard hint to button (streamlit-extras)

import streamlit as st


# TODO add keyboard hint to button (streamlit-extras)
# https://arnaudmiribel.github.io/streamlit-extras/extras/keyboard_text/

def add_keyboard_shortcuts(key_combinations: dict[str, str]):
@github-actions github-actions bot added the todo label Apr 27, 2024
@quantum-ernest
Copy link
Contributor

Add a little explanation.

@adriangalilea
Copy link
Owner

adriangalilea commented Apr 28, 2024

Ah, yeah, I did, but the action closed the issue when I changed the wording, here it was. Let me past it here for reference:

https://arnaudmiribel.github.io/streamlit-extras/extras/keyboard_text/

It'd be great if button showed this kind of hint inside, not sure how feasible is it, but it would greatly improve UX, should probably be optional.

streamlit_shortcuts.button("delete", on_click=delete_callback, shortcut="Ctrl+Shift+X", hint=True)

@adriangalilea adriangalilea added the good first issue Good for newcomers label Apr 28, 2024
@adriangalilea
Copy link
Owner

adriangalilea commented Apr 28, 2024

image

A bit like this, but inside the button that get's the keybinding. So discoverability is built-in and there's no need to create an info pane explaining shortcuts.

@quantum-ernest
Copy link
Contributor

So the shortcut key binding should show on the button if hint is set to true right?

@adriangalilea
Copy link
Owner

So the shortcut key binding should show on the button if hint is set to true right?

Yes

quantum-ernest pushed a commit to quantum-ernest/streamlit-shortcuts that referenced this issue Apr 29, 2024
@quantum-ernest
Copy link
Contributor

The st.button() doesn't evaluate html, when you pass the key() as the label.
I can put it on the side using st.columns() if that's ok/

@adriangalilea
Copy link
Owner

Hey @quantum-ernest, that could def work, maybe under would be better instead on the side, care to share a screenshot?

@quantum-ernest
Copy link
Contributor

Screenshot from 2024-04-29 17-06-54

@adriangalilea
Copy link
Owner

adriangalilea commented Apr 29, 2024

Nice! Looks a bit rough since it's non responsive(white on dark theme) and the lack of alignment with the button. But could work as a bare implementation, well done!

Perhaps scrapping streamlit extras and adding some styled text inside the button would work better. (not sure if possible, just thinking out loud, can't dedicate time atm sadly)

Feel free to PR if you think it's good ;)

Thank you so much @quantum-ernest

Copy link
Author

github-actions bot commented Aug 2, 2024

Closed in 04cf302

@github-actions github-actions bot closed this as completed Aug 2, 2024
@adriangalilea adriangalilea reopened this Aug 2, 2024
quantum-ernest pushed a commit to quantum-ernest/streamlit-shortcuts that referenced this issue Aug 16, 2024
quantum-ernest pushed a commit to quantum-ernest/streamlit-shortcuts that referenced this issue Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers todo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants