Questions tagged [photoimage]

104 questions
5
votes
1 answer

My image is not transparent when I am using ImageTk

I am trying to put an image into a window with ImageTk and PhotoImage. Below is the code: import tkinter as tk import random as r from PIL import ImageTk, Image window = tk.Tk() HEIGHT = window.winfo_screenwidth() WIDTH =…
10 Rep
  • 2,217
  • 7
  • 19
  • 33
4
votes
3 answers

How to find out size of a PhotoImage in Tkinter?

How do I access the width and height information on a PhotoImage() class object? I tried PhotoImage(...).winfo_width() and PhotoImage(...)["Width"]. Both of them didn't work.
gowner
  • 327
  • 1
  • 4
  • 11
3
votes
0 answers

tkinter PhotoImage still not work for some PNG files

PhotoImage for images in PGM, PPM, GIF and PNG formats. The latter is supported starting with Tk 8.6. Information about my environment, WIN10 Python 3.6.0 tkinter.TkVersion 8.6 tkinter.Tcl().eval('info patchlevel') 8.6.6 I got some PNG files…
Jason Yang
  • 11,284
  • 2
  • 9
  • 23
3
votes
1 answer

Python tkinter code doesn't run when inside a function

def display_rain(): rain_image = Image.open("./images/rain_jpeg.jpg") rain_resized = rain_image.resize((250,250), Image.ANTIALIAS) rain_tk = ImageTk.PhotoImage(rain_resized) rain_label = tk.Label(root, image = rain_tk) …
3
votes
0 answers

Widgets disappear when main window moved off screen

I have a tkinter window that I have given a background picture by creating a Label widget with a PhotoImage instance (referencing the image instance through Label attributing). However when I run the script and move the main window below the start…
Ryan Oz
  • 71
  • 4
2
votes
0 answers

Why does image fails to display in tkinter unless PhotoImage is saved as a variable?

I just started learning python recently. I have tried to use Thonny. I googled and searched on stackoverflow such as Why does Tkinter image not show up if created in a function? and Tkinter.PhotoImage doesn't not support png image, but have not…
Kwan Hui
  • 21
  • 3
2
votes
1 answer

Is there a way to make Entry widgets in tkinter rounded or look nicer?

I code in Python and I use tkinter quite a lot to create GUIs for my applications. I prefer to make my GUIs look round and modern rather than sharp cornered boxes. For buttons and labels I tend to use PhotoImage to use self-made images that provide…
2
votes
1 answer

Resize PhotoImage using .zoom or .subsample

I want to resize PhotoImage at load stage. As you know, .zoom and .subsample cannot work with floating variables, only integers. Now I resize it with wrong way: i1=PhotoImage(file="res\\1h.gif").zoom(new_size).subsample(old_size) It works with…
D7ILeucoH
  • 97
  • 9
2
votes
1 answer

PhotoImage zoom

I'm trying to zoom in on an image and display it with the following code import tkinter as tk from PIL import Image as PIL_image, ImageTk as PIL_imagetk window = tk.Tk() img1 = PIL_imagetk.PhotoImage(file="C:\\Two.jpg") img1 =…
Mas
  • 329
  • 2
  • 13
2
votes
2 answers

Python Tkinter Treeview add an image as a column value

i'm trying to add an Image to the first column of every row on a treeview, but no matter what I do, always end up with the name of the object "pyimage1" showed instead of the actual image. As this image shows The code that i'm using is something…
diegoiva
  • 454
  • 1
  • 8
  • 17
2
votes
1 answer

how can I make png image to gif image?

I want to change png image to gif image using python3.6 how can I do that? i'm making a GUI program with tkinter and i haver to change png to gif image so i can display on my program please help tk = Tk() tk.configure(bg =…
2
votes
2 answers

Python Tkinter - Find image file path from PhotoImage

I have a PhotoImage in tkinter called al_p4 but I want to be able to print the file path of the image. Can anyone help. Here is my code: al_p4 = Image.open("Media/DVD/image.jpg").resize((100, 150), Image.ANTIALIAS) al_p4 =…
Music Champ29
  • 67
  • 1
  • 1
  • 8
1
vote
1 answer

Adding image to button via tkinter

This is the code... from tkinter import * import PIL count = 0 def click(): global count count+=1 print(count) window = Tk() photo = PhotoImage(file='Flanderson.png') button = Button(window, text="Draw A Card", …
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
2 answers

how to display an image in tkinter from a byte array

i scraped from the web some pictures with aiohttp and i got them saved in a list filled with arrays like this('\xe25\xd7\xeeP{\x08\x18-6\x809\xabQ1LQ\xf0\x02hC\x11\x97*.\xc8...') i am trying to display the pictures using canvas and Photoimage but it…
user109606
  • 51
  • 4
1
2 3 4 5 6 7