Skip to content

Commit

Permalink
Add explicit float -> int conversion for Qt (#1041)
Browse files Browse the repository at this point in the history
This was happening implicitly until https://bugs.python.org/issue36048 This makes it explicit, which means things should work with PyQt5 on Python 3.10.

Fixes #1037
  • Loading branch information
corranwebster committed Apr 18, 2023
1 parent 1565976 commit 6135fea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test-with-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
toolkit: 'wx'
- os: 'macos-latest'
toolkit: 'wx'
# PyQt5 API doesn't automatically cast float -> int, see #1037
- toolkit: 'pyqt5'
python-version: '3.10'
# Kiva tests hanging on windows, see #1038
- os: 'windows-latest'
toolkit: 'pyqt5'
Expand Down
2 changes: 1 addition & 1 deletion enable/qt4/base_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def __init__(self, parent, wid=-1, pos=None, size=None, **traits):
self.control.move(*pos)

if size is not None:
self.control.resize(*size)
self.control.resize(*(int(x) for x in size))

def _get_base_pixel_scale(self):
if self.control is None:
Expand Down
10 changes: 5 additions & 5 deletions enable/qt4/scrollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ def _update_control(self, enable_range, value):
# invert values for vertical ranges because of coordinate system issues
value = self._correct_value(value, minimum, max_value)

self._control.setMinimum(minimum)
self._control.setMaximum(max_value)
self._control.setValue(value)
self._control.setPageStep(page_size)
self._control.setSingleStep(line_size)
self._control.setMinimum(int(minimum))
self._control.setMaximum(int(max_value))
self._control.setValue(int(value))
self._control.setPageStep(int(page_size))
self._control.setSingleStep(int(line_size))

def _correct_value(self, value, min_value, max_value):
""" Correct vertical position values for Qt and Enable conventions
Expand Down

0 comments on commit 6135fea

Please sign in to comment.