Jun-16-2021, 12:49 AM
(This post was last modified: Jun-16-2021, 01:55 AM by rwahdan.
Edit Reason: i found one mistake
)
Hi,
I am trying to show an image in a button. the approch is to read the path from a file and that path is in the last line. I am able to read the path from the file but i can't add it to the button. It gives error it can't find the path.
There was a new line break "\n" that I needed to take out. now I can see the space of the photo in the form but no image and yes i did pack()
I am trying to show an image in a button. the approch is to read the path from a file and that path is in the last line. I am able to read the path from the file but i can't add it to the button. It gives error it can't find the path.
# find the last line for the photo with open(username1, 'rb') as f: f.seek(-2, os.SEEK_END) while f.read(1) != b'\n': f.seek(-2, os.SEEK_CUR) last_line = f.readline().decode() photo = PhotoImage(file=last_line) photoimage = photo.subsample(1, 2) Label(session_start, text="Welcome " + username1).pack() Label(session_start, text="").pack() Label(session_start, text="").pack() Button(session_start, image=photoimage).pack(pady="150")Note:
There was a new line break "\n" that I needed to take out. now I can see the space of the photo in the form but no image and yes i did pack()