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

  Рет қаралды 317,350

Codemy.com

Codemy.com

Күн бұрын

Пікірлер: 756
@Codemycom
@Codemycom 4 жыл бұрын
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My KZbin 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 4 жыл бұрын
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 3 жыл бұрын
@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 3 жыл бұрын
@@100jsj6 You probably aren't using a real icon file.
@100jsj6
@100jsj6 3 жыл бұрын
@@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
@prakulsingla1363 3 жыл бұрын
This is the best playlist I can find on python GUI. Amazing.
@Codemycom
@Codemycom 3 жыл бұрын
Thanks! Glad you like it!
@Phizzo4real
@Phizzo4real 2 жыл бұрын
I have been going thru and learning a ton...
@rajofficialjadhav2642
@rajofficialjadhav2642 10 күн бұрын
You are one of best coder
@cbaymac
@cbaymac 4 жыл бұрын
One of the best instructors on KZbin. Your explanations and format are great. I am going to sign up for your full program. Thanks for all your hard work.
@marisko16
@marisko16 4 жыл бұрын
Man, you are explaining things just the way I would do. Perfect, thank you very much.
@Codemycom
@Codemycom 4 жыл бұрын
Glad you're enjoying it!
@myselfsohit
@myselfsohit 4 жыл бұрын
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!
@Zachomara
@Zachomara 4 жыл бұрын
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
@greatindianbuilder2491
@greatindianbuilder2491 3 жыл бұрын
Thanks for vid, really help. I feel so lucky that I have access to so much information(and tutorials) without any charge.
@alwayscubing8200
@alwayscubing8200 3 жыл бұрын
Hey buddy, so awesome...very useful. I have been searching tkinter gui tutorials and fortunately, i found u😃😃
@Codemycom
@Codemycom 3 жыл бұрын
Glad you did
@keymediastudioitself
@keymediastudioitself 4 жыл бұрын
To avoid resizing put: # app = your root app.resizable(width=False, height=False)
@tomabrasoveanu
@tomabrasoveanu 3 жыл бұрын
how do i tell what my root is?
@100jsj6
@100jsj6 3 жыл бұрын
@@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 3 жыл бұрын
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
@TahmidulAzomSany
@TahmidulAzomSany 3 жыл бұрын
Those who are getting delayed by the exit button: You can use root.destroy instead of root.quit
@ayaallahibrahimabdel-razek7971
@ayaallahibrahimabdel-razek7971 3 жыл бұрын
thanks that really helped me but why didn't root.quit work ?🤔
@daniyalmalik9441
@daniyalmalik9441 3 жыл бұрын
Thankyou Man
@marcmathieutrance6807
@marcmathieutrance6807 2 жыл бұрын
@@ayaallahibrahimabdel-razek7971 maybe its kind of deprecated or something
@aaronhojnacki6051
@aaronhojnacki6051 2 жыл бұрын
Thank you
@jorgearmandoperez1450
@jorgearmandoperez1450 4 жыл бұрын
Man you are my new favorite hero! thanks!
@Codemycom
@Codemycom 4 жыл бұрын
Wow, thanks!
@ozbekchawindows4236
@ozbekchawindows4236 4 жыл бұрын
You are so good... You are my hero! You know everything in Python...
@Codemycom
@Codemycom 4 жыл бұрын
Ha, hardly everything...but thanks!
@ashrsfsiliman452
@ashrsfsiliman452 4 жыл бұрын
Great job deserving of thanks عمل رائع يستحق الشكر
@Capsaicinophile
@Capsaicinophile 2 жыл бұрын
Walter White teaches Tkinter like a boss.
@harshwardhanshirodkar769
@harshwardhanshirodkar769 4 жыл бұрын
@Codemy.com is there a way we can change the taskbar icon for the file too?
@Codemycom
@Codemycom 4 жыл бұрын
no
@OsiRixxx
@OsiRixxx 3 жыл бұрын
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 3 жыл бұрын
No it won't, unless you send them the images too.
@marcususa
@marcususa 8 күн бұрын
Is there a way to position the images? Like have N, E, W, S (north east west south) where one image is not right next to another or right above?
@SpinnTV
@SpinnTV 4 жыл бұрын
is there a way to use font awsome with python desktop app
@Codemycom
@Codemycom 4 жыл бұрын
No clue, sorry
@yogeshwarns3821
@yogeshwarns3821 2 жыл бұрын
Sir.what is the compiler u are using??
@suryadev2207
@suryadev2207 2 жыл бұрын
Pycharm
@amankumarbairagi794
@amankumarbairagi794 4 жыл бұрын
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
@bigstrib
@bigstrib Ай бұрын
I know this is 5 years old it did not quite display what I was looking for.. I do not quite know python and am using AI to help me..I am trying to import font awesome icons...I guess it could be something like "from font_awesome_icons import FontAwesome" it does not seem to work. Do you know of an import that will import icons? I will still look around at other videos..In my code it shows little boxes where the icons should be but it is just not grabbing the icons. I am wondering if importing icons were possible or if I have to save all icons and do it that way.. Thanks.
@Eulers_identity132
@Eulers_identity132 9 ай бұрын
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 9 ай бұрын
yeah
@Hyvexx
@Hyvexx 4 жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
Codemy.com Oh ok
@yashar696
@yashar696 4 жыл бұрын
Thanks it was great & very useful♥♥
@Codemycom
@Codemycom 4 жыл бұрын
You're welcome 😊
@raniduharshana5238
@raniduharshana5238 4 жыл бұрын
Thank you very much. I learnt a lot about tkinter. 🤭❤️
@Codemycom
@Codemycom 4 жыл бұрын
Glad it was helpful!
@nihalthannegedarapremaratn2352
@nihalthannegedarapremaratn2352 4 жыл бұрын
Very helpful. Thanks you..... Hope continue.....
@Codemycom
@Codemycom 4 жыл бұрын
Glad you liked it...there's like 50 more videos in this playlist
@Colaholiker
@Colaholiker 10 ай бұрын
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 10 ай бұрын
Yes, it's a windows thing
@pragunashok6008
@pragunashok6008 4 жыл бұрын
when i try to add an icon, it gives error tkinter.Tclerror: bitmap "" is not defined
@espanolparatodos7758
@espanolparatodos7758 4 жыл бұрын
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 3 жыл бұрын
THAT IS THE EXACT SAME THING HAPPENING WITH ME @Peter Rezkalla i'll try that thanks
@ndvz8672
@ndvz8672 3 жыл бұрын
Whats going on John! LOVE the content. Youre awesome, thank you!
@Codemycom
@Codemycom 3 жыл бұрын
thanks!
@fsldr
@fsldr 7 ай бұрын
thanks a lot man!
@Codemycom
@Codemycom 7 ай бұрын
Welcome!
@Harish-ou4dy
@Harish-ou4dy 4 жыл бұрын
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 4 жыл бұрын
@@Codemycom Then what do you suggest?
@infinitespace1982
@infinitespace1982 4 жыл бұрын
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 4 жыл бұрын
@@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 4 жыл бұрын
@@infinitespace1982 Not admitting that he has maybe make a mistake
@elysonpanolino7522
@elysonpanolino7522 2 жыл бұрын
How can I resize the image?
@Codemycom
@Codemycom 2 жыл бұрын
Check the playlist, I have videos on that.
@AshikurRahman-ny9ul
@AshikurRahman-ny9ul 4 жыл бұрын
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
@harryman3347
@harryman3347 4 жыл бұрын
I done the same as 2:45 But it says can't deode bytes untruncated
@Codemycom
@Codemycom 4 жыл бұрын
Check your code for typos
@diyankalaydzhiev7517
@diyankalaydzhiev7517 3 жыл бұрын
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
@victorvlog261
@victorvlog261 Жыл бұрын
hi sir, at 2:59, when I run the program, it doesnt show the chosen icon on the left top, it just showed the white file icon. i do not know why it happened. Can you help me about it please. Thank you
@Codemycom
@Codemycom Жыл бұрын
What did you do differently from the video? Do you have the icon file on your computer in the correct location?
@victorvlog261
@victorvlog261 Жыл бұрын
@@Codemycom I follow step by step from your video. I copied the path of the direction of the photo so I do not think it’s wrong.
@Codemycom
@Codemycom Жыл бұрын
@@victorvlog261it would work if it wasn't wrong... you have a typo or error of some sort.
@victorvlog261
@victorvlog261 Жыл бұрын
@@Codemycom How to get the icon like yours?
@Codemycom
@Codemycom Жыл бұрын
you could download it from my github, or use any icon you want. It's not really important at all. You can leave it off completely if you want@@victorvlog261
@sirvex7514
@sirvex7514 10 ай бұрын
im gonna be honest mr heisenberg you look extremely cute with the doggo
@Codemycom
@Codemycom 10 ай бұрын
Ha thanks
@drednot57
@drednot57 4 жыл бұрын
In Linux, one has to do this to put an icon in the title bar: import tkinter as tk root = tk.Tk() root.title('CharDB: PC Record Database App') root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file='chardb-gui.png')) root.geometry("1152x648") In Linux the iconbitmap() call can only use the XBM image format due to limitations of X-Windows system. XBM is a binary color format -- on or off, so images must be in B&W; no grey-scale or colors. Thus one needs to use a PhotoImage() call to put a custom icon in the title bar.
@Codemycom
@Codemycom 4 жыл бұрын
Good tip!
@borgyoh
@borgyoh 5 жыл бұрын
at around 4:19 when you tested the quit button, i copied exactly what you types minus the image of course and my button shows up but it wont click. im using a mac btw.
@Codemycom
@Codemycom 5 жыл бұрын
you might have a typo that you aren't noticing. Let me see your code..
@borgyoh
@borgyoh 5 жыл бұрын
@@Codemycom not sure how i can show you without a screen shot. i copied your verbatim exactly. the button shows up but when i click , it doesnt do anything. i also had a problem with getting the image to show up in the window. ithe error is a "file not found" as in the location of the image file. i assume things are different on a mac. i copy the exact file address of the image and still get an error.
@Codemycom
@Codemycom 5 жыл бұрын
​@@borgyoh you could copy and paste the code here
@borgyoh
@borgyoh 5 жыл бұрын
@@Codemycom from tkinter import * from PIL import ImageTk , Image root = Tk() root.title("buttons and images") #skipped icon on header button_quit = Button(root, text= "exit program" , command = root.quit) button_quit.pack() root.mainloop()
@Codemycom
@Codemycom 5 жыл бұрын
@@borgyoh in your button command, try comand = root.destroy. If that doesn't work, try import sys #at the top of your program button_quit = Button(root, text= "exit program" , command=sys.exit) if that doesn't work, still import sys, but create a function called quit import sys #at the top of your program def quit(): sys.exit() and call command=quit from your button
@theepicguy6575
@theepicguy6575 4 жыл бұрын
Legend says this is series is epic
@Codemycom
@Codemycom 4 жыл бұрын
Ha thanks!
@God_OfGame
@God_OfGame 2 ай бұрын
very very nice❣❣❣
@Codemycom
@Codemycom 2 ай бұрын
thanks
@muhammadakmalmaulanarizqy7807
@muhammadakmalmaulanarizqy7807 4 жыл бұрын
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
@mikhailkevin2505
@mikhailkevin2505 2 жыл бұрын
good afternoon sir, i want to ask something about tkinter, can we display terminal python with it?
@michaelvidanes6629
@michaelvidanes6629 2 жыл бұрын
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.
@well1049
@well1049 2 жыл бұрын
Amazing, but how you make a button for user to add an image or file?
@Codemycom
@Codemycom 2 жыл бұрын
add an image or file to what?
@Franco-rd8du
@Franco-rd8du 4 жыл бұрын
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!
@ritajbhosale6816
@ritajbhosale6816 5 жыл бұрын
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 5 жыл бұрын
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.
@namanchhibbbar2205
@namanchhibbbar2205 4 жыл бұрын
you are really awesome, highly appreciate your work
@Codemycom
@Codemycom 4 жыл бұрын
Thank you! I appreciate that!
@vik0_052
@vik0_052 4 жыл бұрын
is there a way to make a back/reverse button in tkinter?
@Codemycom
@Codemycom 4 жыл бұрын
Sure...it just depends what you want to go back on
@vik0_052
@vik0_052 4 жыл бұрын
@@Codemycom Sir did you make a video for it, I have been searching through your series but I couldn't find any?
@talefraim8118
@talefraim8118 2 жыл бұрын
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
@preityvasudevankondath1731
@preityvasudevankondath1731 4 жыл бұрын
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
@onio1
@onio1 2 жыл бұрын
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
@elchinefa9524
@elchinefa9524 4 жыл бұрын
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 4 жыл бұрын
Yes, you can make them into exe files. Check the playlist, I have a video on that
@elchinefa9524
@elchinefa9524 4 жыл бұрын
@@Codemycom Thanks a lot, i'll check it tomorrow.
@coolgames22ismyname95
@coolgames22ismyname95 4 жыл бұрын
Hello, I have a question if you could please help me I would be thankful, at 4:26 I have written the code as exactly as I could but it just doesn't work it says. "Python not responding"
@Codemycom
@Codemycom 4 жыл бұрын
What's the full exact error message?
@coolgames22ismyname95
@coolgames22ismyname95 4 жыл бұрын
@@Codemycom Thanks for the reply. First of all, this is the code I wrote: from tkinter import * root = Tk() root.title('blah') button_quit = Button(root, text="Exit program",command=root.quit) button_quit.pack() root.mainloop() The error message is: "Python is not responding" and it shows me two option that are to report the problem to microsoft or close the program Also just a edit i write all this is jupyter
@100jsj6
@100jsj6 3 жыл бұрын
@@coolgames22ismyname95 that error is of ur pc . its slow maybe... yeah thats definitely it . and if root.quit dont work try command = bleh def bleh(): root.destroy()
@tablesawart2728
@tablesawart2728 2 жыл бұрын
At 4:16 when I click, program crash... The button REMAINS PRESSED and I am forced to stop by clicking on the red x at the top right... I'm using Spyder IDE. I repeatedly checked the code, and it turns out absolutely identical. I don't know how to proceed... 😵‍💫
@Codemycom
@Codemycom 2 жыл бұрын
No, it's not absolutely identical. Check it again, there is an error.
@loicmahe2430
@loicmahe2430 5 жыл бұрын
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 = ...)
@daggercentral9818
@daggercentral9818 3 жыл бұрын
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
@Jumbjetsky
@Jumbjetsky 2 жыл бұрын
I have a hard time putting all this together to obtain what i need. I want the following: 1. click on icon open a window. 2. Window contains button or drop down, for "open file" to browse for a file containing txt/csv data 3. when file is opened, the pathway is obtained 4. A button with a built in function runs an analysis on the data. And visualizations are displayed for quality control check. 5. Button to submit data to a database I want all of the above to be on 1 window, even when data is displayed. But i cannot figure out whether tkinter can do that. I have only figured out to do this in a series of events composed of several windows which are opened, then closed for the next window to appear. Hope you can help
@Codemycom
@Codemycom 2 жыл бұрын
Yeah, there's nothing to all of that. I have videos on pretty much all of that in this playlist.
@Spacekriek
@Spacekriek 11 ай бұрын
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 11 ай бұрын
But when adding something happens in 10 seconds, for free...why does that bother you?
@Spacekriek
@Spacekriek 11 ай бұрын
@@Codemycom Just a work in progress, then. :)
@katmanduYT
@katmanduYT 4 жыл бұрын
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?
@vexinity5151
@vexinity5151 3 жыл бұрын
Such a legend, oh my gosh.
@Codemycom
@Codemycom 3 жыл бұрын
Ha thanks
@Dnxkdex
@Dnxkdex 4 жыл бұрын
I’m using a chromebook to do my coding in, however i can’t find the location/ direct path of my ico file, is there any videos you can direct me to that will help resolve this problem
@Codemycom
@Codemycom 4 жыл бұрын
Yeah, I don't know how you can use a chromebook with tkinter
@aadityasahoo6244
@aadityasahoo6244 3 жыл бұрын
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 3 жыл бұрын
did you pip install Pillow and import Image at the top of your file?
@aadityasahoo6244
@aadityasahoo6244 3 жыл бұрын
@@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 3 жыл бұрын
@@aadityasahoo6244 Set it aside for a couple days and look at it with fresh eyes...you probably just misspelled something
@kenshin7440
@kenshin7440 Жыл бұрын
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 Жыл бұрын
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😢😢😢😢😢
@wingsonlai1132
@wingsonlai1132 4 жыл бұрын
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 3 жыл бұрын
go to command prompt and do : pip install pillow
@EGGFRENZY2015
@EGGFRENZY2015 3 жыл бұрын
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
@ehsam8202
@ehsam8202 2 жыл бұрын
if i wanted to randomly select 1 image from a bunch of images how would i go upon doing that
@Codemycom
@Codemycom 2 жыл бұрын
Add them all to a list and randomly select an item from the list in the normal way: random.choice(yourlist)
@crossfarm4146
@crossfarm4146 4 жыл бұрын
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.
@viswamberprasad9418
@viswamberprasad9418 4 жыл бұрын
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
@focusfail.
@focusfail. 4 жыл бұрын
Hello, I have got a problem. I am getting an error wich sais "No module named" PIL" I have already reinstalled Pillow multiple times.
@harshwardhanshirodkar769
@harshwardhanshirodkar769 4 жыл бұрын
I got a similar error , while I was able to download pillow library using pip I kept getting an error, I finally found a solution on stack overflow that just required me to update path variables. stackoverflow.com/questions/44515769/conda-is-not-recognized-as-internal-or-external-command in case anyone wants to refer to it
@afonsofraguas1145
@afonsofraguas1145 4 жыл бұрын
try this before "python -m pip install --upgrade pip"
@emanuelshemesh
@emanuelshemesh 4 жыл бұрын
whn i try to run the pogram it says photoimage' object has no attribute '_photoimage__photo' any ideas what i should do??
@mariannagladysz5191
@mariannagladysz5191 3 жыл бұрын
Is it possible that command=root.quit doesn't work on Mac?
@Codemycom
@Codemycom 3 жыл бұрын
it doesn't work in IDLE...but you shouldn't be using IDLE anyway
@digiajay
@digiajay 3 жыл бұрын
This is cool and I can update the icon on the window title. How can we update the icon on taskbar?
@Codemycom
@Codemycom 3 жыл бұрын
It's the same icon
@AJ-vw2cm
@AJ-vw2cm 3 жыл бұрын
@@Codemycom Yes, I just noticed that when I debug in the VS code it shows python icon in taskbar, however after building to executable, the exe picked up the icon
@rawanalsubhi6620
@rawanalsubhi6620 4 жыл бұрын
How I can Re size the image ?
@Codemycom
@Codemycom 4 жыл бұрын
Try using height and width attributes...or use photoshop
@rawanalsubhi6620
@rawanalsubhi6620 4 жыл бұрын
@@Codemycom how I can use height and width I tried to use (padx and pay) with frame but it dose not work
@vic-san12
@vic-san12 3 жыл бұрын
I love your videos. I learned a lot from them. More power to you!
@Codemycom
@Codemycom 3 жыл бұрын
Thanks!
@aravind.m6266
@aravind.m6266 Жыл бұрын
am using grid system, if i click the exit button the gui is not automatically closing can u hel me?
@Codemycom
@Codemycom Жыл бұрын
Has nothing to do with the grid system. You likely have a typo or did something different from the video. Try root.quit()
@aravind.m6266
@aravind.m6266 Жыл бұрын
@@Codemycom thank u, but its working but its asking do you want to kill the program and when i click yes then only its closing
@aravind.m6266
@aravind.m6266 Жыл бұрын
its working on visual studio code but not in python idle but thank u so much
@funnyanimalworld7579
@funnyanimalworld7579 4 жыл бұрын
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
@mrmirchiTheCodGuy
@mrmirchiTheCodGuy 2 жыл бұрын
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
@TahmidulAzomSany
@TahmidulAzomSany 3 жыл бұрын
having problem adding icon in LINUX. It's showing TclError: bitmap "/home/tasanyphy/Desktop/lens.ico" not defined
@Codemycom
@Codemycom 3 жыл бұрын
You can't use icons on linux, those are windows things
@TahmidulAzomSany
@TahmidulAzomSany 3 жыл бұрын
Can you please help me out with this things!? I'm already stuck here. And can't move further!
@Codemycom
@Codemycom 3 жыл бұрын
@@TahmidulAzomSany No sorry, I don't have videos on using icons with linux. Remove the icon line in your code, you don't have to add an icon, and move on.
@parsabahrambeik4381
@parsabahrambeik4381 4 жыл бұрын
Hi, thank you very much for your video. You helped me a lot with the database. AND.....
@Codemycom
@Codemycom 4 жыл бұрын
Happy to help!
@emeine8759
@emeine8759 4 жыл бұрын
how to put the Button on the image or background ??? and to make ii transparent
@Codemycom
@Codemycom 4 жыл бұрын
Check my playlist, I go over that
@vik0_052
@vik0_052 4 жыл бұрын
how can I print the output only once if I click a button widget?
@Codemycom
@Codemycom 4 жыл бұрын
Run an if statement in the function to see if the output has been printed already
@thecobra8508
@thecobra8508 3 жыл бұрын
how do i get a better quality icon when i run the gui?
@Codemycom
@Codemycom 3 жыл бұрын
Make one with editing software like photoshop or buy one
@thecobra8508
@thecobra8508 3 жыл бұрын
@@Codemycom i dont have photoshop oof but thanks
@100jsj6
@100jsj6 3 жыл бұрын
@@thecobra8508 try using inkscape ... maybe
@ritusree05
@ritusree05 4 жыл бұрын
Sir I use python idle for my tkinter projects. I used the same as you to add exit button to the tkinter window, but the code didn't work . It just brought up a button with the text and no function at all. I was sure I provided the quit function to it with the exact code as you. Can I get a help from you?
@Codemycom
@Codemycom 4 жыл бұрын
Don't use idle
@ritusree05
@ritusree05 4 жыл бұрын
@@Codemycom Does idle not support certain function? Or is not there some other way to perform the exit button function?
@Codemycom
@Codemycom 4 жыл бұрын
@@ritusree05 It's idle...why would you use it?
@ritusree05
@ritusree05 4 жыл бұрын
@@Codemycom OK then.... I will try not to use it any more. Thank you sir.
@100jsj6
@100jsj6 3 жыл бұрын
@@ritusree05 sir u can try using root.destroy in built function instead
@DrizztStrife
@DrizztStrife 3 жыл бұрын
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 3 жыл бұрын
I don't know, but that code doesn't look anything at all like mine. Maybe start there.
@marcmathieutrance6807
@marcmathieutrance6807 2 жыл бұрын
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
@pratibhasanvatsarkar4816
@pratibhasanvatsarkar4816 4 жыл бұрын
Hello sir, I want to add content or text on image....how can i do that ....plz tell me
@romainserieys8803
@romainserieys8803 4 жыл бұрын
hi, i'm having the same issue. Any solution yet?
@Codemycom
@Codemycom 4 жыл бұрын
@@romainserieys8803 May look at that one day
@romainserieys8803
@romainserieys8803 4 жыл бұрын
@@Codemycom Finally found out, now i'm stuggling with adding a button on my image ^^
@Codemycom
@Codemycom 4 жыл бұрын
@@romainserieys8803 don't add a button to your image, add an image to your button.
@romainserieys8803
@romainserieys8803 4 жыл бұрын
Codemy.com why? I did it anyway ^^ thanks for replying
@BRUH-hv5yt
@BRUH-hv5yt 2 жыл бұрын
10:01 "Its just that easy"
@notanamehere8355
@notanamehere8355 3 жыл бұрын
I am trying to show the image on a separate window but when I try to set the window for the image to show code: bgimage = ImageTk.PhotoImage(Image.open("CTNBG.png")) bglabel = Label(abctn, image=bgimage) bglabel.place(x=0,y=0) it gives me an error : _tkinter.TclError: image "pyimage1" doesn't exist I have 2 windows one named root and one named abctn How can I fix this?
@Codemycom
@Codemycom 3 жыл бұрын
I have videos on the playlist that talk about images on other windows, you need to make them global to avoid tkinter garbage handlers.
@notanamehere8355
@notanamehere8355 3 жыл бұрын
@@Codemycom oh thanks for replying. I found what the problem was, I needed to make the image's master the second window. I really like your tutorials, great way to start python again after 1 year
@anabelsa
@anabelsa 3 жыл бұрын
Please, notice that the PIL import statements must go after the tkinter import. Otherwise, you will get some errors.
@Codemycom
@Codemycom 3 жыл бұрын
I’m not sure that’s the case.
@anabelsa
@anabelsa 3 жыл бұрын
@@Codemycom Well, I am, because I placed the PIL import before and got an error. I found the reason somewhere, only now I cannot find it back.
@ShaiS0
@ShaiS0 4 жыл бұрын
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.
@vandanapal3011
@vandanapal3011 2 жыл бұрын
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
@TakeMorePics
@TakeMorePics 4 жыл бұрын
Im following the instructions perfectly, but cant seem to get the icon part to work. I am on Ubuntu 18. The icon I have is called Chrome.ico and is in the same directory as the program that is calling it. I even tried the entire path to the .ico file, and that doesnt work either. from tkinter import * root = Tk() root.title('Learn To Code at Codemy.com') root.iconbitmap('Chrome.ico') root.mainloop() and I get the error: tkinter.TclError: bitmap "Chrome.ico" not defined
@Codemycom
@Codemycom 4 жыл бұрын
Icon files don't work on ubuntu.. you need an xbm file and must append it with a @ sign (I think) root.iconbitmap('@/home/whatever/Chrome.xbm') or something like that...
@TakeMorePics
@TakeMorePics 4 жыл бұрын
@@Codemycom how do you know all this stuff? Thanks!
@Codemycom
@Codemycom 4 жыл бұрын
@@TakeMorePics lol no idea, haha
@FRIENDSofCAP
@FRIENDSofCAP 5 жыл бұрын
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 5 жыл бұрын
Check this out for your answer... stackoverflow.com/questions/33134594/set-tkinter-python-application-icon-in-mac-os-x
@bibfocal
@bibfocal Жыл бұрын
I found this to work on Linux if anyone has trouble with the icon.ico. Use a .gif instead. # Adding icon image in Linux img = PhotoImage(file="images/icon.gif") root.tk.call('wm', 'iconphoto', root._w, img)
@evenvonschemde8746
@evenvonschemde8746 4 жыл бұрын
After i have installed Pillow it still says "No module named 'PIL'" when i try running the program. Someone help?
@safalkumarsinha5110
@safalkumarsinha5110 4 жыл бұрын
Have you installed PILLOW?
@adityasagar9078
@adityasagar9078 4 жыл бұрын
same problem ,I installed pillow but it says no module PIL available
@bahnus6312
@bahnus6312 3 жыл бұрын
If you use “studio visual code” i Can help you guys
@kiem2702
@kiem2702 3 жыл бұрын
"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
@selinsabrcan2848
@selinsabrcan2848 3 жыл бұрын
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
@fentonmsu 4 жыл бұрын
Wonderful, still using windoa 8.1
@Codemycom
@Codemycom 4 жыл бұрын
ouch lol
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Tkinter Course - Create Graphic User Interfaces in Python Tutorial
5:37:31
freeCodeCamp.org
Рет қаралды 3,3 МЛН
Python Tkinter GUI Design Using ttkbootstrap - Complete Course
3:23:58
freeCodeCamp.org
Рет қаралды 348 М.
Using tkinter with classes
28:23
Atlas
Рет қаралды 74 М.
Using images in tkinter [ including how to scale them ]
31:57
Adding Frames To Your Program - Python Tkinter GUI Tutorial #11
9:00
Build A Simple Calculator App - Python Tkinter GUI Tutorial #5
18:05
Treeview - Python Tkinter GUI Tutorial #116
20:21
Codemy.com
Рет қаралды 142 М.
Open Files Dialog Box - Python Tkinter GUI Tutorial #15
12:34
Codemy.com
Рет қаралды 195 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН