Skip to content

'FloatSlider' widget crash when setting up a minimum value #505

@lorenzocerrone

Description

@lorenzocerrone

Describe the bug
In magicgui 0.6.0 setting up a min value different from 0. for the FloatSlider causes two bugs in the widget.

  1. The default value shown is wrong. (100000, for default=1, and min=0.1)
  2. When moving the slider the widget crash
Traceback (most recent call last):
  File ".../python3.10/site-packages/magicgui/backends/_qtpy/widgets.py", line 640, in _on_readout_change
    self._qwidget.setValue(self._pre_set_hook(self._readout_widget.value()))
OverflowError: argument 1 overflowed: value must be in the range -2147483648 to 2147483647
[1]    12542 IOT instruction (core dumped)  python test.py

Some more details:

  • The error does not affect the function call. If I run the widget in the example below, I get the correct value 1.
  • if I set min=0. the widget works normally.
  • Typing a new value next to the slider causes the same Traceback as above.

To Reproduce

from magicgui import magicgui

@magicgui(call_button='Run',
          sigma={'label': 'Sigma',
                 'widget_type': 'FloatSlider',
                 'max': 5.0,
                 'min': 0.1})
def widget_test(sigma: float = 1.0) -> None:
    print(sigma)

widget_test.show(run=True)

Screenshots
Screenshot from 2022-11-15 10-29-43

Environment (please complete the following information):

  • OS: linux, fedora 35
  • backend: Qt: 5.12.9, PyQt5: 5.12.3
  • magicgui version 0.6.0
  • python: 3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions