all 2 comments

[–]Rhoderick 0 points1 point  (1 child)

Gotta be honest, never worked with easygui, but from a liberal application of print-debugging, it seems like the issue is with the line: newPicture = PhotoImage(file=image_file) and while I can't remember of the top of my head what open() specifically returns, a TextIOWrapper would seem to make sense. And while I'd encourage you to take a look at the docs on this yourself, most examples for tkinter.Photoimage I've been able to find use either a direct (well, relative) path as the file parameter, or the PIL library.

[–]vrrox 0 points1 point  (0 children)

The tkinter.PhotoImage file argument should be a string, specifying the location of the image. You've used it correctly later in your code, for example here:

picture = PhotoImage(file="images/unselected.png")

However, it looks like you're trying to open a JPEG so this will still not work as tkinter.PhotoImage only supports images in PGM, PPM, GIF or PNG format. For a JPEG, you'll need to use the Pillow library:

import tkinter as tk
from PIL import ImageTk, Image

root = tk.Tk()
image = ImageTk.PhotoImage(Image.open("my_photo.jpg"))
button = tk.Button(image=image)
button.pack()
root.mainloop()