On Mon, 23 Nov 2009, Ivica Ico Bukvic wrote:
> You need to cycle through cords of a visible canvas b/c even though a
> canvas is open they may not be placed in a visible part of that canvas.
The bug is happening because a given pd canvas doesn't have a
corresponding tk canvas. This happens when the canvas is said to be
«closed». When a window is minimised, it's just useless to send the
«raise» command, but it doesn't cause an error message. In the case of
GOP, the canvas' contents is visible, but the associated tk canvas does
not an id matching the pointer of the pd canvas.
> Of course lingering question is what is in the end faster in tcl/tk
> land: cycling through objects and refreshing them (which would be the
> cleaner thing to do)
Why would it be the cleaner thing to do? It's not like simpler, smaller
commands are full of doorknob viruses. Tk has the commands on groups of
items so that it acts on groups of items, I don't know why we're supposed
to avoid that feature and call it cleaner.
> or simply refreshing entire canvas and trusting that tcl/tk is
> implemented so efficiently that its execution offsets time required for
> redundant redraws.
What about trusting that tcl/tk is implemented so efficiently that when
you are picking each element in the manner that they are sorted already,
and raising each of them separately to the top (thus changing the order of
N cords N times in a row), tcl/tk would figure out that it has nothing to
redraw?... I wouldn't even be sure that *any* toolkit would figure out
that situation. Whereas for raise all_cords, tcl/tk guarantees it
preserves the relative order of members of all_cords, so it is possible
and likely that it will figure out that nothing has changed (but not
certain).
tcl/tk is notoriously inefficient but it's also very easy to make wrong
guesses as to what will be done redundantly and what won't. If you are
interested in accelerating your code Tk-wise, I could show you what I
found about Tk's redrawing when I tried to modify tk/generic/tkCanvas.c.
_ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801