---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[12], line 2
1 get_ipython().run_line_magic('pdb', 'off')
----> 2 myTS=turtle.TurtleScreen(myCanvas)
File ~/miniforge3/envs/jupyterlab/lib/python3.14/site-packages/ipyturtle3/ipyturtle3.py:250, in TurtleScreen.__init__(self, cv, mode, colormode, delay)
229 self.canvheight = h
230 self.xscale = self.yscale = 1.0
232 self._shapes = {
233 "arrow" : Shape("polygon", ((-10,0), (10,0), (0,10))),
234 "turtle" : Shape("polygon", ((0,16), (-2,14), (-1,10), (-4,7),
235 (-7,9), (-9,8), (-6,5), (-7,1), (-5,-3), (-8,-6),
236 (-6,-8), (-4,-5), (0,-7), (4,-5), (6,-8), (8,-6),
237 (5,-3), (7,1), (6,5), (9,8), (7,9), (4,7), (1,10),
238 (2,14))),
239 "circle" : Shape("polygon", ((10,0), (9.51,3.09), (8.09,5.88),
240 (5.88,8.09), (3.09,9.51), (0,10), (-3.09,9.51),
241 (-5.88,8.09), (-8.09,5.88), (-9.51,3.09), (-10,0),
242 (-9.51,-3.09), (-8.09,-5.88), (-5.88,-8.09),
243 (-3.09,-9.51), (-0.00,-10.00), (3.09,-9.51),
244 (5.88,-8.09), (8.09,-5.88), (9.51,-3.09))),
245 "square" : Shape("polygon", ((10,-10), (10,10), (-10,10),
246 (-10,-10))),
247 "triangle" : Shape("polygon", ((10,-5.77), (0,11.55),
248 (-10,-5.77))),
249 "classic": Shape("polygon", ((0,0),(-5,-9),(0,-7),(5,-9))),
--> 250 "blank" : Shape("image", self._blankimage())
251 }
253 self._bgpics = {"nopic" : ""}
255 self._mode = mode
File ~/miniforge3/envs/jupyterlab/lib/python3.14/turtle.py:877, in Shape.__init__(self, type_, data)
875 data = tuple(data)
876 elif type_ == "image":
--> 877 assert(isinstance(data, TK.PhotoImage))
878 elif type_ == "compound":
879 data = []
AssertionError:
It looks like _blankimage() returns a numpy array, while TK expects a PhotoImage. I was able to patch it and run the README example with this code:
That's not quite enough for a PR (creating a new Tk instance is probably unnecessary) but does make the package work.
I get the following stack trace calling
turtle.TurleScreen(myCanvas):It looks like _blankimage() returns a numpy array, while TK expects a PhotoImage. I was able to patch it and run the README example with this code:
That's not quite enough for a PR (creating a new Tk instance is probably unnecessary) but does make the package work.
Versions