@@ -48,18 +48,19 @@ def _get_image_from_kw(kw: dict[str, Any]) -> ImageFile.ImageFile | None:
4848
4949
5050def _pyimagingtkcall (
51- command : str , photo : PhotoImage | tkinter .PhotoImage , id : int
51+ command : str , photo : PhotoImage | tkinter .PhotoImage , ptr : object
5252) -> None :
5353 tk = photo .tk
54+ ptr_str = repr (ptr ).strip ("<>" )
5455 try :
55- tk .call (command , photo , id )
56+ tk .call (command , photo , ptr_str )
5657 except tkinter .TclError :
5758 # activate Tkinter hook
5859 # may raise an error if it cannot attach to Tkinter
5960 from . import _imagingtk
6061
6162 _imagingtk .tkinit (tk .interpaddr ())
62- tk .call (command , photo , id )
63+ tk .call (command , photo , ptr_str )
6364
6465
6566# --------------------------------------------------------------------
@@ -181,7 +182,7 @@ def paste(self, im: Image.Image) -> None:
181182 block = image .new_block (self .__mode , im .size )
182183 image .convert2 (block , image ) # convert directly between buffers
183184
184- _pyimagingtkcall ("PyImagingPhoto" , self .__photo , block .id )
185+ _pyimagingtkcall ("PyImagingPhoto" , self .__photo , block .ptr )
185186
186187
187188# --------------------------------------------------------------------
@@ -255,9 +256,8 @@ def __str__(self) -> str:
255256def getimage (photo : PhotoImage ) -> Image .Image :
256257 """Copies the contents of a PhotoImage to a PIL image memory."""
257258 im = Image .new ("RGBA" , (photo .width (), photo .height ()))
258- block = im .im
259259
260- _pyimagingtkcall ("PyImagingPhotoGet" , photo , block . id )
260+ _pyimagingtkcall ("PyImagingPhotoGet" , photo , im . im . ptr )
261261
262262 return im
263263
0 commit comments