magicgui
magicgui copied to clipboard
Slider and FloatSlider - show more decimal places & up-down buttons for readouts
I'm really enjoying the new slider + readout combo but have a couple more requests. I would love to have more options when using the direct widget API for Slider and FloatSlider -- specifically for the readouts that are in them.
- FloatSlider only: the ability to show more than 2 decimal places in the readout
- Number of decimal places could be auto-determined where, if the increment size is 0.001 for example, then readout shows 3 decimal points. It seems it's currently capped at 2 decimal points regardless of the increment value?
- Alternatively the number of decimal places could be set explicitly with a param called
precisionor something
- Slider and FloatSlider: The ability to show buttons (up down arrrows) next to the readout number if we want (seems like they are hidden by default currently)
Thanks!!
I agree on both accounts! I think we have auto-decimal detection based on stepsize with the regular spinbox, so could do so here as well.
In the meantime, if you want to use the private API as a short-term patch, you can access the Qt widget as follows:
fs = FloatSlider()
# the "compound" backend widget is at ._widget
# and the spinbox is at ._widget._readout_widget
spinbox = fs._widget._readout_widget
# change number of decimals
spinbox.setDecimals(3)
# change symbols:
spinbox.setButtonSymbols(spinbox.UpDownArrows)
spinbox.setStyleSheet("") # undo default styles
Thank you!