Using images in tkinter [ including how to scale them ]

preview_player
Показать описание
A video that covers using images in tkinter. An emphasis is put on how to scale images properly to fill an area.

You can get the code here:
Рекомендации по теме
Комментарии
Автор

You are one of the best python teachers I have encountered to date

andc
Автор

There was an old PIL library for image manipulation in python2. Pillow is newer fork of it, written in python3. So library is pillow, but "import PIL ..." for compatibility))

diver
Автор

Note: When a PhotoImage object is garbage-collected by Python (e.g. when you return from a function which stored an image in a local variable), the image is cleared even if it’s being displayed by a Tkinter widget.

To avoid this, the program must keep an extra reference to the image object. A simple way to do this is to assign the image to a widget attribute, like this:

label = Label(image=photo)
label.image = photo # keep a reference!
label.pack()

This is alternative way to do it instead of using global variable.

lewisheslop
Автор

Damn bro, how does this channel have only 920 subs, with these damn cool videos?

vnixd
Автор

Thankyou for bringing this kind of videos 🎉

chillwithcode
Автор

So I have many UI elements. When I resize them with PIL is so slow. Is there a way to make them fast? I've made an app, but I am trying to figure out how to make it fit on the window that opens, Sadly, now the canvas gets cut by the window.

djohnworthy
Автор

Is there anyway to make the picture smaller and to size fixed position?

stifenjans
Автор

tkinter puede leer por defecto png files o gif files o pnm o ppm files. pillow solo se usa para leer jpg o tiff.

rolandojtorres
Автор

Very good video
Was looking for long time
I have a question
I have a folder with 25 photos.
I want the images with even number must come in canvas A and the images with odd numbers must come in canvas B.
Can you make a video or help me to code that
Waiting for your reply

autarroy
Автор

I have pillow already installed but it says pillow cant be defined, why s=is this happening? im very new tocoding

benedict
Автор

The one answer i was looking for and it is left as training exercise... i guess i have to look somewhere else

galedex
Автор

no trates de entender tkinter si no sabes tcltk antes. python no ejecuta tkinter, es tcl el que ejecuta tkinter.

rolandojtorres
Автор

Like Communism this all works great in theory. In practice is is always a complete disaster.

"Error: Cannot import ImageTk from PIL." OF COURSE....

mitch_the_-itch