Using Icons, Images, and Exit Buttons - Python Tkinter GUI Tutorial #8

How to use Icons, Images, and Exit Buttons with TKinter and Python. In this video learn how to use icons, images, and exit buttons in tkinter. Tkinter images, TKinter Exit Buttons, and TKinter icons are pretty easy - see how in this video!
In this series I'll show you how to create graphical user interfaces for Python with Tkinter. TKinter comes with Python already, so there's nothing to install!
✅ Watch The Other Videos In This Python Playlist:
bit.ly/2UFLKgj
▶️ See More At:
Codemy.com
✅ Join My Facebook Group:
bit.ly/2GFmOBz
✅ Subscribe To My KZread Channel:
bit.ly/2IGzvOR
▶️ Learn to Code at Codemy.com
Take $22 off with coupon code: youtube

Пікірлер: 753

  • @Codemycom
    @Codemycom4 жыл бұрын

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My KZread Channel: bit.ly/2UFLKgj bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN

  • @jainajit2412

    @jainajit2412

    3 жыл бұрын

    how to display multiple images in tkinter window. I have tried this code but its not working! from tkinter import * import os root = Tk() root.geometry('1000x600+180+50') list_img=[] for i in os.listdir(): if i.split('.')[1] == 'png': list_img.append(i) f1 = Frame(root,bg='black',borderwidth=5 ,relief=SUNKEN,) f1.pack(fill=BOTH) for image in range(0,9): photo_ = PhotoImage(file=list_img[image]) img_ = photo_.subsample(2,2) l = Label(f1,image=img_) l.pack(pady=5) root.mainloop()

  • @donaldppaul3260

    @donaldppaul3260

    3 жыл бұрын

    There is a bug in my calculator .if we press equal to again after a mathametical operation it just do that same mathametical operation with result I mean is that a bug

  • @100jsj6

    @100jsj6

    2 жыл бұрын

    @Codemy.com Hello sir ,I have an error : i cant really add the icon . i dont know why . heres what i did : root.iconbitmap(C:\Users\myuser\Desktop\Coding-Items\image.ico) # this doesnt work . can you give me suggestion ? Thanks

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    @@100jsj6 You probably aren't using a real icon file.

  • @100jsj6

    @100jsj6

    2 жыл бұрын

    @@Codemycom Hello sir . Yes that maybe becoz i just renamed file from .png to .ico . I'll try an actual convertor for it . Here is the error thrown in the terminal if that'll help : Traceback (most recent call last): File "c:\Users\myuser\Desktop\Coding-Items\SPAM\Spam.py", line 13, in win.iconbitmap('SPAM_asset.ico') File "C:\Users\myuser\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 2080, in wm_iconbitmap return self.tk.call('wm', 'iconbitmap', self._w, bitmap) _tkinter.TclError: bitmap "SPAM_asset.ico" not defined I was adding an icon for a spamming app hence the weird names 😅😅 Thank you so much for replying sir and that too quickly !

  • @prakulsingla1363
    @prakulsingla13633 жыл бұрын

    This is the best playlist I can find on python GUI. Amazing.

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Thanks! Glad you like it!

  • @Phizzo4real

    @Phizzo4real

    Жыл бұрын

    I have been going thru and learning a ton...

  • @cbaymac
    @cbaymac3 жыл бұрын

    One of the best instructors on KZread. Your explanations and format are great. I am going to sign up for your full program. Thanks for all your hard work.

  • @greatindianbuilder2491
    @greatindianbuilder24913 жыл бұрын

    Thanks for vid, really help. I feel so lucky that I have access to so much information(and tutorials) without any charge.

  • @marisko16
    @marisko163 жыл бұрын

    Man, you are explaining things just the way I would do. Perfect, thank you very much.

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Glad you're enjoying it!

  • @ozbekchawindows4236
    @ozbekchawindows42364 жыл бұрын

    You are so good... You are my hero! You know everything in Python...

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Ha, hardly everything...but thanks!

  • @jorgearmandoperez1450
    @jorgearmandoperez14503 жыл бұрын

    Man you are my new favorite hero! thanks!

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Wow, thanks!

  • @ashrsfsiliman452
    @ashrsfsiliman4523 жыл бұрын

    Great job deserving of thanks عمل رائع يستحق الشكر

  • @vic-san12
    @vic-san122 жыл бұрын

    I love your videos. I learned a lot from them. More power to you!

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Thanks!

  • @ndvz8672
    @ndvz86723 жыл бұрын

    Whats going on John! LOVE the content. Youre awesome, thank you!

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    thanks!

  • @alwayscubing8200
    @alwayscubing82003 жыл бұрын

    Hey buddy, so awesome...very useful. I have been searching tkinter gui tutorials and fortunately, i found u😃😃

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Glad you did

  • @namanchhibbbar2205
    @namanchhibbbar22054 жыл бұрын

    you are really awesome, highly appreciate your work

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Thank you! I appreciate that!

  • @nihalthannegedarapremaratn2352
    @nihalthannegedarapremaratn23524 жыл бұрын

    Very helpful. Thanks you..... Hope continue.....

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Glad you liked it...there's like 50 more videos in this playlist

  • @fsldr
    @fsldr2 ай бұрын

    thanks a lot man!

  • @Codemycom

    @Codemycom

    2 ай бұрын

    Welcome!

  • @bea59kaiwalyakhairnar37
    @bea59kaiwalyakhairnar372 жыл бұрын

    Really helpful

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    glad you liked it!

  • @siegfriedcoppens
    @siegfriedcoppens2 жыл бұрын

    Good video!

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Thanks!

  • @yashar696
    @yashar6963 жыл бұрын

    Thanks it was great & very useful♥♥

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    You're welcome 😊

  • @marcmathieutrance6807
    @marcmathieutrance68072 жыл бұрын

    Thank you very much

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Welcome!

  • @myselfsohit
    @myselfsohit4 жыл бұрын

    I have a no words ....frankly speaking i enjoying a lot..thank you so much for your efforts for those can't afford paid courses..love you from INDIA.......

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Thanks for watching!

  • @quangtram4672
    @quangtram46723 жыл бұрын

    Superb.

  • @ArminEskandary
    @ArminEskandary2 жыл бұрын

    ur a life saver

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Happy to help!

  • @parsabahrambeik4381
    @parsabahrambeik43813 жыл бұрын

    Hi, thank you very much for your video. You helped me a lot with the database. AND.....

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Happy to help!

  • @tor6953
    @tor69537 ай бұрын

    Thank you

  • @Codemycom

    @Codemycom

    7 ай бұрын

    welcome

  • @hawrezangana8240
    @hawrezangana82402 жыл бұрын

    Walter White teaches Tkinter like a boss.

  • @yujiafu9484
    @yujiafu94843 жыл бұрын

    thank you

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    you're welcome!

  • @katmanduYT
    @katmanduYT3 жыл бұрын

    I did a program in the past without PIL but I just used img = tk.PhotoImage , can I know the difference between what I used and pil buttons?

  • @raniduharshana5238
    @raniduharshana52384 жыл бұрын

    Thank you very much. I learnt a lot about tkinter. 🤭❤️

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Glad it was helpful!

  • @vexinity5151
    @vexinity51512 жыл бұрын

    Such a legend, oh my gosh.

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Ha thanks

  • @user-qw8mm6bt9p
    @user-qw8mm6bt9p4 жыл бұрын

    THANK YOU

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Welcome!

  • @keymediastudioitself
    @keymediastudioitself3 жыл бұрын

    To avoid resizing put: # app = your root app.resizable(width=False, height=False)

  • @tomabrasoveanu

    @tomabrasoveanu

    2 жыл бұрын

    how do i tell what my root is?

  • @100jsj6

    @100jsj6

    2 жыл бұрын

    @@tomabrasoveanu the name "app" is a variable which contains tk.Tk() so this is what the code wud be: from tkinter import * # * signifies all #create a variable to host the app with the name of ur choice . im doing "hi" over here hi = Tk() #it will be tk.Tk() if u do "import tkinter " instead of "from tkinter import *" hi.resizable(width= False , height= False) hi.mainloop() #now ,the app wont be resizable

  • @100jsj6

    @100jsj6

    2 жыл бұрын

    i hope i satisfied your question by giving an answer 😃😃

  • @Viicorico

    @Viicorico

    2 жыл бұрын

    @@100jsj6 hi what do u mean by resizable ?

  • @100jsj6

    @100jsj6

    2 жыл бұрын

    @@Viicorico i mean that the window isnt resizable

  • @loicmahe2430
    @loicmahe24304 жыл бұрын

    Good evening If I want to put my image in one of the frames I've created, what do I have to add so it goes to the frame and not the main root Thank you and keepo going with this awesome videos you're making!!

  • @iannsa5390

    @iannsa5390

    4 жыл бұрын

    suppose you wrote self.frame = Frame(self.mainWindow) then you have to place the image in the label and the label in the frame. then, you make self.my_label = Label(self.frame,image = ...)

  • @preityvasudevankondath1731
    @preityvasudevankondath17314 жыл бұрын

    Hey, great course, helping me a lot during my projects Just a question, how to add a button on top of the image?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    There's 100 videos on this playlist. I have several videos on buttons and images :-p

  • @TahmidulAzomSany
    @TahmidulAzomSany3 жыл бұрын

    Those who are getting delayed by the exit button: You can use root.destroy instead of root.quit

  • @ayaallahibrahimabdel-razek7971

    @ayaallahibrahimabdel-razek7971

    2 жыл бұрын

    thanks that really helped me but why didn't root.quit work ?🤔

  • @daniyalmalik9441

    @daniyalmalik9441

    2 жыл бұрын

    Thankyou Man

  • @marcmathieutrance6807

    @marcmathieutrance6807

    2 жыл бұрын

    @@ayaallahibrahimabdel-razek7971 maybe its kind of deprecated or something

  • @aaronhojnacki6051

    @aaronhojnacki6051

    2 жыл бұрын

    Thank you

  • @mikhailkevin2505
    @mikhailkevin2505 Жыл бұрын

    good afternoon sir, i want to ask something about tkinter, can we display terminal python with it?

  • @syllakerfalla9516
    @syllakerfalla95164 жыл бұрын

    very goog

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Thanks!

  • @Zachomara
    @Zachomara4 жыл бұрын

    For new people, PIL is in all caps. Also, you add Pillow from the command line with pip install Pillow. (Stack overflow apparently says its deprecated) Also, ImageTk, the "k" is not capitalized. It drove me nuts for about an hour before figuring it out. Also thank you for this video. Awesome content.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Was any of that not obvious in the video?

  • @Zachomara

    @Zachomara

    4 жыл бұрын

    @@Codemycom I think my main mistakes with it was not hearing the part about the command line. I ended up going to try to install it within the python program at first, and went down a rabbit hole. I'd say user error was the main cause. That being said, I learned quite a lot from the videos so far. Like way more than any of the other videos I went through.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    @@Zachomara Cool

  • @farmflight

    @farmflight

    4 жыл бұрын

    @@Codemycom ok I keep getting this error code: "No module named 'PIL'" but I added pillow in the command line by using pip install pillow. Do you know what might be happening?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    @@farmflight Did you pip install Pillow (capital P)? You'll have to google it, some people just have problems with it

  • @selinsabrcan2848
    @selinsabrcan28482 жыл бұрын

    Hello, I am having difficulty visualizing my png images. I currently have them in a file on my desktop called project_file. I am using "c:/desktop/project_file/imagename" but python is giving me an error. Can someone tell me what I'm doing wrong? Or how to fix this issue! Thanks

  • @fentonmsu
    @fentonmsu3 жыл бұрын

    Wonderful, still using windoa 8.1

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    ouch lol

  • @mehhh._.3704
    @mehhh._.37044 ай бұрын

    Great Tutorial! I'm watching this 5 years later, but there's a function called Eval() in python. You could use this to make it a scientific calculator and make the evaluation function just evaluate the string.

  • @Codemycom

    @Codemycom

    4 ай бұрын

    yeah

  • @douglasmonteirodasilva2421
    @douglasmonteirodasilva24214 жыл бұрын

    Hi John, Me here again haha. John I have been following your tutorial awhile and building an app aside with tips that I get from here. I tried and managed to make it work (switching frames in tkinter without having to call a new window). But when I try to insert an image inside of a class, the code runs but the image doesn't appear. any ideas what it could be ? regards, Douglas

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    I couldn't really guess...could be any number of things...

  • @ShaiS0
    @ShaiS04 жыл бұрын

    First of all, just want to say I'm so happy I found your channel! informative clear and fun! So thank you for that. Now for my question - I've successfully added the ico and png files as demonstrated. But they only seem to work when I put the full path to them. If I try just the file name I get a "TclError bitmap "coffee.ico" not defined. same thing for the png. The files are in the same folder as the py file. using VS Code as my IDE if that matters

  • @ShaiS0

    @ShaiS0

    4 жыл бұрын

    I've now tried running the same py file straight from the command line and it seems to be running fine. So I guess it's related to environment or path when running from VS Code. no clue as why though...

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    @@ShaiS0 Yeah that's why I don't use complicated editors like VS Code or Pycharm...there's always weirdness like that.

  • @ShaiS0

    @ShaiS0

    4 жыл бұрын

    @@Codemycom Thanks for your reply. Well, that's a bummer. Though I guess I could still use it as an editor (quite like it) and just execute the old fashioned way from the CMD. Thanks!

  • @ShaiS0

    @ShaiS0

    4 жыл бұрын

    Just an update - for those who end up in the same situation. It should be possible to change the settings so that relative path is resolved from the script file location and not from somewhere else - I couldn't make it work for me. What I did is I installed an extension to CODE called "Code Runner". It adds a right click context menu "run" action and a "run" icon at the top right side. This works similar to running the code manually from the terminal window. Unfortunately it doesn't work together with the debugger built in CODE but it's better than nothing.

  • @Manish_Kumar_04
    @Manish_Kumar_043 жыл бұрын

    Hi John, my side its showing unicode error, can't decode... whatever it is, also I'm not able to use pillow as you've told, what I'll do now?

  • @crossfarm4146
    @crossfarm41464 жыл бұрын

    Can you guide me to a video, or some webpage that explains how to change windows within the same window? so for example, I want to have a start button, that when you click it the start button disappears, and then a new window appears (the same window) with different information. In the same way that HTML pages work with navigation. I found one video but the guy was going deep into using classes, which I don't have a firm grasp on it yet. Any of your videos go into this topic?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    You can learn all of those things by watching my videos in my tkinter playlist.

  • @harshwardhanshirodkar769
    @harshwardhanshirodkar7693 жыл бұрын

    @Codemy.com is there a way we can change the taskbar icon for the file too?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    no

  • @theepicguy6575
    @theepicguy65754 жыл бұрын

    Legend says this is series is epic

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Ha thanks!

  • @amankumarbairagi794
    @amankumarbairagi7944 жыл бұрын

    Sir, Which type of editor do you use for programming in python ?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    I use the sublime text editor and the git bash terminal

  • @OsiRixxx
    @OsiRixxx2 жыл бұрын

    if i need to give the code to someone else it will not open the images with my local dirctories, correct? or does python save the .ico internally in the code file? sorry for the dumb question, i am very new to this.

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    No it won't, unless you send them the images too.

  • @emanuelshemesh
    @emanuelshemesh3 жыл бұрын

    whn i try to run the pogram it says photoimage' object has no attribute '_photoimage__photo' any ideas what i should do??

  • @FRIENDSofCAP
    @FRIENDSofCAP4 жыл бұрын

    Hi, Tim here. Question... I am running a Mac Pro desktop computer running Mac oSX(Mojave) and using Visual Studio Code as my IDE with Python 3.7.4... I have tried adding 'mainWindow.iconbitmap('filename.ico) which includes any path prefixes but don't see any icon at all. Any ideas as to why this is? Any tips on addressing this issue? Any help is greatly appreciated. Thanks

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Check this out for your answer... stackoverflow.com/questions/33134594/set-tkinter-python-application-icon-in-mac-os-x

  • @dumidupramith3881
    @dumidupramith38814 жыл бұрын

    super

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Glad you enjoyed it

  • @SpinnTV
    @SpinnTV3 жыл бұрын

    is there a way to use font awsome with python desktop app

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    No clue, sorry

  • @pragunashok6008
    @pragunashok60083 жыл бұрын

    when i try to add an icon, it gives error tkinter.Tclerror: bitmap "" is not defined

  • @espanolparatodos7758

    @espanolparatodos7758

    3 жыл бұрын

    me toooo it's so annoying

  • @himanshushukla787

    @himanshushukla787

    3 жыл бұрын

    Yeah It's happening with me on linux but on windows it's working

  • @100jsj6

    @100jsj6

    2 жыл бұрын

    THAT IS THE EXACT SAME THING HAPPENING WITH ME @Peter Rezkalla i'll try that thanks

  • @michaelvidanes6629
    @michaelvidanes6629 Жыл бұрын

    Can you help me find a solution on retaining images in Tkinter? That's because the image just pops-up when loaded, the it disappers. Hope you can help me. Thanks.

  • @afrahtabassum7001
    @afrahtabassum70013 жыл бұрын

    Hi, This was extremely helpful! I am trying to use canvases in my school project and the main window has a button which opens up another window. Problem is I can't seem to destroy the main window once the new one has been opened. I used destroy() and although all the widgets and the background image is destroyed, it leaves an open window behind with the title as "tk". I can't seem to figure out the issue and hoped you could help me. Thanks! P.S, I am kinda new to your channel so I am sorry if a video already exists on this matter. P.P.S, IDK why I wrote it like an email even though it's a youtube comment cheers

  • @Somebody_Unknown-

    @Somebody_Unknown-

    11 ай бұрын

    use your brain

  • @rice1345

    @rice1345

    7 ай бұрын

    @@Somebody_Unknown- shit opinion detected.

  • @sirvex7514
    @sirvex75145 ай бұрын

    im gonna be honest mr heisenberg you look extremely cute with the doggo

  • @Codemycom

    @Codemycom

    5 ай бұрын

    Ha thanks

  • @nadavAminov
    @nadavAminov3 жыл бұрын

    I do not want to have a picture inside the pane. I want to have instead of the white background of the panel a picture that it will serve as a background. Do you have a video about it?

  • @ritajbhosale6816
    @ritajbhosale68164 жыл бұрын

    is there any way to make the picture\photo to be in circle\oval .. or how can i make the corners transparent of the image.. i can use any image just i want the picture to seen in circular format..

  • @oneilmw

    @oneilmw

    4 жыл бұрын

    Image formats generally have four channels: a red channel, a green channel, a blue channel, and an alpha channel. The alpha channel is the "transparency" layer, and works just like the other three: each pixel has its own red, green, blue, and alpha value. If you turn the alpha value of the corner pixels to 0, you can get rounded corners. If you're looking for a way to automate this vignette within tkinter, good luck to you; it's probably a lot of work. Alternatively, you could (theoretically) make a corner image in your background color, anchor it to it's corresponding corner, then draw that on top of your image to trick the user into thinking that the image has rounded corners. I haven't tested it, but it is something to try.

  • @panosmalamis5389
    @panosmalamis53892 жыл бұрын

    Very helpful tutorial, but I am having problems with that pack function to bring in the function. How does that work? What does it do? Can anyone give me some more information?

  • @Hyvexx
    @Hyvexx3 жыл бұрын

    Im using tkinter on a Mac and it seems that for some reason, root.iconbitmap() doesn't work for me. It just changes the icon to a default Mac photo icon. Is there any way you know that allows me to get around this?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    you'll have to google it...there are a bunch of options, and you'll have to try a few to get the one that works for you. stackoverflow is your friend

  • @Hyvexx

    @Hyvexx

    3 жыл бұрын

    Codemy.com Oh ok

  • @user-yy5gq5by1h
    @user-yy5gq5by1h4 жыл бұрын

    Hi, I got an error: "TclError: bitmap "iconoprueba.icon" not defined", the icon is in the same folder where the file ".py" is. What can I do?. I hope you can help me with that.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    it should be iconoprueba.ico not iconoprueba.icon, that's why you got an error.

  • @atomic-blade6977

    @atomic-blade6977

    3 жыл бұрын

    @@Codemycom i still get it any solutions

  • @kenshin7440
    @kenshin744010 ай бұрын

    Thank you so much for the tutorial I started learning obsidian and emacs for 2 weeks and python about 3 days from now i had a very hard time setting up things but i made it work exept no matter what i ve done i get an error that shows the path nd if i remember it can't open file and bitmap stuff... I went with many solutions i added @ to path by the way im using deb12 i used .png instead of .ico and other things Should i try this? Is it same ? import tkinter as tk root = tk.Tk() root.title("Window with PNG Icon") # Load the PNG image icon_image = tk.PhotoImage(file="path_to_image.png") # Replace with your image path # Set the image as the window icon root.tk.call('wm', 'iconphoto', root._w, icon_image) root.mainloop() ``` I hope i can find a solution here

  • @kenshin7440

    @kenshin7440

    10 ай бұрын

    Finally i made it work and the problem was with the file type it accepts only .xmb which is freaking ugly only black/white in the 50s or 60s I ll keep looking for another solution but why on windows is easy and beautiful while on linux is difficult nd ugly😢😢😢😢😢

  • @Franco-rd8du
    @Franco-rd8du4 жыл бұрын

    Hi John, I am having an issue with pillow library, I installed from pip to the last version but every time I try to import the library I get the ModuleNotFoundError: no module named 'PIL'. I'm using visual studio code, but I tried it from Python.exe? (I don't know the name haha) and I get the same error, hope you can help me. Also, I googled this error but it wasn't helpful. Salut

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Google "No module named 'PIL'" and you'll find a bunch of things to try...try em all till one works

  • @Franco-rd8du

    @Franco-rd8du

    4 жыл бұрын

    Thanks for answering, I solved it, just had to open cmd and type pipe install pillow and worked

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    @@Franco-rd8du Nice!

  • @muhammadakmalmaulanarizqy7807
    @muhammadakmalmaulanarizqy78074 жыл бұрын

    hello sir i got a problem this Traceback (most recent call last): File "C:\Users\USER\AppData\Local\Programs\Python\Python37\imges tkinter.py", line 7, in my_img = ImageTk.PhotoImage(Image.open(k)) NameError: name 'k' is not defined how can i do to solve this problem?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    There's an error on line 7

  • @Harish-ou4dy
    @Harish-ou4dy4 жыл бұрын

    I converted my .jpg image into an .ico image using an online converter tool and used in my program. The icon in my window doesn't appear, but it shows a blank image.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    maybe the converter tool sucks...

  • @infinitespace1982

    @infinitespace1982

    3 жыл бұрын

    @@Codemycom Then what do you suggest?

  • @infinitespace1982

    @infinitespace1982

    3 жыл бұрын

    What you're probably doing wrong is that you are not specifying the NAME of the ico file after the directory, e.g. 'c:/gui' is the directory and 'codemy.ico' is the name of the ICO file, thus you must typer the following: (r'c:/gui/codemy.ico') in full (DON'T FORGET THAT 'r')

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    @@infinitespace1982 Using a different tool...or making your own in photoshop or the free gimp or any other graphics tool that will let you make and icon.

  • @anushkamble85

    @anushkamble85

    3 жыл бұрын

    @@infinitespace1982 Not admitting that he has maybe make a mistake

  • @onio1
    @onio12 жыл бұрын

    Any way to fit an image to the size of a button? Or do the image needs to previously be the size of such button?! Great videos by the way! KUDOS!!!

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    sure

  • @diyankalaydzhiev7517
    @diyankalaydzhiev75173 жыл бұрын

    Hello, i have a question, when i add image and then delete it from the computer it can't run the code. So is there a way to load the image to the code so that is part of it?

  • @ReinierS

    @ReinierS

    3 жыл бұрын

    You need to define a place to that image. Everytime you rerun the code it forgets everything in cache. So you can upload the photo on the internet and get it from there. Your code can't memorize your image

  • @MrSirPain
    @MrSirPain2 жыл бұрын

    Thank you for the great instructor, please keep up the great work and I look forward to the videos. I can not install Pillow. I am getting a "SyntaxError: invalid syntax" error!!!

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    What's the exact error? the command is case sensitive

  • @Spacekriek
    @Spacekriek6 ай бұрын

    Great series, thank you very much. What I do find irritating about these software packages, IDEs etc is this trend to add plugins and packages afterwards. Never complete. It's like buying a car and discovering you still need a spare wheel, side view mirrors... Oh, do you need an engine too, sir ? No problem, just download it ! :)

  • @Codemycom

    @Codemycom

    6 ай бұрын

    But when adding something happens in 10 seconds, for free...why does that bother you?

  • @Spacekriek

    @Spacekriek

    6 ай бұрын

    @@Codemycom Just a work in progress, then. :)

  • @daggercentral9818
    @daggercentral98183 жыл бұрын

    Traceback (most recent call last): File "C:\Users\ACER\images.py", line 2, in from PIL import ImageTK,Image ImportError: cannot import name 'ImageTK' from 'PIL' (C:\Users\ACER\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\__init__.py) getting this error please help sir...

  • @tishaanants

    @tishaanants

    3 жыл бұрын

    Ditto

  • @aravindtlp
    @aravindtlp3 жыл бұрын

    How did the my_label work without you mentioning that its in root? Thanks for the great content!

  • @darshanbothra2673

    @darshanbothra2673

    3 жыл бұрын

    It automatically takes in the root window, i think this was an update or something, but yeah, that works

  • @elchinefa9524
    @elchinefa95243 жыл бұрын

    Hi. Is the an option to run python program with double click? something like .exe file. Or i must create .bat file? Thanks in advance.

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Yes, you can make them into exe files. Check the playlist, I have a video on that

  • @elchinefa9524

    @elchinefa9524

    3 жыл бұрын

    @@Codemycom Thanks a lot, i'll check it tomorrow.

  • @TechWithSabri
    @TechWithSabri4 жыл бұрын

    Hello sir can you tell me please what's the difference between btn_quit = Button(root,text='Exit',command = root.quit) and this btn_quit = Button(root,text='Exit',command = root.quit() ) when we call the method " quit " without parentheses it's working but when we call it with parentheses doesn't work why ? by the way thank you so much

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    in tkinter you don't use () to call functions.

  • @abdallahdataguy
    @abdallahdataguy2 жыл бұрын

    I like your "...which is insanely cheap" 😂😂

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Ha!

  • @7ash.34
    @7ash.343 жыл бұрын

    That work for me if someone is facibg unicode error try to use r like this root.iconbitmap(r'the place where data is store') It will work

  • @Colaholiker
    @Colaholiker5 ай бұрын

    The iconbitmap() method seems to be a Windows only thing. For those using Linux (and possible MacOS - I don't have access to a Mac to verify this), another way of setting the icon must be taken. It took some effort to figure this out, so I'll share it here. This is the simplest way of doing it, there are more complex ways for multiple-size icons, etc. First, the .ico file format can't be used, so the image should be a PNG file. Then, the following code must be used, assuming that (as we do here), the root window is in a variable called root. root.iconphoto(False, tk.PhotoImage(file='') The file name can be just the image file name if it is in the current working directory during script execution or any absolute or relative path. Not all GUI environments in Linux have the window icon in the top left corner, but this also sets the icon used in the task bar.

  • @Codemycom

    @Codemycom

    5 ай бұрын

    Yes, it's a windows thing

  • @alexportal1985
    @alexportal19854 жыл бұрын

    Is there a way to make the image resize with the window? It would be great to have the image scale reduce of increase with expanding of the window.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Sure, but it's too complicated to discuss in a comment

  • @charleymai5270
    @charleymai52704 жыл бұрын

    I keep getting this problem when I try to change the icon image. So whenever I run from tkinter import * root = Tk() root.title("Images") root.iconbitmap('C:/photos/red.ico') root.mainloop() This error would pop up File "C:\Users\charl\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2071, in wm_iconbitmap return self.tk.call('wm', 'iconbitmap', self._w, bitmap) _tkinter.TclError: bitmap "c:/photos/red.ico" not defined I have the icon in a folder that is inside of the python folder but it keeps giving me this error. Is there any way that I can make this work?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    use lowercase C root.iconbitmap('c:/photos/red.ico')

  • @yogeshrajgure2569
    @yogeshrajgure25693 жыл бұрын

    hey bro , remember that image that u load using PIL .. that is actually loading the image, but the size of window is growing too big to fit the screen, while same size of photo on ur computer is loading a pretty decent image.. may i know why.. by the way it is jpeg/jpg image

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Likely because the image actually IS that big...but when you load it elsewhere on your computer, that thing you load it in resizes it.

  • @aadityasahoo6244
    @aadityasahoo62442 жыл бұрын

    hey john, kudos on making an amzing playlist! coming to my question: im getting an error while doing this ```img = ImageTk.PhotoImage(Image.open(path)) AttributeError: type object 'Image' has no attribute 'open'``` so im chosing path from the askopenfilename method, and then applyiong it here but for some reason it doesnt work. any suggestions? Thanks.

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    did you pip install Pillow and import Image at the top of your file?

  • @aadityasahoo6244

    @aadityasahoo6244

    2 жыл бұрын

    @@Codemycom thanks so much for replying! anyway, yes i did install pillow and import the image, and did everything u did, but for the life of me i cant figute out what it is that ive done wrong!

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    @@aadityasahoo6244 Set it aside for a couple days and look at it with fresh eyes...you probably just misspelled something

  • @vandanapal3011
    @vandanapal30112 жыл бұрын

    how to capture image and import then convert sketch in python can u send source code make button camera and sketch , import from gallery pic

  • @mbn-code
    @mbn-code3 жыл бұрын

    its funny because i came from anothe one of your videos with the calculator and i made my own exit button, then now coming across this video was fun to see how you did it. my code for an exit button: (obviously with a simple gui) btw i am new and i made it so muc more complicated for myself trying o do it from tkinter import * root = Tk() root.title("exit button") root. def function(exit): pass def button_exit(): button_exit = function(exit()) button_exit = Button(root, text="exit", padx=40, pady=20, command=button_exit) button_exit.grid(row=1, column=0, columnspan=1) root.mainloop() but the only thing that worked in this video for me is the exit button the things with the pictures dident work

  • @AshikurRahman-ny9ul
    @AshikurRahman-ny9ul4 жыл бұрын

    Is quit a built-in method for pyCharm IDE?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    The IDE you use is irrelvant...we aren't writing code for an IDE...we're just writing Python code

  • @fayizhalim3145
    @fayizhalim31453 жыл бұрын

    Hei Bro can i ask you a question. I still confused how to make my image appear even though i follow the step by step it won't work. Text like this appear in the Terminal "No such file or directory E:\ (My location file)". I don't know why it won't appear.

  • @fayizhalim3145

    @fayizhalim3145

    3 жыл бұрын

    And fyi i've already installed Pillow Function

  • @DrizztStrife
    @DrizztStrife2 жыл бұрын

    For the icon root.iconbitmap(r'c:\_Python\Icons\icon.ico') I successfully remove the default feather icon, but it is replaced with a blank page icon. I've tried .ico images 512x512 and 256x256- what am I doing wrong?

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    I don't know, but that code doesn't look anything at all like mine. Maybe start there.

  • @kiem2702
    @kiem27023 жыл бұрын

    "SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape" I'm using VSCode and I get this error when I use the full path of both the icon and the image both in and not in the same folder of the python file. But when I put it in the same folder of the python file and only put the relative path, it works. How do I fix this?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Don't use visual code

  • @NamNguyen-um1eu
    @NamNguyen-um1eu3 жыл бұрын

    use 64x64 image can help u fix TCL error maybe (window)

  • @viswamberprasad9418
    @viswamberprasad94184 жыл бұрын

    I used the exact same lines as yours. i stored the icon as ".ico" in the same location(desktop) as my ".py" file,but when i run the code,it raises this error _tkinter.TclError: bitmap "C:/Users/Dell/Desktop/icon.ico" not defined. would really appreciate it if anyone can help me out!

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Is the file a real ico file?

  • @thehappyopossum

    @thehappyopossum

    4 жыл бұрын

    i am having the same issue also, if anyone knows a fix or suggestion to fix this, would be greatly appreciated

  • @viswamberprasad9418

    @viswamberprasad9418

    4 жыл бұрын

    @@thehappyopossum hey bud,just make sure that it is a real .ico file and also that it is in a separate folder with your python file

  • @mrmirchi3647
    @mrmirchi3647 Жыл бұрын

    Just a tip for mac users when installing modules/running code: If pip doesn't work, try pip3 And if python doesn't work try python3

  • @kidredglow2060
    @kidredglow2060 Жыл бұрын

    i installed pillow, but in python, it underlines PIL in red, and also ImageTk, and Image

  • @rahulsailwal4025
    @rahulsailwal40254 жыл бұрын

    Thank you so much. It didn't work for me, but made some tweak to make it work. Old code - img=ImageTk.PhotoImage(Image.open(path)) Tweak i have done - img=ImageTk.PhotoImage(Image.open(path),master=root)

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    whatever works for you

  • @marcmathieutrance6807
    @marcmathieutrance68072 жыл бұрын

    I have encounter an error during the iconbitmap tutorial. the error says: unicodeescape: codec can't decode bytes in position 2-3. I google it and it direct me to stack overflow where I found the solution. prefix the string with (to produce a raw string):

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Glad you got it sorted out

  • @wingsonlai1132
    @wingsonlai11323 жыл бұрын

    5:48 I got an error ---- ModuleNotFoundError: No module named "PIL". It seems like I have not installed PIL or/and Pillow. Google tells me that I need to install either PIL or Pillow. However, google also said that both cannot co-exist. How can I know what's the best way to get the image job done for python? My laptop/python/pycharm info: Windows 10 Dell Inspiron 5590 PyCharm 2020.2.1 (Community Edition) Python 3.8.3

  • @100jsj6

    @100jsj6

    2 жыл бұрын

    go to command prompt and do : pip install pillow

  • @talefraim8118
    @talefraim81182 жыл бұрын

    Thank you so much. I can see the icon while running my code on windows. but, when i'm trying to run it on Linux, the main window is appearing without the icon, what can be the reason to that?

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Windows icon files don't work on linux. You have to google linux icons for the solution

  • @funnyanimalworld7579
    @funnyanimalworld75794 жыл бұрын

    how to resize image button on a grid when you resize window of a program.i know how to resize a button but not a text or image on a button ,those stay the same

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Complicated topic...I'll do some videos on it eventually.

  • @funnyanimalworld7579

    @funnyanimalworld7579

    4 жыл бұрын

    Thank you

  • @tristangwithian4010
    @tristangwithian40102 жыл бұрын

    For those of you using Windows 10 and Idle (and I know Mr Elder says not to use Idle because it sucks!) who get the 'no module named PIL' error, I looked at lots of Google hits on this and tried a few things but eventually found I didn't get the error when simply running from the command line ('python images.py). It turns out I was running a version of idle from an earlier version of Python - Windows had simply bookmarked the old one so when I typed idle it suggested the old one. So, I found the version of idle commensurate with the version of python I'm running, which happens to be 3.9.7 and ran that instead (look for the file idle.py). If you don't know what version of python you are running, at the command line run simply 'python' and it will tell you the version (ok, this assumes you have python added to your 'path' environment variable, which is another topic). I'm rambling but in short, make sure you are running the version of Idle corresponding to the latest version of python you have installed.

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Or just don't use idle

  • @crazyamygdala
    @crazyamygdala4 жыл бұрын

    Hi! Thank you for the tutorial.Built calculator succefully. Working on the image module. Getting this error: AttributeError: module 'PIL.ImageTk' has no attribute 'Photoimage'. Googling isn't helping either. Working on python 3.7, PIL version 5.4.1, used syntax ' similar to yours. Help in this regard would be highly appreciated

  • @crazyamygdala

    @crazyamygdala

    4 жыл бұрын

    Tried on IDLE and Spyder

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    The i in Image needs to be capitalized

  • @crazyamygdala

    @crazyamygdala

    4 жыл бұрын

    @@Codemycom Thanks! Distracted mind = loss of situational awareness! Ha ha...Stay safe

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    @@crazyamygdala Happens to me allllll the time!

  • @VanoTitov
    @VanoTitov4 жыл бұрын

    hello. can I take in my program not image, and python file?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Sorry, I don't understand

  • @yashdeore473
    @yashdeore4733 жыл бұрын

    genius

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Thanks!

  • @douglasmonteiro3085
    @douglasmonteiro30854 жыл бұрын

    Hi, I am getting the error : No module named 'PIL'. I have installed Pillow. and trying the other tips from stackoverflow/google. Do you have any Idea of what it can be?

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    It could be a bunch of different things. Google "No module named 'PIL'" and you'll find a bunch of things to try...try em all till one works :-p

  • @douglasmonteiro3085

    @douglasmonteiro3085

    4 жыл бұрын

    @@Codemycom Hi Jhon I have spent the last week going over and over this error and I cannot figure it out haha, I have uninstalled and installed python again following the right procedure. unfortunately it still doesn't work. But I am stubborn haha. one question, when u do pip freeze you get a bunch of things installed, do they have any relation with this program? Also, if I have Image and Pillow installed can it be a problem ? I have tried them together, one or another by itself, but still nothing haha.

  • @douglasmonteiro3085

    @douglasmonteiro3085

    4 жыл бұрын

    @@Codemycom After a long week trying different things, what has finally worked for me was...changing the editor. I was using pycharm and nothing worked out. with Atom things finally worked. finally I can keep going with the tutorial hahaha

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    @@douglasmonteiro3085 Awesome! Yeah I don't like pyCharm personally. I stick with Sublime Text and I never have a problem.

  • @EGGFRENZY2015
    @EGGFRENZY20153 жыл бұрын

    how would you set the image in the top right? so it is always in the top right?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    maybe check the video I have on status bars..it shows how to put stuff in the bottom right, and you can modify that