[PyQt] charactermap demo widget under python3

Colin McPhail colin.mcphail at talktalk.net
Tue Sep 21 16:55:12 BST 2010


Hi,

The charactermap widget in the PyQt demo does not work correctly under python3: it processes mouse move and click event coordinates incorrectly with the result that the tooltip and the line edit field select the wrong character to display.

The cause of the problem is that the mouseMoveEvent() and mousePressEvent() methods use normal division (/) rather than floor division (//) to discover which character cell the mouse is pointing at.  In python2 normal division actually performs floor division if both operands are integer.  In python3 normal division produces a floating point result for that case.

The attached diff replaces the use of normal division with floor division in those two methods.  The resultant source is suitable for use with both python2 and python3.

-- Colin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: charactermap.diff
Type: application/octet-stream
Size: 1282 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100921/20dfa0df/attachment.obj>


More information about the PyQt mailing list