question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'FloatSlider' widget crash when setting up a minimum value

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
tlambert03commented, Nov 18, 2022

Fixed in 0.6.1

1reaction
brisvagcommented, Nov 18, 2022

Just encountered the same (probably) issue, ~but with slightly different error~ [EDIT: looks like it’s exactly the same, my bad 😛]:

from magicgui import magicgui

@magicgui(auto_call=True, f=dict(widget_type='FloatSlider', min=0.5))
def a(f: float = 1):
    print(f)

a.show()

The slider works fine, and the printed values are in the correct range. However, the label is the problem:

image

And if I try to edit it, this error appears:

File ~/git/magicgui/src/magicgui/backends/_qtpy/widgets.py:650, in Slider._on_readout_change(self)
    649 def _on_readout_change(self):
--> 650     self._qwidget.setValue(self._pre_set_hook(self._readout_widget.value()))                      

OverflowError: argument 1 overflowed: value must be in the range -2147483648 to 2147483647
Read more comments on GitHub >

github_iconTop Results From Across the Web

FloatSlider sometimes approximates the max and does ...
Running the following code I get a widget in the range [0.2, 0.5] instead of [0.2,0.6]: w = widgets.FloatSlider(value = 0.5, min =...
Read more >
Source code for pywwt.jupyter
DOMWidget, BaseWWTWidget): """ An AAS WorldWide Telescope Jupyter widget. ... FloatSlider( value=self.foreground_opacity, min=0, max=1, readout=False ) ...
Read more >
Cursor of FloatSlide widget doesn't move
First, thankyou for the complete runnable example (with imports!) I think this might be to do with the minimum value or step size...
Read more >
Python Jupyter Widgets - YouTube
Widget in Jupyter using ipywidgets. http://nbviewer.jupyter.org/url/ignite.byu.edu/che263/lectureNotes/ widgets.ipynb.
Read more >
FloatSlider — Panel v0.14.2
The FloatSlider widget allows selecting selecting a numeric floating-point value within a set bounds using a slider. For more information about listening to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found