Forum Archive

Does ui.Slider have an enabled state attribute?

shinyformica

Looking at the documentation for the various widgets, I see "enabled" properties for buttons and other controls, but not for sliders? Does that mean sliders can't be disabled?

A more general question: can an entire view hierarchy be "disabled" in some way? In the sense of somehow setting the enabled state of a View to False, which would disable the entire view hierarchy under it?

cvp

@shinyformica ui.Slider has an attribute "touch_enabled"

cvp

@shinyformica you can define an ui.View with the same frame as the main view, as a sub_view of this main view, with a transparent background and
sent it to the back if you want to enable other inner objects
or bring it to the front if you want to disable other inner objects

w = ui.View()
w.frame = main_view.frame
w.background_color = (1,1,1,0)
main_view.add_subview(w)
#w.bring_to_front() # disable other
w.send_to_back() # enable other 
mikael

@shinyformica, it has not been exposed in the Python API, but still pretty easy to use:

s = Slider()
s.objc_instance.setEnabled_(False)
shinyformica

@mikael thanks! That's what I was looking for...really odd that something which probably should be a base View property isn't exposed for all View subclasses. Perhaps I should request it? Not sure how to do that.

mikael

@shinyformica, Google for ”Pythonista-Issues”.