Это видео недоступно.
Сожалеем об этом.
Learn Python tkinter labels easy 🏷️
HTML-код
- Опубликовано: 21 сен 2020
- Python label labels tkinter GUI code example tutorial for beginners
#Python #label #labels #tkinter #GUI #code #example #tutorial for #beginners
from tkinter import *
label = an area widget that holds text and/or an image within a window
window = Tk()
photo = PhotoImage(file='person.png')
label = Label(window,
text="bro, do you even code?",
font=('Arial',40,'bold'),
fg='#00FF00',
bg='black',
relief=RAISED,
bd=10,
padx=20,
pady=20,
image=photo,
compound='bottom')
label.pack()
#label.place(x=0,y=0)
window.mainloop()
from tkinter import *
# label = an area widget that holds text and/or an image within a window
window = Tk()
photo = PhotoImage(file='person.png')
label = Label(window,
text="bro, do you even code?",
font=('Arial',40,'bold'),
fg='#00FF00',
bg='black',
relief=RAISED,
bd=10,
padx=20,
pady=20,
image=photo,
compound='bottom')
label.pack()
#label.place(x=0,y=0)
window.mainloop()
raise RuntimeError(f"Too early to {what}: no default root window")
RuntimeError: Too early to create image: no default root window
error in line 7 (photo = PhotoImage(file='person.png'))
I am confident this channel gonna explode within the next few months. Great content for beginners....
You were right 🤧🥶
Yup, this is such a good video
You deserve to be one of those programming youtubers at the top
This lesson was really cool. And it appears to be only the beginning. Definitely two thumbs up.
amazing tutorial, bro you're videos are helpping me with school very much thanks
I am already in love with you and your teaching style. This is the best video tutorial I have watched on RUclips
I have been looking for someone like you for a long time. Thank you for all of this work you have been doing.
this is the best tutorial.. 😍😍😍😍
Thanks, simple and efficient as always.
VERY GOOD SERIES
Ive been trying for ages to get an image on a button and even tho u explained how to do it on a label. It was so simple I could do it on a button as well. Thanks bro
you are so underrated keep the good work going man
thank you Mahmoud!
SO COOL
Love your tutorial
Thank Bro you help me alot
thanks big bro
Wow!
Thanks
superb
Good.
thanks bro
Bro's 2021 voice compared to his 2020 voice sounds like he put on 30 kg of muscle and truly became the gigachad as we know him today. Based
amazing tutorials thanks!
nice video
Great information ❤❤
Just remember me when you become famous
cool
This error always comes up in my terminal: _tkinter.TclError: couldn't recognize data in image file
I've written it all over again and all the solutions on the internet are just changing the image type, which I did but it still doesn't work
same
Nice tutorial
love u
Really good
Ty
thanks a mil
Great!
💛
Hi there!
Photo image is not working for me, IDK why? until I did this
import PIL as P
import PIL.ImageTk as ptk
pic = "C:\filepath"
buttonImage = P.Image.open(pic)
buttonPhoto = ptk.PhotoImage(buttonImage)
Can someone explain me why is this and why not am able to use BRO CODE for images???😕😕😕😕😕😕
nice bro
AWESOME!!(sorry fo shouting, i hope i wasn"t too loud)
I still can't figure it out how to add pictures to pycharm I'm using a Mac :/
Thank you!
He has nuclear launch codes in his computer... I trust him with that information more than the government
well, "Hello World!"
i dropped a comment
Meow~! :3
شكرا
blabla for you bro
Damn thanks bro
For me compound and image arguments are hating each other. If I use them individually they are working well , but not together. Any reason.? I am using mac Os this the reason ?
For some reason my label didn't expand to the size of the text / photo
Hi Bro,
I have a problem when I try to display both text and image. After I typed in compound='bottom', both of text and image disappears and leave a blank space with the border (which I suppose is the same size as if they are still there?). I cannot figure out what going run.
I have the same problem. Still don't know what to do. Did you find the solution?
@@user-ux2jl5ly2f Not really
remove the "relief = RAISED," and it will work, dont know why had the same problem
Hey there! I'm on a Mac, and it has to do with the relief option. You have five options for relief: FLAT, RAISED, SUNKEN, GROOVE, RIDGE. RAISED and SUNKEN will not work when combining both the photo and the text. GROOVE, FLAT, and RIDGE should work if you choose those options instead.
@@dylanwatson7331 Thank you for this comment
Can community pycharm import pictures
how I can dowland phyton
Traceback (most recent call last):
File "C:\Users\Asger\PycharmProjects\pythonProject\main.py", line 1347, in
window = Tk()
NameError: name 'Tk' is not defined '
WHY does this happen
_tkinter.TclError: couldn't recognize data in image file I got this error even after i copy and paste the same code of you and change the photo name to person.png. Please help me out on this.
i had this problem too u can solve this by installing PIL by typing "pip install Pillow" in command prompt then in your code import it as:
from PIL import ImageTk, Image
then where ever you use PhotoImage, you instead use ImageTk.PhotoImage()
it will definetlely work.
Glad to help
@@jeevanpranav6877 Thank's for your response bro. i find out that there should be always png image. if using other image formats you need to import and do lots of other stuffs that you've mentioned too.
drop a comment down below
Wait, I can't make labels!😭 Couldn't I!?
I know this video is old, but I have a question. How do you print the label?
print("label name")
Bro, do you even code?
d
Bro, are you sure you know how to code?😊
NUCLEAR LAUNCH CODES????!!!???!!!???
coment
Dayy1 gui
Thanks
Wow!
Traceback (most recent call last):
File "C:\Users\PC\PycharmProjects\pythontutorial\adv\labels.py", line 7, in
photoes = PhotoImage(file='tow.jpg')
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\PC\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 4130, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Users\PC\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 4075, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "tow.jpg"
this happens when i try to display images why bruh
I have same problem, did you find a solution?
@@SZAJZA1916 try switching from jpg images to PNG images
Actually i converted my file to png and my issue was solved
Dayy1 gui
Thanks