Python 3 Programming Tutorial - Tkinter adding images and text

preview_player
Показать описание
Finally, as a conclusion to our intro to tkinter, we cover the addition of labels. A label in tkinter can be an image or text. In this tutorial, we cover both examples, by showing an image as a part of an event, by adding "show image" to our edit option in our menu bar. We do the same thing with "show text," which pops up some text as well.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

I've been trying to figure out how to add an image into a Tkinter GUI for so long and finally managed to do it thanks to this tutorial. Thank you so much!

dylanwares
Автор

Thanks for completely brushing over how to install the extra library, I was loving these tutorials, but now I've hit a wall, and all the comments are treating it like it should be the easiest thing ever.

edm
Автор

hmm one question how could you do like the image will fill the whole window and be the background?

asbjrnandersen
Автор

Hi sentdex,

I have followed your tutorials and now I'm advancing on the tkinter window a bit more. So now I some questions:

1) When I import a GIF file it doesn't move, Is the code different of do I have to use a module like canvas instead?

2) How do I change the size of the picture and the text? I tried using the codes on stuff like stackover flow but nothing worked?

Hope you can help or even make an advanced tutorial on stuff like this,

Thanks in advanced Joe

joewoodger
Автор

sentdex 
It would be great if you could add on to this tutorial. There is a lot to learn. Thus far, I have understood better from your tutorials than anyone else's.

Just as a quick tip to those who didn't know this, you can remove the dashed line that shows in all the menu cascades by adding in 'tearoff = 0' like this:

file = Menu(menu, tearoff = 0)

This will remove the option to pull the file or edit menu's commands into a secondary window, thus removing the dashed line.

XraytedTimtations
Автор

Good mini-series, thanks for taking the time, much appreciated

michaelryding
Автор

Hey +sentdex, when you approach a new programming language, how do you go about learning all the little things about it? Like tkinter, or pygame for example? How did you come to find these as solutions for your problems? How did you learn how to utilize these elements for your purposes?

This question coming from someone who primarily learns from tutorials such as yours, by debugging their own code, and occasionally by reading documentations.

GibsnRage
Автор

Thankyou so much :) Theres so many ways to put an image into python/tkinter and after many many tutorials ive found this one which does it how i wanted it to be :)

benbob
Автор

Thx...Dude...Really Helpful...Keep Helping..the Beginnners..!!

mr.nobody
Автор

"So you can.... Accept that" hahaha good stuff. For people having issues installing PIL or pillow, try using "pip3 install PIL" instead of "pip install PIL"

ssssaaaammmmm
Автор

Hi, I saw you have img.Label(self, image=render) already defined the image as render, why it is necessary to have img.image = render to make it work?

haolingyang
Автор

Harrison, thanks for the wonderful video tutorials! It would be a great help if you can extend this topic a tad bit, by including a scrollbar (horizontal and vertical) to the frame / by adding a canvas. Scrollbars are commonly used, and I realize that it requires a bit of effort to add them. Hence the request. Thanks.

skbpillai
Автор

Hey, thanks for the video, very helpfull but how do you resize the image to the windows size?

MyNosound
Автор

Finaly after so mutch try and error + this video i was able to finaly get a image from a url :D

from tkinter import *
import urllib
from PIL import Image, ImageTk

url='picture url'
response = urllib.request.urlopen(url)
img = Image.open(response)
render = ImageTk.PhotoImage(img)

renderImg = Label(master=Window, image=render)
renderImg.image = render
renderImg.grid(row=2)

Works on python 3.5.2

stew
Автор

Hi I made a program in python with tkinter which is like this. You enter your name, age and your income and it will give you a message if you are eligible for credit card. Based on your age and salary, you get messages of you are eligible for credit card, not eligible for credit card, eligible for gold card or platinum card.
Now I want to display emojis along with these messages. I am just stuck at this point. I have saved my images in the same folder as my program sits. Need help here.

lathanelapati
Автор

Is there a way to make picture boxes (images) without pillow for Python 3.5.1 that support .bmp, .jpg, etc?

ThePassingVoid
Автор

Pillow only supports a specific version 3.3 - and now that a later version is 3.5.1 is available - then installing Pillow refuses to install on a Windows machine - because it says that it can;t find Python 3.3.

marvinn
Автор

by command=function() it runs it ok, but after that, is command assigned to the callable function too without a returned statement at the end of function() ? does it need a return self.function at the end of it ? it looks like it's implicitly done ?

MichiganSmith
Автор

Hi, i'm using a Mac and i'm trying to set an image as a background in a window. I've tried many different ways but doesn't work. The error message is "no such file or directory" even if i changed the file type of my picture in .gif or .pnj . Can you help me please? :)

ZzDaRkSpiritzZ
Автор

Ran into the immediate exiting problem due to client_exit() a few episodes back, good call

andrewtakao
visit shbcf.ru