Questions tagged [tkinter-photoimage]

In tkinter, some widgets can display an image such as Label and Button. These widgets take an image= keyword argument that allows them to display an image.

There's a good description of tkinter Photoimages here on TkDocs.

17 questions
2
votes
0 answers

How to insert in a treeview some imgs saved in a list?

I have the next code: from tkinter import ttk import tkinter as tk from PIL import Image, ImageTk ID = [1,2,3,4,5, 6, 7, 8, 9] Names = ['Tom', 'Rob', 'Tim', 'Jim', 'Kim', 'Steph', 'Davis', 'Katt'] photo = ['1.jpeg', '2.jpeg', '3.jpeg', '4.jpeg',…
1
vote
1 answer

How can you make images fit within widget using PhotoImage (without use of PIL)?

I'm attempting to develop a solution with two buttons (without any libraries outside tkinter), one with a thumbs up image (like) and one with a thumbs down image (dislike), however I can't even seem to get the basics down of getting the images to…
1
vote
1 answer

tkinter - Can't assign window icon to root window if a prompt was created first

Environment: Windows 10, Python 3.9.5 If I try to display a prompt (using tkinter.messagebox functions) before creating the root window, I cannot assign a window icon to the root window. The iconphoto call fails with the error, even though the icon…
toxicantidote
  • 168
  • 2
  • 10
1
vote
0 answers

Displaying image in a button using tkinter in Python is not working as intended

I am trying to implement a window using tkinter which should allow to navigate to another pages on clicking buttons. I want to add images to the button as relevant to the functionality of the navigating page. However, the image is not getting…
1
vote
2 answers

Image background black

So even though I tried to set the background to custom color the picture is automatically set with bg=black. Witch I am guessing is default. Can someone tell me in what moment I have to set the background, and how to do it so the picture doesn't get…
1
vote
1 answer

Is .png the only format acceptable in python's tkinter module?

I tried inserting a picture with format .jpg as a PhotoImage But everytime i try running the program, it gives the following error: couldn't recognize data in image file But this never happens with an .png picture, which makes me wonder if .png is…
1
vote
0 answers

Make PhotoImage transparent with themes

tk.Label(self.info_frame, text = 'Paths:', font = 'bold').grid(column = 0, row = 0) self.info_icon = tk.PhotoImage(file = r'info.png') self.info_button = ttk.Button(self.info_frame, image = self.info_icon, command = lambda:…
yg213
  • 25
  • 4
0
votes
2 answers

tk.PhotoImage is not loading image in another instance of Tk()

I am building an application which have a main menu and some side menus/forms. Those forms are created in separate files as following:- from tkinter import * import tkinter as tk class side_test(): def __init__(self): self.window =…
Hamid Shah
  • 15
  • 5
0
votes
1 answer

Why doesn't my '<>' bind change the PhotoImage being displayed in the Tkinter Window when it is called?

I can display an image to the Label Widget without difficulty, however when I try to change the label widget image by using the '<>' bind to get a different image path string (which is then attached to a new PhotoImage class using the Retrieve_Image…
0
votes
0 answers

PhotoImage not shown when passed into a tk.Label()

So I'm developing a GUI where a label, that will contain an Image, will only be shown after clicking the option onMenuUpToDown. Other functions with the same code and same image format work properly but when it comes to this function, it just…
0
votes
1 answer

Problems resizing a PhotoImage on RPi

I'm hoping someone can help with this. I've got a new install of Pi OS (1/12/23) running on an RPi 3. Searching the web, I've found that this is not a new problem but I can't seem to find the answer. My problem is that the following short code runs…
0
votes
1 answer

Tk button is not clickable and image is not loading

I have created a GUI that shows data about videos from YouTube and allows me to select which video I want to download. The code works well, but for some reason some of the images don't load and I can't select the video. This is the result I get: it…
SagiZiv
  • 932
  • 1
  • 16
  • 38
0
votes
1 answer

Avoiding garbage collection for Tkinter PhotoImage (Python)

I'm using MacOS v 12.6 and Python v 3.9.6. Why does the code below garbage collect the image unless the commented-out line is uncommented? Isn't using self.img supposed to be enough to avoid garbage collection? from tkinter import Tk, Label from PIL…
TimH
  • 423
  • 4
  • 14
0
votes
1 answer

Stop tkinter from flashing when switching Canvas PhotoImages?

My tkinter user-interface involves two large Canvas widgets that are used to display photographs. The photographs update periodically, since they are being fed from live cameras. Problem: with some probability, the Canvas flashes white as it…
Joymaker
  • 813
  • 1
  • 9
  • 23
0
votes
1 answer

image "pyimage2" doesn't exist

This code of program is not running and showing error image "pyimage2" doesn't exist import tkinter from PIL import ImageTk, Image def imagine(): window1 = tkinter.Tk() window1.geometry("1000x300") img =…
1
2