Open Files Dialog Box - Python Tkinter GUI Tutorial #15

  Рет қаралды 190,247

Codemy.com

Codemy.com

Күн бұрын

How to use Open Files Dialog Box in Tkinter and Python. In this video I'll show you how to open files with the filedialog box:
root.filename = filedialog.askopenfilename(initialdir="/", title="Select A File", filetypes=(("jpg files", "*.jpg"),("all files", "*.*")))
In this series I'll show you how to create graphical user interfaces for Python with Tkinter.
✅ 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 KZbin Channel:
bit.ly/2IGzvOR
▶️ Learn to Code at Codemy.com
Take $22 off with coupon code: youtube

Пікірлер: 324
@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
@100jsj6
@100jsj6 2 жыл бұрын
i love your tutorial series soo much coz i tried to use dropdown but i didnt understand it from the documentation , but now i understand thanks to ur series !!!
@Codemycom
@Codemycom 2 жыл бұрын
@@100jsj6 Glad you like it!
@deltadeveloperr
@deltadeveloperr Жыл бұрын
i made a file location finder app with this video. thank you!
@Codemycom
@Codemycom Жыл бұрын
@@deltadeveloperr awesome
@tristangwithian4010
@tristangwithian4010 3 жыл бұрын
Thanks for leaving errors in your videos so we can see you calmly identify and fix them. Great to see some humility but most importantly teaching that errors are just part of development work and can be easily fixed.
@Codemycom
@Codemycom 3 жыл бұрын
I appreciate that!
@agrimpuriya2585
@agrimpuriya2585 3 жыл бұрын
This was the most useful video yet. Great content John!
@Codemycom
@Codemycom 3 жыл бұрын
Glad it was helpful!
@9MRantu
@9MRantu 3 жыл бұрын
Thanks John! I've been learning A LOT from your videos from scratch! I'm not a programmer, just curious and trying to apply something to my job! Thanks for your dedication!! I'll put an issue here that I had to troubleshoot, in case it happens to another one. When using this, I had this error: codecs.charmap_decode(input,self.errors,decoding_table)[0] and something about an encoding error - I finally solved it by putting a second code line (right after getting root.filename), and put: root.filename = root.filename.name - then it just took the location, but not the encoding option Thanks again!
@TheChrissiepie
@TheChrissiepie 5 ай бұрын
Thank you! Spent 20 minutes trying to figure out the problem before checking the comments section 🙄
@Omega-ll4tx
@Omega-ll4tx Жыл бұрын
You have the best channel on the internet. The way you teach is unprecedented the scope of these projects make students want to learn the boring theory in textbooks because its being applied in real time w/ real world application. Thank you.
@Codemycom
@Codemycom Жыл бұрын
Thanks! I appreciate it!
@dylancampbell6433
@dylancampbell6433 2 жыл бұрын
I had no idea about filedialogs before this video, WOW. I have just been manually iterating through folders this entire time :( best video by far.
@Codemycom
@Codemycom 2 жыл бұрын
Glad I could help!
@petitfrapo
@petitfrapo 2 жыл бұрын
That photo with your dog is literally the brand image of the playlist, gotta love how cute your dog is!!
@Codemycom
@Codemycom 2 жыл бұрын
ha
@tieuwest
@tieuwest 2 жыл бұрын
Thanks. I really enjoy this and find this super helpful.
@Codemycom
@Codemycom 2 жыл бұрын
Glad to hear it!
@2noiembrie83
@2noiembrie83 Жыл бұрын
Loved every minute of it!
@Codemycom
@Codemycom Жыл бұрын
Thanks!
@muhammetgylyjov9288
@muhammetgylyjov9288 5 жыл бұрын
I am in love with your tutorials. If I were tutorial I would ask to marry your tutorials 😊
@Codemycom
@Codemycom 5 жыл бұрын
Awesome!
@thengakola6217
@thengakola6217 3 жыл бұрын
simp
@isuruprasaddilhara6771
@isuruprasaddilhara6771 2 жыл бұрын
Best tutorial I have ever seen ❤
@Codemycom
@Codemycom 2 жыл бұрын
Thanks!
@vantuantran225
@vantuantran225 Жыл бұрын
Straight to the problem, I love it
@Codemycom
@Codemycom Жыл бұрын
happy to hear it
@SammarpanDasguptaOfficial
@SammarpanDasguptaOfficial 3 жыл бұрын
You are a genius teacher.....truly......I get confidence from your lectures......love you from India.
@Codemycom
@Codemycom 3 жыл бұрын
Thank you so much! I appreciate that!
@shreyashchoudhary4576
@shreyashchoudhary4576 3 жыл бұрын
Great! Really Helpful
@Codemycom
@Codemycom 3 жыл бұрын
Glad you liked it!
@radhatiwari1211
@radhatiwari1211 5 жыл бұрын
Great explanation 👍
@Codemycom
@Codemycom 5 жыл бұрын
Thanks!
@siddharthrawat7205
@siddharthrawat7205 4 жыл бұрын
Really helpful. subbed
@Codemycom
@Codemycom 4 жыл бұрын
Thanks!
@totolariflette
@totolariflette 2 жыл бұрын
Thank you so much, you saved my day
@Codemycom
@Codemycom 2 жыл бұрын
Glad I could help!
@cristianoz930
@cristianoz930 2 ай бұрын
I love you bro ❤❤❤❤❤❤ thx for all these videos
@Codemycom
@Codemycom 2 ай бұрын
Welcome!
@iamzareef
@iamzareef 3 жыл бұрын
Thanks sir! you just saved my day
@Codemycom
@Codemycom 3 жыл бұрын
Happy to hear it!
@tejasgorivale425
@tejasgorivale425 4 жыл бұрын
john you are great man hats off _/\_
@Codemycom
@Codemycom 4 жыл бұрын
Thank you!
@NEXC
@NEXC 3 жыл бұрын
youtube coupon code is huge discount! thank for you bro
@Codemycom
@Codemycom 3 жыл бұрын
Welcome!
@mission_and_purpose
@mission_and_purpose 2 жыл бұрын
Thank you very much! that helped me!
@Codemycom
@Codemycom 2 жыл бұрын
Happy to hear it!
@minhhoangnhat7331
@minhhoangnhat7331 3 жыл бұрын
Thanks for your videos
@Codemycom
@Codemycom 3 жыл бұрын
Glad you like them!
@parsabahrambeik4381
@parsabahrambeik4381 3 жыл бұрын
Hi, thank you very much for your video.
@Codemycom
@Codemycom 3 жыл бұрын
So nice of you
@TheGeneticHouse
@TheGeneticHouse Жыл бұрын
Perfect I need this one for my app! Thanks again 4 hours in lol
@Codemycom
@Codemycom Жыл бұрын
Awesome
@dxbryakxff
@dxbryakxff 2 жыл бұрын
MAN I LOVE U SO MUCH
@Codemycom
@Codemycom 2 жыл бұрын
Ha, thanks!
@gimanthadesilva
@gimanthadesilva 3 жыл бұрын
thank you u are the best!!
@Codemycom
@Codemycom 3 жыл бұрын
You're welcome!
@jazthurin
@jazthurin Жыл бұрын
Fantastic tutorial thank you
@Codemycom
@Codemycom Жыл бұрын
Very welcome!
@aregabgaryan3800
@aregabgaryan3800 4 жыл бұрын
thanks a lot man^^
@Codemycom
@Codemycom 4 жыл бұрын
Sure thing!
@nikrastegar5131
@nikrastegar5131 3 жыл бұрын
this tutorial actually saved my ass , thanks alot
@Codemycom
@Codemycom 3 жыл бұрын
Ha, awesome
@furrane
@furrane 2 жыл бұрын
FYI : the Scale command argument will pass the scale value to the function called. Which means you could use something like this here : def slide(val): root.geometry(str(val)+'x400')
@Refnom95
@Refnom95 Жыл бұрын
Thanks for the great videos! Would be very grateful if you could answer a quick question? What is the reason for assigning the file path string to 'root.filename'? From what I understand, this creates a new attribute called 'filename' for the 'root' object. What is the advantage of doing this instead of just assigning it to a normal variable (ie. just 'filename')?
@Hi.GuysBs
@Hi.GuysBs 3 жыл бұрын
Thank you so mutch!!
@Codemycom
@Codemycom 3 жыл бұрын
Very welcome!
@aotruc2472
@aotruc2472 4 жыл бұрын
Thank you very much
@Codemycom
@Codemycom 4 жыл бұрын
You're welcome!
@namanallawadhi7397
@namanallawadhi7397 2 жыл бұрын
thank you Heisenberg :)
@Codemycom
@Codemycom 2 жыл бұрын
Welcome!
@yashdeore473
@yashdeore473 3 жыл бұрын
Brilliant again. Nothing shocks me now
@Codemycom
@Codemycom 3 жыл бұрын
Ha, thanks
@creationandtechwithin4409
@creationandtechwithin4409 4 жыл бұрын
man you are awesome
@Codemycom
@Codemycom 4 жыл бұрын
Thanks!
@riyapalkar1178
@riyapalkar1178 3 жыл бұрын
Thanku Sooo much . For this I hadn't seen this video Sorry . For that But a big thanku this video helped me solve my problem 😊
@Codemycom
@Codemycom 3 жыл бұрын
Sure thing
@aryaparyani
@aryaparyani 4 жыл бұрын
thank u!
@Codemycom
@Codemycom 4 жыл бұрын
You're welcome!
@ahmedredasaeed2374
@ahmedredasaeed2374 2 жыл бұрын
Thanks alot
@Codemycom
@Codemycom 2 жыл бұрын
Welcome!
@raniduharshana5238
@raniduharshana5238 4 жыл бұрын
Thank you
@Codemycom
@Codemycom 4 жыл бұрын
You're welcome
@prachidusa3357
@prachidusa3357 3 жыл бұрын
Hello Sir..👋 Plz help me with this: I'm trying to execute code with resizing d image within the given frame. The code got executed in simple root frame. But, I'm trying to execute it in new window in a defined class (self,root), but it gives Nameerror: frame_name not defined even though defined.
@AcTheMace
@AcTheMace 4 жыл бұрын
Thanks for this tutorial, I have just one question: I with there was a way to remove the "All Files" portion of the code and still have it run so that you can restrict what type of files a user is allowed to select. If there is a solution to this, please tell me, Thanks!
@remus-alexandrusimion3439
@remus-alexandrusimion3439 4 жыл бұрын
Kinda late to the party but doesn't removing that section of code remove the "all files"? Also, as a user, I hate when programmers do that. Because if i'm lacking the file there's no way for me to distinguish between "I have no file" and "it doesn't load any file". Better allow "all files" and validate the filetype after. That way the user can at least validate that his computer isn't frozen, and that files are actually loading, but they're not providing valid files. Cheers!
@AunSyedShah
@AunSyedShah 3 жыл бұрын
May God bless you.
@Codemycom
@Codemycom 3 жыл бұрын
Thanks
@atharvaathalye
@atharvaathalye 4 жыл бұрын
Sir it gives me error "positional argument follows keyword arguments"
@Prashant__Gaming
@Prashant__Gaming 4 жыл бұрын
thanks sir
@Codemycom
@Codemycom 4 жыл бұрын
You're very welcome! Thanks for watching!
@ks.545
@ks.545 3 жыл бұрын
Hi, lets say I select a video by using file dialog box, is it possible to pass the 'selected video' to "cap = cv2.VideoCapture('selected video')" in another .py file ? Grateful if anyone can help 🙏
@suyashnalawade8272
@suyashnalawade8272 3 жыл бұрын
how can i pass the opened file to another function and make it read as binary
@fernandohood5542
@fernandohood5542 4 жыл бұрын
What about trying to return a list of files in a directory location?
@tristangwithian4010
@tristangwithian4010 3 жыл бұрын
#Don't forget to import these import glob, os #Change to a directory of your choice os.chdir("images") #Loop through all the files in that folder matching your pattern for file in glob.glob("*.jpg"): print(file)
@iTIsMoRGaN
@iTIsMoRGaN 3 жыл бұрын
Hey, does anyone know why we need to explicitly import tkinter.filedialog (from tkinter import filedialog) when we previously imported all (*) from tkinter? Shouldn't it be included with *?
@Codemycom
@Codemycom 3 жыл бұрын
You would think so...just one of those weird tkinter things...
@fiidat
@fiidat 4 жыл бұрын
What about askfilesaveas using Tkinter. Your explanation on how to use askopenfilename is the best I found. No one specifically mentions the fact that it only returns the filename, so you actually need another step to open it. Thanks.
@Codemycom
@Codemycom 4 жыл бұрын
:-)
@mr_possible6197
@mr_possible6197 4 жыл бұрын
@@Codemycom I want to capture the filename obtained from Button click. How to do that?? in a nutshell, File dialog opens ---> I select the file ---> clicked OK ----> At this point, I wanna get the file name into a text box. Please help me out here.
@Codemycom
@Codemycom 4 жыл бұрын
@@mr_possible6197 you used a variable name to open the file dialog box right? That variable contains the file name.
@9696viktor
@9696viktor 3 жыл бұрын
Thanks for the tutorial! How can I make it so that when I open the dialog box, I can select multiple files and append their path to a list?
@Codemycom
@Codemycom 3 жыл бұрын
I think I might do that in another video on the playlist
@afridinaseer
@afridinaseer 4 жыл бұрын
HI SIR can we add this uploaded file to our mysql database using insert quary and kepping its datatype to LONGBLOB? Thanks
@Codemycom
@Codemycom 4 жыл бұрын
Give it a try and see
@alaskawoodman
@alaskawoodman 3 жыл бұрын
Your videos are very helpful. Does Tkinter offer a method to show any file details like file size?
@Codemycom
@Codemycom 3 жыл бұрын
Not natively, but you could write code to determine that
@ellenjunker2172
@ellenjunker2172 4 жыл бұрын
great tutorial! One question, if i want to open a csv file, how can i keep it in a variable so i can use it in different functions?
@Codemycom
@Codemycom 4 жыл бұрын
I think I have a video on that in the playlist
@tanaydas7496
@tanaydas7496 4 жыл бұрын
@@Codemycom sir I could not find the solution of this question. Can you tell me the video number... where the value of a variable within a function can be used in other functions ??
@Codemycom
@Codemycom 4 жыл бұрын
@@tanaydas7496 make the variable global. global var_name
@maximmazurov1102
@maximmazurov1102 4 жыл бұрын
@@Codemycom I have a similar question. Struggling to understand how to get the path and use it after in function which reads .csv. Should it be done after root.mainloop()?
@Codemycom
@Codemycom 4 жыл бұрын
@@maximmazurov1102 There are really several videos in this playlist where we askopenfilename to get a path and save it to a variable...
@funnyclips2696
@funnyclips2696 2 жыл бұрын
Excellent...! pls can this be done using grid() method ?
@Codemycom
@Codemycom 2 жыл бұрын
everything can be done using both pack or grid.
@musakayasimp6456
@musakayasimp6456 4 жыл бұрын
hello sir I just wanted to ask a question i noticed that in the previous video the new window one you wrote mainloop not root.mainloop is there times you have to write root.mainloop and times not or what
@Codemycom
@Codemycom 4 жыл бұрын
you should just use root.mainloop()
@tonystark2358
@tonystark2358 4 жыл бұрын
sir, your channel is really underrated compared to your content. Your channel should have a more than a million subs
@Codemycom
@Codemycom 4 жыл бұрын
Thanks! Tell your friends ;-)
@attaulmomin
@attaulmomin 4 жыл бұрын
@@Codemycom tony stark Other coding-youtubers make some non technical videos like advice videos and 'a day in the life of software engineer - videos' and '5 beginners mistakes-videos'.But John E. focuses on making great tutorials and I think he is the only guy who answers as many as possible Q's /cmnts. sometimes people are not looking for great tutorials but for programmig entertainment.
@Codemycom
@Codemycom 4 жыл бұрын
@@attaulmomin thanks
@attaulmomin
@attaulmomin 4 жыл бұрын
@@Codemycom never mind
@okas425
@okas425 3 жыл бұрын
Hey I know I’m super late but I have a question how do I get the location of the file to be accessed globally across the main file? Cuz I don’t think global root.filedialog etc. will work
@Codemycom
@Codemycom 3 жыл бұрын
set the filedialog to a variable, make that variable global.
@bhavyamverma70
@bhavyamverma70 3 жыл бұрын
dear sir instead of using git bash to run you can press "ctrl+b" key combinations to run your program hope you can see it
@Codemycom
@Codemycom 3 жыл бұрын
No, that doesn't always work and it's not the professional way
@akshitmiglani5419
@akshitmiglani5419 3 жыл бұрын
Hi, this is a great tutorial! I'd love if you can provide more clarity on defining a global variable inside a function. Based on my relatively limited knowledge, it is regarded as a bad practice in any situation & secondly, why do we have to do that in context of what we're trying to achieve in this video. Thanks!
@Codemycom
@Codemycom 3 жыл бұрын
Can you explain why you think it's a bad practice? What makes it bad.
@akshitmiglani5419
@akshitmiglani5419 3 жыл бұрын
@@Codemycom Sure, I can give it a try. Correct me if you think I'm wrong. "Defining" a variable global inside a function normally means that we have it declared in the main code & we're just referring to in case we want to change it. So, if we are to use this variable outside, I'm not sure if it'd the same thing as the case I mentioned(having it declared outside & referred inside the function using global). Hope I make sense.
@Gbtx6
@Gbtx6 2 жыл бұрын
@@akshitmiglani5419 I know it's been a year, but for anyone going through the comments: The instructor forgot that the variable was no longer outside of the function so he just forgot to get rid of the global my_image variable. So Akshit was correct, but might've missed that the instructor didn't realize what had happened. To clear things up here's the whole thing summed up: if you create a function and try to refer to a variable that had been created outside of it and before it, but inside this or any other function without the global keyword, python will assume you just want to create a new variable that only exists inside of this function. As I said before, by using global in front of an already created variable outside and before the function, we're basically letting python know that this variable already exists globally. What's funny here is that python is so flexible it doesn't even care that global my_image didn't exist. it just did what it had to with no errors.
@lamlya6908
@lamlya6908 2 жыл бұрын
You've just save a life 😉
@Codemycom
@Codemycom 2 жыл бұрын
awsome
@coolmanreebro
@coolmanreebro 3 жыл бұрын
Great Tutorial! But can you tell me how to resize the image that you upload?
@Codemycom
@Codemycom 3 жыл бұрын
I have videos on that in the playlist
@waltwilliams6012
@waltwilliams6012 3 жыл бұрын
Is it possible to position the FileDialog box at a specific location on the screen?
@Codemycom
@Codemycom 3 жыл бұрын
Not that I know of...
@gustavooliveira-mc9nb
@gustavooliveira-mc9nb 3 жыл бұрын
I dont know if you willl read this but anyways why the variable that receives the return of filedialog.... is root.file name? i dont get it, why cant i use any other name for it? Thanks for your attention
@franktewierikholscher
@franktewierikholscher 6 күн бұрын
That was my question too, right when hè types it.
@peterpanagiotou3825
@peterpanagiotou3825 Жыл бұрын
Hello, i would like to make a question. When you open the file you want, how can you make the button disappear from the "new" window that show the photo? Thanks in advance...
@Codemycom
@Codemycom Жыл бұрын
use pack_forget()
@akhilarayapati5292
@akhilarayapati5292 4 жыл бұрын
Hi, I had a quick question regarding selecting the folder and the path should end with the "//" . Can you please suggest me the ways?
@Codemycom
@Codemycom 4 жыл бұрын
Not sure what you mean
@akhilarayapati5292
@akhilarayapati5292 4 жыл бұрын
@@Codemycom thanks for responding. I meant if i selected a folder through button from UI to that the path will be like for an ex: C:/documents/python/foldername is the output but i need it as C:/documents/python/foldername/ so do u knw any ways to get that extra slash in python. Please suggest the ways.
@Codemycom
@Codemycom 4 жыл бұрын
@@akhilarayapati5292 just add it to the code...I don't understand...initialdir="/documents/python/foldername/" or whatever
@amankumarbairagi794
@amankumarbairagi794 4 жыл бұрын
print("Awesome video sir ")
@Codemycom
@Codemycom 4 жыл бұрын
Thanks! lol
@PersonSnowboarding
@PersonSnowboarding 4 жыл бұрын
I'm at the 6:00 mark, the all files "*.*" doesn't seem to work as the option is faded out in the popup. It only lets me interact with folder and files types I have explicitly typed in to include
@Codemycom
@Codemycom 4 жыл бұрын
Check your code for typos.
@vipgamer9941
@vipgamer9941 Жыл бұрын
Sir I added a file dialogue on a top-level but it does not show on the top but file dialogue shows under the top-level how can I fix this sir
@maxwellhawk
@maxwellhawk Жыл бұрын
im not clear with a import thing. First we do from tkinter import * it should import everything right? yet we specifically write from tkinter import filedialog, why?
@Codemycom
@Codemycom Жыл бұрын
That's just how tkinter works.
@mohaparchopra6656
@mohaparchopra6656 4 жыл бұрын
could u also attach the code u write in a text file available to us through a link
@Codemycom
@Codemycom 4 жыл бұрын
My code is available on github. github.com/flatplanet/Intro-To-TKinter-KZbin-Course
@aryan983983
@aryan983983 5 жыл бұрын
can i open and store images using this?
@Codemycom
@Codemycom 5 жыл бұрын
Try it and see for yourself.
@jinwee2247
@jinwee2247 3 жыл бұрын
Hey John, ran the code. A dialog box with "Save file" shows up with the wrong file types instead. Any ideas why this is the case? Am running on Python 3.7 Spyder on Windows. Thanks in advance!
@Codemycom
@Codemycom 3 жыл бұрын
you have to tell it the file types that you want...
@jinwee2247
@jinwee2247 3 жыл бұрын
@@Codemycom thank you, i switched to pycharm and the code works well. not sure why it isn't working on spyder. cheers!
@gerrygiovan4720
@gerrygiovan4720 3 жыл бұрын
If you use the button "Open File" after showing an image, the next image will appear below the previous one instead of replacing the original.
@tejashirawat9994
@tejashirawat9994 3 жыл бұрын
how did you solve it?
@santhoshrs81
@santhoshrs81 3 жыл бұрын
@@tejashirawat9994 But we can make it as to replace the previous one whenever we open new image
@tejashirawat9994
@tejashirawat9994 3 жыл бұрын
@@santhoshrs81 thank you but I figured it out. We had to update the contents, not add a new component
@victortsenkov1424
@victortsenkov1424 4 жыл бұрын
Could you make a video about tags, how to check if a word is tagged and others?
@Codemycom
@Codemycom 4 жыл бұрын
With tkinter? No... that's just python programming, right?
@phixphixation7261
@phixphixation7261 3 жыл бұрын
@@Codemycom No, he meant the Text widget's tags to apply formatting to a word or sentence.
@secretbenjahman4437
@secretbenjahman4437 3 жыл бұрын
Good day, please help. The root.filename returns '' . i dont understand what is happening. Thanks in advance.
@9MRantu
@9MRantu 3 жыл бұрын
I don't know if it's too late, it was happening to me too, and didn't let me place the image then either I finally solved it by putting a second code line (right after getting root.filename), and put: root.filename = root.filename.name - then it just took the location
@barrykruyssen
@barrykruyssen 11 ай бұрын
Great tutorial. I take it the filedialog just calls the OS's dialog box (which in linux on a chromebook is very lame)
@phaneshpadki3429
@phaneshpadki3429 3 жыл бұрын
when i assign filetypes, its throwing error. I tried giving *.jpg, *.JPG, *.png, *.PNG, *.*, * and a few other combinations. its throwing an error saying ''_tkinter.TclError: Bad file type "*.*".. Please guide
@Codemycom
@Codemycom 3 жыл бұрын
You likely have a typo in your code...it must be exact
@runningforver5958
@runningforver5958 2 жыл бұрын
I thought "from module import *" already imports everything there is in the module? Why do we have to do from tkinter import textdialog after?
@Codemycom
@Codemycom 2 жыл бұрын
That's just how it works.
@millakiani389
@millakiani389 3 жыл бұрын
Hello Is it possible to use adobe xd for my python code ? Please help me
@Codemycom
@Codemycom 3 жыл бұрын
I don't know what adobe xd is
@ertugrulsrt5761
@ertugrulsrt5761 2 жыл бұрын
Is there a way to ask for file directory rather than a file, my program freezes when I try askdirectory()
@Codemycom
@Codemycom 2 жыл бұрын
Your program won't freeze unless you've done something wrong in the code. Check your code
@2.a.m.g698
@2.a.m.g698 3 жыл бұрын
Hello, what if now i wanna open multiple images and show them all? If i choose all files, the FileName = filedialog.askopenfilename will become a list?
@Codemycom
@Codemycom 3 жыл бұрын
give it a try
@2.a.m.g698
@2.a.m.g698 3 жыл бұрын
@@Codemycom Hello, ty for reaching me. Yes its a list. Now i'm stuck with one more problem. I want to read the csv file and draw it using matplotlib. The problem is: my csv file contains values with epsilon. For example, first row will be like : 4,869456e+002;2,712950e-002. So i just cant not a.plot(float(row[0]), float(row[1])) because it will give ValueError: could not convert string to float: '4,869456e+002'. So what do i do now? I'm very new to python and sorry for the stupid question.
@hohotv999
@hohotv999 3 жыл бұрын
Hi, this is a great tutorial! I have a question ! When I change image but he path has not changed. How to fix??
@Codemycom
@Codemycom 3 жыл бұрын
change the path
@hohotv999
@hohotv999 3 жыл бұрын
@@Codemycom Thanks. But I have changed to another image. And the previous image didnt disappear. How to make remove previous when select new image?
@Codemycom
@Codemycom 3 жыл бұрын
@@hohotv999 check today’s video, it’s the last one in the playlist. It shows how to do what you want.
@hohotv999
@hohotv999 3 жыл бұрын
@@Codemycom Ok. thank you !
@icodeint2780
@icodeint2780 3 жыл бұрын
hey guys, am having a strange error whn i try to open any image. unicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 246: character maps to please guys any idea in way?
@tigransaidov5122
@tigransaidov5122 3 жыл бұрын
Maybe you used filedialog.askopenfile instead of filedialog.askopenfilename? I confused them at first and got the same error like you
@SuganthanRaj
@SuganthanRaj 4 жыл бұрын
how to upload and save csv files in particular folder using tkinter?
@Codemycom
@Codemycom 4 жыл бұрын
Good idea for a video...
@tejasgorivale425
@tejasgorivale425 4 жыл бұрын
@@Codemycom please make it asap and also make a video on how to open and display text,docx or all types of files from dialogbox in tkinter
@infinitespace1982
@infinitespace1982 3 жыл бұрын
Can we practice these Tkinter tutorials using IDLE Python?
@Codemycom
@Codemycom 3 жыл бұрын
I don't recommend it.
@quanfeng5488
@quanfeng5488 4 жыл бұрын
You scared my at the beginning of the video ;;
@Codemycom
@Codemycom 4 жыл бұрын
how so?
@LayMooTun
@LayMooTun 5 жыл бұрын
How can i open a python file and run the file. I used the filedialog.askopenfilename() but it doesn't actually open the file. How do i make it open and run. THanks
@siphelelemaphumulo9577
@siphelelemaphumulo9577 4 жыл бұрын
im looking for the same code...i dont know if you were able to get help
@LayMooTun
@LayMooTun 4 жыл бұрын
@@siphelelemaphumulo9577 couldn't find the solution before the due date of my SAC, but it's okay, I ditch the idea. Thanks tho
@KuyaJoel
@KuyaJoel 4 жыл бұрын
filedialog.askopenfilename() will only return the directory of the file in string format
@DARKxDANI47
@DARKxDANI47 11 ай бұрын
Thanks Sir I'm Your Student From Pakistan ❤i Subscribe Your Channel and Always Watching Your Videos , I Can't Afford ur Paid Courses On Web So I'm Wathcing u on YT
@infinitespace1982
@infinitespace1982 3 жыл бұрын
I need some help, when I try to open multiple images, some of them are just blank. What is the reason for this? Is there a way to fix this?
@Codemycom
@Codemycom 3 жыл бұрын
No idea. Could be a lot of things. But mainly, you've probably done something wrong in the code (or the images are of the wrong file type).
@AmitK
@AmitK 3 жыл бұрын
sorry for my silly question but when we imported everything using " from tkinter import * " then why we have to import filedialog using "from tkinter import filedialog"
@Codemycom
@Codemycom 3 жыл бұрын
Thats just how tkinter works
@aka5
@aka5 3 жыл бұрын
Libraries can define what gets imported when you do `from library import *`. This means that it's not necessarily everything that gets imported.
@myth8112
@myth8112 3 жыл бұрын
Pls anyone reply...how can i return the file path to a Entry box or feature or whatever u called....is it doable or we can only return it to a Label?
@Codemycom
@Codemycom 3 жыл бұрын
Add it in the same way you add anything to an entry box...I have videos on that
@myth8112
@myth8112 3 жыл бұрын
@@Codemycom omggg sir u rly replied at me..thxx so much...i meant file path...sry for my bad English...i tried to add it the same way as Label but it doesn't return anything to the Entry box and it still empty Again thx in advance
@Codemycom
@Codemycom 3 жыл бұрын
@@myth8112 yeah like I said go watch the videos I have on entry boxes
@myth8112
@myth8112 3 жыл бұрын
@@Codemycom watched ur vids and did it ..thx so much sir
@NehaYadav-mp5ih
@NehaYadav-mp5ih 3 жыл бұрын
I can't open mp4 files using this. is there any other way to do it?
@Codemycom
@Codemycom 3 жыл бұрын
Tkinter doesn’t handle video well
@rokkuzner
@rokkuzner 2 жыл бұрын
I have an error! It's: Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "c:/Users/LENOVO/Documents/Programiranje/Images in tkinter/images.py", line 11, in addphoto img = ImageTk.PhotoImage(Image.open(photo)) AttributeError: type object 'Image' has no attribute 'open' PLEASE HELP!
@rokkuzner
@rokkuzner 2 жыл бұрын
My whole program is: from tkinter import * from PIL import ImageTk from tkinter import ttk from tkinter import filedialog win = Tk() win.title('Images') def addphoto(): photo = filedialog.askopenfilename(initialdir='C:\\Users\\LENOVO\\Pictures', title='Select an image', filetypes=(('png files', '*.png'),('other files', '*.*'))) img = ImageTk.PhotoImage(Image.open(photo)) label_img = Label(frame2, image=img) label_img.pack(paddy=5) addphotoB = Button(win, text='ADD PHOTO!', bg='lightgreen', command=addphoto) addphotoB.pack(pady=8) yourfhotoslabel = Label(win, text='Your photos:', font=('Arial', 12, 'bold')) yourfhotoslabel.pack() #SCROLLBAR frame = Frame(win) frame.pack(fill=BOTH, expand=1) canvas = Canvas(frame) canvas.pack(side=LEFT, fill=BOTH, expand=1) scrollbar = ttk.Scrollbar(frame, orient=VERTICAL, command=canvas.yview) scrollbar.pack(side=RIGHT, fill=Y) canvas.configure(yscrollcommand=scrollbar.set) canvas.bind('', lambda e: canvas.configure(scrollregion = canvas.bbox('all'))) frame2 = Frame(canvas) canvas.create_window((0,0), window=frame2, anchor='nw') #SCROLLBAR win.mainloop()
@Codemycom
@Codemycom 2 жыл бұрын
@@rokkuzner What did you do differently from the video?
@aryamannatrajan4850
@aryamannatrajan4850 4 жыл бұрын
i am getting this error : couldn't open "": no such file or directory please help. Thank you
@aryamannatrajan4850
@aryamannatrajan4850 4 жыл бұрын
because in yours it just shows the file path but in mine it shows "" please help thank you
@Codemycom
@Codemycom 4 жыл бұрын
@@aryamannatrajan4850 Change the name of the directory GUI Icon to GUI_Icon (don't use spaces)
@aryamannatrajan4850
@aryamannatrajan4850 4 жыл бұрын
@@Codemycom Thank you
@Codemycom
@Codemycom 4 жыл бұрын
@@aryamannatrajan4850 Sure thing
@iluvsyphonfilter
@iluvsyphonfilter 4 жыл бұрын
@@aryamannatrajan4850 I had the same problem, I removed the spaces and it didn't work either, so I did print(root.filename.name) instead of just root.filename and it gave me the directory path
@prathvikothari3513
@prathvikothari3513 4 жыл бұрын
The "my_image = ImageTk.PhotoImage(Image.open(root.folder_select))" command is not working(can't see the image) even though I installed the PIL library plz can you help me
@Codemycom
@Codemycom 4 жыл бұрын
There's likely an error in your code. You capitalized or didn't capitalize something. Also, what is root.folder_select? Maybe that's your problem
@prathvikothari3513
@prathvikothari3513 4 жыл бұрын
@@Codemycom actually I didn't declare the global variable in the function 😅 Thanks for your video!!!
@Codemycom
@Codemycom 4 жыл бұрын
@@prathvikothari3513 ah, there you go then :-P
@sanjayrajasreeraja3456
@sanjayrajasreeraja3456 4 жыл бұрын
how to insert multiple images in a single window? if we use the normal image inserting code we get a white box instead of the image
@Codemycom
@Codemycom 4 жыл бұрын
Are you defining each image separately?
@sanjayrajasreeraja3456
@sanjayrajasreeraja3456 4 жыл бұрын
@@Codemycom Yes I got it thanks to ur photo viewer gui creating video I was able to do it.
@Codemycom
@Codemycom 4 жыл бұрын
@@sanjayrajasreeraja3456 Good
@lingeshwaran511
@lingeshwaran511 3 жыл бұрын
What compiler you using
@Codemycom
@Codemycom 3 жыл бұрын
Sublime text editor and the git bash terminal git-scm.com
@lingeshwaran511
@lingeshwaran511 3 жыл бұрын
Thanks brother 🙏🙏❤️❤️
@devd7613
@devd7613 3 жыл бұрын
This program gives me error like TclError: bad file type "*.*" Should be typeName {extension ? Extension ...?}. What should i do ? Plz explain me...🙏🙏
@Codemycom
@Codemycom 3 жыл бұрын
you likely have a typo somewhere around there
@devd7613
@devd7613 3 жыл бұрын
Can you plz give me your mail id so i can send you the picture of error..plz help..
Sliders With TKinter - Python Tkinter GUI Tutorial #16
13:11
Codemy.com
Рет қаралды 69 М.
DAD LEFT HIS OLD SOCKS ON THE COUCH…😱😂
00:24
JULI_PROETO
Рет қаралды 16 МЛН
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 9 МЛН
No empty
00:35
Mamasoboliha
Рет қаралды 8 МЛН
Radio Buttons with TKinter - Python Tkinter GUI Tutorial #12
17:44
Python GUI open a file (filedialog) 📁
7:38
Bro Code
Рет қаралды 94 М.
Create New Windows in tKinter - Python Tkinter GUI Tutorial #14
9:52
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 36 М.
Python GUI Development With PySimpleGUI
15:15
Real Python
Рет қаралды 1 МЛН
18 Commands That Will Change The Way You Use Linux Forever
29:50
Akamai Developer
Рет қаралды 1,2 МЛН
Threading With Tkinter - Python Tkinter GUI Tutorial #97
9:10
Codemy.com
Рет қаралды 76 М.
DAD LEFT HIS OLD SOCKS ON THE COUCH…😱😂
00:24
JULI_PROETO
Рет қаралды 16 МЛН