adriangalilea / streamlit-shortcuts

Streamlit keyboard shortcuts for your buttons.
https://shortcuts.streamlit.app/
MIT License
28 stars 5 forks source link

Readme example does not match code functionality #9

Closed taylor-ennen closed 7 months ago

taylor-ennen commented 7 months ago

In the section of readme containing the new example usage, 'shortcut' is passed a string however the code calls for a dictionary, I would provide the fix myself but I'm not sure the direction your headed, keeping the dictionary or implement strings for the single button example that's been added.

taylor-ennen commented 7 months ago

Otherwise great project! Saved me a bit of time running into this and happy to keep an eye and help out where needed.

taylor-ennen commented 7 months ago

Also it looks like the usage of "ctrl" in the examples does not match the usage itself of "control".

adriangalilea commented 7 months ago

Hey @taylor-ennen glad you find it helpful,

I've got a problem, I have literally 0 time and I haven't used streamlit in a while nor I have my python dev env set up,

import streamlit as st
import streamlit_shortcuts

def delete_callback():
    st.write("DELETED!")

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

This is the intended usage pattern, the dictionary is only meant when you don't use the streamlit_shortcuts.button but the old pattern, just a wrapper essentially, I haven't tested but it looked good to me, the code is fairly simple, so if you think this doesn't work as it should, feel free to fix it and I will merge :)

Also it looks like the usage of "ctrl" in the examples does not match the usage itself of "control".

Makes sense now that I look at it, then again I'm not able to test if it works or it doesn't :)

taylor-ennen commented 7 months ago

Hey @taylor-ennen glad you find it helpful,

I've got a problem, I have literally 0 time and I haven't used streamlit in a while nor I have my python dev env set up,

import streamlit as st
import streamlit_shortcuts

def delete_callback():
    st.write("DELETED!")

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

This is the intended usage pattern, the dictionary is only meant when you don't use the streamlit_shortcuts.button but the old pattern, just a wrapper essentially, I haven't tested but it looked good to me, the code is fairly simple, so if you think this doesn't work as it should, feel free to fix it and I will merge :)

Also it looks like the usage of "ctrl" in the examples does not match the usage itself of "control".

Makes sense now that I look at it, then again I'm not able to test if it works or it doesn't :)

I've gone ahead and tested the changes and submitted a pr, it's pretty straightforward but this can be closed with the inclusion of that PR.

adriangalilea commented 7 months ago

🎉 @taylor-ennen new version released and available on pip.