[Tkinter-discuss] Moving object on page leaves afterimage on Python 3 but not on 2

Reinis Danne rei4dan at gmail.com
Fri Feb 5 09:56:58 EST 2016

On Fri, Feb 05, 2016 at 10:29:42AM +0100, Michael Lange wrote:
> Hi,
> On Thu, 4 Feb 2016 14:58:11 +0200
> Reinis Danne <rei4dan at gmail.com> wrote:
> > To test:
> > $ git clone https://gitlab.com/bkchem/bkchem.git
> > $ cd bkchem
> > $ git submodule init
> > $ git submodule update
> > $ python3 bkchem/bkchem.py
> this looks like quite a complex piece of code. Is it possible for you to
> provide a simpler example that exhibits the problem?

Ok. With the help of traceback module and some print statements I
have isolated where the issue is and provide a small example code
in attachment.

> Some additional information might also be helpful to track down the
> problem:
> * which platform are you running (Windows / X / Mac)?

I'm running on Gentoo ~amd64 but have tested also on Linux Mint.

> * do your Python 2 / 3 versions share the same Tk version?
> * which Tk version(s) do you use?

Yes, I have only tk-5.6.4 installed.

> Without having reviewed the code I can only try a quick shot in the dark:
> maybe Python 2 and 3 do *not* use the same Tk and these Tk versions
> behave slightly differently. Maybe inserting additional calls to
> update_idletasks() here and there might help. At a quick glance the
> redraw() method in your graphics module might be a candidate for this.
> Have you already tried that?
> Best regards
> Michael

Thanks for the help!

The main drawing routines for BKChem are located in paper.py, but
the issue seems to be with bond.py::bond.delete(). It uses map()
to call Canvas.delete() for every item in a list. It works in
Python 2, but in Python 3 it doesn't delete the item(s).

Replacing this:
map(self.paper.delete, items)

with this:
for i in items:

fixes the problem.

I don't understand why the difference. That code is equivalent in
both cases as far as I know. Is there a bug or I'm using map()

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 599 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20160205/b9d9d489/attachment.py>

More information about the Tkinter-discuss mailing list