New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThumbnailCtrl #746

Closed
FelipeCalliari opened this Issue Feb 12, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@FelipeCalliari
Contributor

FelipeCalliari commented Feb 12, 2018

Operating system: Windows 10 x64 Build 1709
wxPython version: 4.0.1
Stock or custom build: Stock build
Python version: 3.6.4
Stock or custom build: Stock build

Description of the problem: While running the wxPython-demo-4.0.1.tar.gz, I tried the ThumbnailCtrl object and received the following error:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\wx\lib\agw\thumbnailctrl.py", line 2242, in OnMouseDown
    self.ScrollToSelected()
  File "C:\ProgramData\Anaconda3\lib\site-packages\wx\lib\agw\thumbnailctrl.py", line 1950, in ScrollToSelected
    y1 = row*(self._tHeight + self._tBorder) + self.GetCaptionHeight(0, row)
  File "C:\ProgramData\Anaconda3\lib\site-packages\wx\lib\agw\thumbnailctrl.py", line 1778, in GetCaptionHeight
    for ii in range(begRow, begRow + count):
TypeError: 'float' object cannot be interpreted as an integer

In Python 2, when we divide 2 integers the result is a integer, ie, int/int = int, but in Python 3 the result is a float, ie, int/int = float.

So, I was able to make this module (wx/lib/agw/thumbnailctrl.py) work by modifying the following lines:

1785 =    def GetItemIndex(self, x, y):
1793 -        col = (x - self._tBorder)/(self._tWidth + self._tBorder)
1793 +        col = (x - self._tBorder)//(self._tWidth + self._tBorder)

1938 =    def ScrollToSelected(self):
1945 -        row = self.GetSelection()/self._cols
1945 +        row = self.GetSelection()//self._cols
@Metallicow

This comment has been minimized.

Contributor

Metallicow commented Feb 12, 2018

Yeah there are bound to be some floor division lines that might pop up still when running on Py3.
You can go ahead and make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment