Open
Description
With Python 3.10, using a traitsui BoundsEditor
for a Range
fails:
from traits.api import *
from traitsui.api import *
from traitsui.qt4.extra.bounds_editor import BoundsEditor
class Test(HasTraits):
val = Range(0.3, 10.5)
_xmin = Float(5.0)
_xmax = Float(10.0)
view = View(
UItem(
'val',
editor=BoundsEditor(
low_name='_xmin',
high_name='_xmax',
format='%.2f')
)
)
Test().configure_traits()
Traceback (most recent call last):
File ".../lib/python3.10/site-packages/traitsui/qt4/extra/range_slider.py", line 81, in paintEvent
opt.sliderPosition = value
TypeError: 'float' object cannot be interpreted as an integer
The same code works in Python 3.9.
In range_slider.py, the slider position appears to be set like so:
opt = QtGui.QStyleOptionSlider()
opt.sliderPosition = value
This appears to be the reason for the failure because value
is a float and implicit conversion fails in Python 3.10.
Python 3.9
Python 3.9.10 (main, Mar 2 2022, 14:03:08)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyface.qt import QtGui
>>> QtGui.QStyleOptionSlider().sliderValue = 5
>>> QtGui.QStyleOptionSlider().sliderValue = 5.5
<stdin>:1: DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
Python 3.10
Python 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyface.qt import QtGui
>>> QtGui.QStyleOptionSlider().sliderValue = 5
>>> QtGui.QStyleOptionSlider().sliderValue = 5.5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'float' object cannot be interpreted as an integer
Metadata
Metadata
Assignees
Labels
No labels