magicgui icon indicating copy to clipboard operation
magicgui copied to clipboard

Slider and FloatSlider - show more decimal places & up-down buttons for readouts

Open schoinh opened this issue 4 years ago • 2 comments

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.

  1. 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 precision or something
  2. 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!!

schoinh avatar Apr 27 '21 23:04 schoinh

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

tlambert03 avatar Apr 27 '21 23:04 tlambert03

Thank you!

schoinh avatar Apr 28 '21 00:04 schoinh