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

I want to be able to disable a widget from my app script #862

Closed
tconkling opened this issue Dec 18, 2019 · 42 comments · Fixed by #4154
Closed

I want to be able to disable a widget from my app script #862

tconkling opened this issue Dec 18, 2019 · 42 comments · Fixed by #4154
Assignees
Labels
type:enhancement Requests for feature enhancements or new features

Comments

@tconkling
Copy link
Contributor

Sometimes I want to show the user that a piece of UI exists, but is currently disabled until some condition is met. For example:

  • a "Submit" button that gets enabled when some text inputs have reasonable form data
  • A slider that's only enabled when a checkbox is clicked

It would be useful if each widget function took an optional "enabled" flag.

@tconkling tconkling added type:enhancement Requests for feature enhancements or new features spec needed labels Dec 18, 2019
@isConic
Copy link

isConic commented Dec 18, 2019

I can see this appear two ways syntactically.

foo = st.button("test", enabled = False)  

or

foo = st.button("test")
foo.enabled = False

@hcoohb
Copy link

hcoohb commented Dec 19, 2019

That would be a most definitely wanted feature by many of us I think (myself included ;-) )
I was about to start an issue but you beat me to it...

@benlindsay
Copy link

Very much interested in this feature too

@gmohandass
Copy link

+1

@ssameerr
Copy link

ssameerr commented Sep 1, 2020

Same here

@dalmia
Copy link

dalmia commented Nov 2, 2020

+1

1 similar comment
@orenbookarang
Copy link

+1

@aldencabajar
Copy link

Is there anyone working on this yet?

@Cubba2412
Copy link

I would definitely also be interested in this. The ability to disable a button as to lock a users initial choice.

@H4dr1en
Copy link

H4dr1en commented Mar 3, 2021

Also interested!

@Cubba2412
Copy link

Also very interested!

@jrieke
Copy link
Collaborator

jrieke commented Mar 30, 2021

+1. This is also very useful if you want to show some default options that can't be changed (e.g. you have 3 checkboxes and the first one should always be checked due to some other settings).

@muhammadAgfian96
Copy link

+1

1 similar comment
@JohannCR
Copy link

JohannCR commented Jul 6, 2021

+1

@sohilbhatia
Copy link

interested

@El-Ku
Copy link

El-Ku commented Jul 30, 2021

+1

12 similar comments
@beep-92
Copy link

beep-92 commented Aug 11, 2021

+1

@lucasgsfelix
Copy link

+1

@modbender
Copy link

+1

@Victor-Botelho
Copy link

+1

@KlausGPaul
Copy link

+1

@ElizaStaruk
Copy link

+1

@Tomiinek
Copy link

+1

@iamashwin99
Copy link

+1

@fergusonrae
Copy link

+1

@vvvlad
Copy link

vvvlad commented Oct 6, 2021

+1

@ghost
Copy link

ghost commented Oct 7, 2021

+1

@MarcoTranxpert
Copy link

+1

@abdullahtrn
Copy link

+1

1 similar comment
@madshaven
Copy link

+1

@PablocFonseca
Copy link

+1 this would make more intutive UI possible

@aarav2you
Copy link

aarav2you commented Nov 3, 2021

+1 Wow this has been opened since 18th dec, it has gone unnoticed

@Spiruel
Copy link

Spiruel commented Nov 3, 2021

Also interested

@ElizaStaruk
Copy link

Just found this through Google again, so still +1 (+2?) 😆

@PablocFonseca
Copy link

  • 1 here too. I'm using st.Markdown and custom Html code to simulate this feature... a mess... I'd love to have it implemented maybe with some custom css as well

@Muzammiljethwa
Copy link

I have done this by going through this approch:

st.write("Select atmost 2 locations")
location = st.multiselect("Where do you live?", ("New York", "San Francisco", "Chicago", "Seattle"))
button = st.button("Print Locations",disabled=False)

if button :
   if len(location) <= 2:
       st.write(location)
   else:
       st.warning("You have to select only 2 locations")

hope it will help !!!!!

@Yuwei9527
Copy link

+1

2 similar comments
@danb27
Copy link

danb27 commented Aug 10, 2022

+1

@colin99d
Copy link

colin99d commented Sep 5, 2022

+1

@Khalilsqu
Copy link

Khalilsqu commented Oct 23, 2022

how does this work?

I can't disable a widget after creation.

I want to disable or enable for example a checkbox based on another condition in my app!

@jrieke
Copy link
Collaborator

jrieke commented Oct 23, 2022

This was released already a while ago. Just pass a boolean value to the disabled parameter of a widget:

disabled = st.checkbox("Disable slider")
st.slider("My slider", disabled=disabled)

@SubaruSpirit
Copy link

This was released already a while ago. Just pass a boolean value to the disabled parameter of a widget:

disabled = st.checkbox("Disable slider")
st.slider("My slider", disabled=disabled)

This works beautifully! Can't believe such an easy solution is burried here, a lot of solution on SO are way too complicated for a simple thing to do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.