python at mrabarnett.plus.com
Tue Jan 24 08:08:34 EST 2017
On 2017-01-24 07:09, rryan.asu at gmail.com wrote:
> I'm trying to build a tkinter GUI with python 3.5, and would like to interactively adjust the color palette for an image by moving the mouse in the canvas using PIL. In pseudo-code, I have something like
> palette=color_map(x,y) # x,y are scalars indicating the position of the mouse in the Canvas
> This works just fine, but is very slow. The photo.paste(image) step takes about 0.15 s (using an image that is 4k x 4k). I read the manual on effbot, and they caution that the paste method would be slow if the image is display --- and I'm guessing that's what I'm doing. So my question is, what alternatives do I have to speed that step up.
> Thank you for any thoughts you might have...
How often are you pasting?
Are you pasting whenever the mouse moves, even a little?
If that's the case, try using the .after method to paste only
occasionally, and then only if the mouse has moved since the last time.
More information about the Python-list