PhotoImage.paste

rryan.asu at gmail.com rryan.asu at gmail.com
Tue Jan 24 10:15:22 EST 2017


Hi MRAB

Yes, I am pasting every time the mouse moves (or every time the tk event handler gets called).  I thought about the after method, and I guess i can try to implement that.  It seems like that would help in the "jerkiness" of the GUI's response, but it leaves me kinda disappointed.  I obviously do not understand the inner workings of PIL or tk, but it seems kinda broken that it must take 0.2 sec to adjust a palette.  This GUI is a rewrite of a code I had in another language, and this palette modifying was much faster.  

I'll try the after method, hoping it'll at least make the GUI a bit more responsive.  

Thanks again!
Russell


On Tuesday, January 24, 2017 at 8:08:53 AM UTC-5, MRAB wrote:
> On 2017-01-24 07:09, 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
> > image.putpalette(palette)
> > photo.paste(image)
> >
> > 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...
> > -Russell
> >
> 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 mailing list