Tkinter error __str__ returned non-string (type Frame)

Question:
Once again, solving(hopefully) one problem begat another. I was in the process of resolving an issue with tkinter.PhotoImage, and upon finding a solution(I think) I ran into this error:

TypeError: str returned non-string (type Frame)

Anyone able to diagnose my issue? can’t figure out where this is coming from even(though supposedly in the middle line of my code snippet(according to the error)).

Repl link:
https://replit.com/@ThomasWarenski/SDEV-140-Final-Project#main.py

Code Snippet:

sceneryImage = tk.PhotoImage(playFrame, file = themeDictionary["Test Theme"][0][0])
scenery = tk.Label(playFrame, image = sceneryImage, text = themeDictionary["Test Theme"][0][1], compound = "bottom")
scenery.grid(column = 3, row = 0, stick = "NSEW")

Thank you

Try setting that to sceneryImage = tk.PhotoImage(file = themeDictionary["Test Theme"][0][0])
The first argument is name, so you were trying to set the name to a frame object.
Docs: TkDocs - PhotoImage

1 Like

I already tried without playFrame, it gave me an error in my program with multiple windows, but not in one with only one, so I assumed that was the issue. Let me try changing playFrame to master = playFrame

2 Likes

That might work, if you get any type errors in the future, check the docs and make sure you are putting the right arg in the right place.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.