I'm writing code to save and combine images made with the turtle module, however when I go to save the image an error keeps appearing; I think in relation to the Canvasvg module itself? Could it have been installed incorrectly, and if so how can I do it correctly?
Error code:
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Python Program\lib\idlelib\run.py", line 137, in main
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
File "D:\Python Program\lib\queue.py", line 172, in get
raise Empty
queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python Program\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "D:\Python Program\lib\turtle.py', line 686, in eventfun
fun()
File "C:\Users\garla\Desktop\tst.py", line 75, in saveImg
canvasvg.saveall(ts , namesav)
File "D:\Python Program\lib\canvasvg\canvasvg.py', line 337, in saveall
for element in convert(doc, canvas, items, tounicode):
File "D:\Python Program\lib\canvasvg\canvasvg.py", line 84, in convert
tk = canvas.tk
AttributeError: 'str' object has no attribute 'tk'
Here's the code which uses canvasvg :
def saveImg() :
print("Done.")
save = input("Would you like to save this ? Y/N \n")
if save.upper() == "Y" :
Red.hideturtle()
Blue.hideturtle()
name = input("File Name :")
namesav = name + " .jpg"
ts = turtle.getscreen() .getcanvas()
canvasvg.saveall(ts , namesav)
elif save.upper() == "N" :
def runChk() :
runAgain = input("Would you like to run again? Y?N (N will Exit)")
if runAgain.upper() == "Y" :
print("Running")
main()
elif runAgain.upper() == "N" :
print ("Exiting...")
exit()
else :
print("Invalid response.")
runChk()
runChk()
else :
print("Invalid Response.")
saveImg()
All help is appreciated.