Learn Python tkinter labels easy 🏷️
ฝัง
- เผยแพร่เมื่อ 21 ต.ค. 2024
- 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'))
This lesson was really cool. And it appears to be only the beginning. Definitely two thumbs up.
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
I am already in love with you and your teaching style. This is the best video tutorial I have watched on TH-cam
I have been looking for someone like you for a long time. Thank you for all of this work you have been doing.
amazing tutorial, bro you're videos are helpping me with school very much thanks
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!
this is the best tutorial.. 😍😍😍😍
Thanks, simple and efficient as always.
You are awesome! Keep going pls im learning much more than in school
Love your tutorial
amazing tutorials thanks!
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
VERY GOOD SERIES
This video helped me a lot
Thank Bro you help me alot
Thanks
Cool… thanks Bro!
SO COOL
thanks big bro
Great!
Really good
thanks a mil
Good.
Great information ❤❤
Just remember me when you become famous
.
Ty
Nice tutorial
💛
Wow!
superb
cool
thanks bro
AWESOME!!(sorry fo shouting, i hope i wasn"t too loud)
❤😊
nice video
❤❤
Thank you!
Wow!
Thanks
❤
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???😕😕😕😕😕😕
love u
nice bro
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
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 ?
شكرا
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
Damn thanks bro
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?
@@Рейдан-б3й 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
I still can't figure it out how to add pictures to pycharm I'm using a Mac :/
well, "Hello World!"
He has nuclear launch codes in his computer... I trust him with that information more than the government
I know this video is old, but I have a question. How do you print the label?
print("label name")
For some reason my label didn't expand to the size of the text / photo
drop a comment down below
Meow~! :3
blabla for you bro
Wait, I can't make labels!😭 Couldn't I!?
_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.
i dropped a comment
Can community pycharm import pictures
Bro, are you sure you know how to code?😊
Bro, do you even code?
how I can dowland phyton
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?
@@1916-1gu try switching from jpg images to PNG images
Actually i converted my file to png and my issue was solved
NUCLEAR LAUNCH CODES????!!!???!!!???
coment
d
fg dont work
Dayy1 gui
Thanks
Dayy1 gui