Open Files Dialog Box - Python Tkinter GUI Tutorial #15

  Рет қаралды 195,370

Codemy.com

Codemy.com

Күн бұрын

Пікірлер: 322
@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 3 жыл бұрын
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 3 жыл бұрын
@@100jsj6 Glad you like it!
@deltadeveloperr
@deltadeveloperr 2 жыл бұрын
i made a file location finder app with this video. thank you!
@Codemycom
@Codemycom 2 жыл бұрын
@@deltadeveloperr awesome
@tristangwithian4010
@tristangwithian4010 4 жыл бұрын
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 4 жыл бұрын
I appreciate that!
@Omega-ll4tx
@Omega-ll4tx 2 жыл бұрын
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 2 жыл бұрын
Thanks! I appreciate it!
@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
@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 10 ай бұрын
Thank you! Spent 20 minutes trying to figure out the problem before checking the comments section 🙄
@agrimpuriya2585
@agrimpuriya2585 3 жыл бұрын
This was the most useful video yet. Great content John!
@Codemycom
@Codemycom 3 жыл бұрын
Glad it was helpful!
@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 4 жыл бұрын
simp
@dylancampbell6433
@dylancampbell6433 3 жыл бұрын
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 3 жыл бұрын
Glad I could help!
@SammarpanDasguptaOfficial
@SammarpanDasguptaOfficial 4 жыл бұрын
You are a genius teacher.....truly......I get confidence from your lectures......love you from India.
@Codemycom
@Codemycom 4 жыл бұрын
Thank you so much! I appreciate that!
@chwenjun225
@chwenjun225 Жыл бұрын
Straight to the problem, I love it
@Codemycom
@Codemycom Жыл бұрын
happy to hear it
@funnyclips2696
@funnyclips2696 2 жыл бұрын
Excellent...! pls can this be done using grid() method ?
@Codemycom
@Codemycom 2 жыл бұрын
everything can be done using both pack or grid.
@yashdeore473
@yashdeore473 4 жыл бұрын
Brilliant again. Nothing shocks me now
@Codemycom
@Codemycom 4 жыл бұрын
Ha, thanks
@ellenjunker2172
@ellenjunker2172 5 жыл бұрын
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...
@fernandohood5542
@fernandohood5542 4 жыл бұрын
What about trying to return a list of files in a directory location?
@tristangwithian4010
@tristangwithian4010 4 жыл бұрын
#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)
@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
@2noiembrie83
@2noiembrie83 Жыл бұрын
Loved every minute of it!
@Codemycom
@Codemycom Жыл бұрын
Thanks!
@lingeshwaran511
@lingeshwaran511 4 жыл бұрын
What compiler you using
@Codemycom
@Codemycom 4 жыл бұрын
Sublime text editor and the git bash terminal git-scm.com
@lingeshwaran511
@lingeshwaran511 4 жыл бұрын
Thanks brother 🙏🙏❤️❤️
@radhatiwari1211
@radhatiwari1211 5 жыл бұрын
Great explanation 👍
@Codemycom
@Codemycom 5 жыл бұрын
Thanks!
@TheGeneticHouse
@TheGeneticHouse Жыл бұрын
Perfect I need this one for my app! Thanks again 4 hours in lol
@Codemycom
@Codemycom Жыл бұрын
Awesome
@AcTheMace
@AcTheMace 5 жыл бұрын
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!
@Refnom95
@Refnom95 2 жыл бұрын
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')?
@isuruprasaddilhara6771
@isuruprasaddilhara6771 3 жыл бұрын
Best tutorial I have ever seen ❤
@Codemycom
@Codemycom 3 жыл бұрын
Thanks!
@palkar_artworks
@palkar_artworks 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
@NEXC
@NEXC 3 жыл бұрын
youtube coupon code is huge discount! thank for you bro
@Codemycom
@Codemycom 3 жыл бұрын
Welcome!
@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()
@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 4 ай бұрын
That was my question too, right when hè types it.
@tieuwest
@tieuwest 2 жыл бұрын
Thanks. I really enjoy this and find this super helpful.
@Codemycom
@Codemycom 2 жыл бұрын
Glad to hear it!
@cristianoz930
@cristianoz930 6 ай бұрын
I love you bro ❤❤❤❤❤❤ thx for all these videos
@Codemycom
@Codemycom 6 ай бұрын
Welcome!
@Yash111-l8l
@Yash111-l8l Жыл бұрын
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
@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')
@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.
@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
@amankumarbairagi794
@amankumarbairagi794 4 жыл бұрын
print("Awesome video sir ")
@Codemycom
@Codemycom 4 жыл бұрын
Thanks! lol
@namanallawadhi7397
@namanallawadhi7397 3 жыл бұрын
thank you Heisenberg :)
@Codemycom
@Codemycom 3 жыл бұрын
Welcome!
@iamzareef
@iamzareef 3 жыл бұрын
Thanks sir! you just saved my day
@Codemycom
@Codemycom 3 жыл бұрын
Happy to hear it!
@maxwellhawk
@maxwellhawk 2 жыл бұрын
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 2 жыл бұрын
That's just how tkinter works.
@mission_and_purpose
@mission_and_purpose 3 жыл бұрын
Thank you very much! that helped me!
@Codemycom
@Codemycom 3 жыл бұрын
Happy to hear it!
@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.
@nikrastegar5131
@nikrastegar5131 4 жыл бұрын
this tutorial actually saved my ass , thanks alot
@Codemycom
@Codemycom 4 жыл бұрын
Ha, awesome
@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
@totolariflette
@totolariflette 3 жыл бұрын
Thank you so much, you saved my day
@Codemycom
@Codemycom 3 жыл бұрын
Glad I could help!
@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.
@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
@jazthurin
@jazthurin 2 жыл бұрын
Fantastic tutorial thank you
@Codemycom
@Codemycom 2 жыл бұрын
Very welcome!
@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
@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
@minhhoangnhat7331
@minhhoangnhat7331 3 жыл бұрын
Thanks for your videos
@Codemycom
@Codemycom 3 жыл бұрын
Glad you like them!
@tejasgorivale425
@tejasgorivale425 4 жыл бұрын
john you are great man hats off _/\_
@Codemycom
@Codemycom 4 жыл бұрын
Thank you!
@shreyashchoudhary4576
@shreyashchoudhary4576 3 жыл бұрын
Great! Really Helpful
@Codemycom
@Codemycom 3 жыл бұрын
Glad you liked it!
@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
@millakiani389
@millakiani389 4 жыл бұрын
Hello Is it possible to use adobe xd for my python code ? Please help me
@Codemycom
@Codemycom 4 жыл бұрын
I don't know what adobe xd is
@parsabahrambeik4381
@parsabahrambeik4381 4 жыл бұрын
Hi, thank you very much for your video.
@Codemycom
@Codemycom 4 жыл бұрын
So nice of you
@suyashnalawade8272
@suyashnalawade8272 4 жыл бұрын
how can i pass the opened file to another function and make it read as binary
@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()
@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
@dxbryakxff
@dxbryakxff 2 жыл бұрын
MAN I LOVE U SO MUCH
@Codemycom
@Codemycom 2 жыл бұрын
Ha, thanks!
@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.
@AunSyedShah
@AunSyedShah 3 жыл бұрын
May God bless you.
@Codemycom
@Codemycom 3 жыл бұрын
Thanks
@siddharthrawat7205
@siddharthrawat7205 4 жыл бұрын
Really helpful. subbed
@Codemycom
@Codemycom 4 жыл бұрын
Thanks!
@AmitK
@AmitK 4 жыл бұрын
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 4 жыл бұрын
Thats just how tkinter works
@aka5
@aka5 4 жыл бұрын
Libraries can define what gets imported when you do `from library import *`. This means that it's not necessarily everything that gets imported.
@devd7613
@devd7613 4 жыл бұрын
This program gives me error like TclError: bad file type "*.*" Should be typeName {extension ? Extension ...?}. What should i do ? Plz explain me...🙏🙏
@Codemycom
@Codemycom 4 жыл бұрын
you likely have a typo somewhere around there
@devd7613
@devd7613 4 жыл бұрын
Can you plz give me your mail id so i can send you the picture of error..plz help..
@runningforver5958
@runningforver5958 3 жыл бұрын
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 3 жыл бұрын
That's just how it works.
@travelwithbay
@travelwithbay 4 жыл бұрын
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 4 жыл бұрын
you have to tell it the file types that you want...
@travelwithbay
@travelwithbay 4 жыл бұрын
@@Codemycom thank you, i switched to pycharm and the code works well. not sure why it isn't working on spyder. cheers!
@okas425
@okas425 4 жыл бұрын
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 4 жыл бұрын
set the filedialog to a variable, make that variable global.
@NehaYadav-YT
@NehaYadav-YT 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
@vamprock02
@vamprock02 4 жыл бұрын
sir i have a question how can we open a pdf file using tkinter do we need something another to open a pdf file or a excel file ?
@Codemycom
@Codemycom 4 жыл бұрын
I have a video on that in the playlist
@vamprock02
@vamprock02 4 жыл бұрын
@@Codemycom thank you sir
@victorwang305
@victorwang305 3 жыл бұрын
Why does the message pop up as ' after running my_label? Would you please help me to solve this problem?
@Codemycom
@Codemycom 3 жыл бұрын
What did you do differently from the video?
@victorwang305
@victorwang305 3 жыл бұрын
@@Codemycom Thank you for your reply! I just did as the same as up the myLabel = (...).pack(), and run all the codes like followings. The png file was selected but the message ' displayed in the Viewer windows. from tkinter import * from PIL import ImageTk, Image from tkinter import filedialog root = Tk() root.title("Ai4U Image Viewer") root.iconbitmap("Banray_logo.ico") root.filename = filedialog.askopenfile(initialdir="/myphon/vs_code/w3school/", title="Select a file", filetypes=(("png files", "*.png"), ("jpg files", "*.jpg"), ("All files", "*.*"))) myLabel = Label(root, text=root.filename).pack() root.mainloop()
@Codemycom
@Codemycom 3 жыл бұрын
@@victorwang305 don't ever pack your widgets on the same line you define them.
@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
@iTIsMoRGaN
@iTIsMoRGaN 4 жыл бұрын
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 4 жыл бұрын
You would think so...just one of those weird tkinter things...
@gimanthadesilva
@gimanthadesilva 4 жыл бұрын
thank you u are the best!!
@Codemycom
@Codemycom 4 жыл бұрын
You're welcome!
@tibbers2822
@tibbers2822 3 жыл бұрын
How come when I run this no button appears in the window?
@Codemycom
@Codemycom 3 жыл бұрын
Because you made a mistake
@tibbers2822
@tibbers2822 3 жыл бұрын
@@Codemycom the code is the same as the video though so I don’t understand what I did wrong
@Codemycom
@Codemycom 3 жыл бұрын
@@tibbers2822 No it's not the same, you have a typo. Leave it for a day or two and come back with fresh eyes. The error will jump right out at you then. You've probably been staring at it too long for your brain to notice the typo.
@prachidusa3357
@prachidusa3357 4 жыл бұрын
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.
@aregabgaryan3800
@aregabgaryan3800 5 жыл бұрын
thanks a lot man^^
@Codemycom
@Codemycom 5 жыл бұрын
Sure thing!
@infinitespace1982
@infinitespace1982 4 жыл бұрын
Can we practice these Tkinter tutorials using IDLE Python?
@Codemycom
@Codemycom 4 жыл бұрын
I don't recommend it.
@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).
@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
@icodeint2780
@icodeint2780 4 жыл бұрын
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 4 жыл бұрын
Maybe you used filedialog.askopenfile instead of filedialog.askopenfilename? I confused them at first and got the same error like you
@akshitmiglani5419
@akshitmiglani5419 4 жыл бұрын
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 4 жыл бұрын
Can you explain why you think it's a bad practice? What makes it bad.
@akshitmiglani5419
@akshitmiglani5419 4 жыл бұрын
@@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.
@leela_prasad
@leela_prasad 4 жыл бұрын
Nice video sir, but i have a question: how to browse multiple files from the dialog box?
@Codemycom
@Codemycom 4 жыл бұрын
No idea
@leela_prasad
@leela_prasad 4 жыл бұрын
@@Codemycom ok But thanks so much for response.....
@Codemycom
@Codemycom 4 жыл бұрын
@@leela_prasad Sure thing
@crobes-hx
@crobes-hx 4 жыл бұрын
filedialog.askopenfilenames() with an s at the end.
@leela_prasad
@leela_prasad 4 жыл бұрын
@@crobes-hx awesome thanks a lot
@aryan983983
@aryan983983 5 жыл бұрын
can i open and store images using this?
@Codemycom
@Codemycom 5 жыл бұрын
Try it and see for yourself.
@prachidusa3357
@prachidusa3357 4 жыл бұрын
Hello Sir, I tried executing ur code same as it is in jupyter notebook but it gives attribute error as : 'tuple' object has no attribute 'read'... Kindly plz help me with this query
@Codemycom
@Codemycom 4 жыл бұрын
Yeah running tkinter in juptyer is probably a bad idea
@prachidusa3357
@prachidusa3357 4 жыл бұрын
@@Codemycom ok... thank u for ur response Sir.... actually I made all d installations for Anaconda platform, initially I tried with spyder but didnt worked, so I selected for jupyter notebook. Sir, plz suggest which platform I should use for executing opencv python code, as I'm creating A GUI Application for face recognition using tkinter.
@Codemycom
@Codemycom 4 жыл бұрын
@@prachidusa3357 Just use regular Python and the tools I use in the videos. Sublime text and git bash git-scm.com
@prachidusa3357
@prachidusa3357 4 жыл бұрын
@@Codemycom Sure Sir..and thanks once again..👍
@prachidusa3357
@prachidusa3357 4 жыл бұрын
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.
@coolmanreebro
@coolmanreebro 4 жыл бұрын
Great Tutorial! But can you tell me how to resize the image that you upload?
@Codemycom
@Codemycom 4 жыл бұрын
I have videos on that in the playlist
@Hi.GuysBs
@Hi.GuysBs 3 жыл бұрын
Thank you so mutch!!
@Codemycom
@Codemycom 3 жыл бұрын
Very welcome!
@lamlya6908
@lamlya6908 3 жыл бұрын
You've just save a life 😉
@Codemycom
@Codemycom 3 жыл бұрын
awsome
@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 🙏
@rokkuzner
@rokkuzner 3 жыл бұрын
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 3 жыл бұрын
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 3 жыл бұрын
@@rokkuzner What did you do differently from the video?
@priyabharanidharan3279
@priyabharanidharan3279 2 жыл бұрын
Im a beginner. Your vides are very helpful and resourceful for learning I tried this, but Im getting an error while assigning it to label.image player=ImageTk.PhotoImage(Image.open(main.file_name)) player_pic=Label(main,image=main.file_name) _tkinter.TclError: image "C:/Users/PD/messi.png" doesn't exist. Can you please help me in this
@Codemycom
@Codemycom 2 жыл бұрын
It's telling you what the problem is. C:/Users/PD/messi.png doesn't exist. Your image isn't sitting in the PD/ directory
@priyabharanidharan3279
@priyabharanidharan3279 2 жыл бұрын
@@Codemycom Thanks for the reply. I checked the same and file is there. The Image.open dint throw error. So I assume it could access the file there. Please assist
@Codemycom
@Codemycom 2 жыл бұрын
@@priyabharanidharan3279 Check again, you program says it isn't there. Messi.png isn't the same as messi.png
@akramelomrani8728
@akramelomrani8728 4 жыл бұрын
how could we do the pdf file please
@Codemycom
@Codemycom 4 жыл бұрын
Too complicated to explain in a comment
@akramelomrani8728
@akramelomrani8728 4 жыл бұрын
@@Codemycom I was wondering if you could give me a pice of code
@Codemycom
@Codemycom 4 жыл бұрын
@@akramelomrani8728 no
@bhuvangirishdesai4344
@bhuvangirishdesai4344 3 жыл бұрын
can we open a excel files??
@Codemycom
@Codemycom 3 жыл бұрын
Of course. I have a whole course on excel and python at codemy.com
@barrykruyssen
@barrykruyssen Жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
You likely have a typo in your code...it must be exact
@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
@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
@atharvaathalye
@atharvaathalye 5 жыл бұрын
Sir it gives me error "positional argument follows keyword arguments"
@mohaparchopra6656
@mohaparchopra6656 5 жыл бұрын
could u also attach the code u write in a text file available to us through a link
@Codemycom
@Codemycom 5 жыл бұрын
My code is available on github. github.com/flatplanet/Intro-To-TKinter-KZbin-Course
@moneebk916
@moneebk916 3 жыл бұрын
I don’t know why but my filter ain’t working. All the filetypes I give are applied automatically and then I cannot select any filetype. They automatically apply all types.
@Codemycom
@Codemycom 3 жыл бұрын
You have an error in your code.
@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
@creationandtechwithin4409
@creationandtechwithin4409 4 жыл бұрын
man you are awesome
@Codemycom
@Codemycom 4 жыл бұрын
Thanks!
@Music-bo8ig
@Music-bo8ig 4 жыл бұрын
Hi i created data base now i need to view that data in tkinter window how i do this
@Codemycom
@Codemycom 4 жыл бұрын
Keep watching the videos to learn how
@Music-bo8ig
@Music-bo8ig 4 жыл бұрын
@@Codemycom you have a some video for me
@Codemycom
@Codemycom 4 жыл бұрын
@@Music-bo8ig There are videos in the playlist that cover that...look at the playlist yourself.
@Music-bo8ig
@Music-bo8ig 4 жыл бұрын
I checked no any helpful video😫😫😖
@Codemycom
@Codemycom 4 жыл бұрын
@@Music-bo8ig There's like half a dozen videos on that exact thing. Check again. Or don't.
@ahmedredasaeed2374
@ahmedredasaeed2374 2 жыл бұрын
Thanks alot
@Codemycom
@Codemycom 2 жыл бұрын
Welcome!
Sliders With TKinter - Python Tkinter GUI Tutorial #16
13:11
Codemy.com
Рет қаралды 72 М.
Python GUI open a file (filedialog) 📁
7:38
Bro Code
Рет қаралды 102 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
OpenAI Unveils o3! AGI ACHIEVED!
26:24
Matthew Berman
Рет қаралды 167 М.
Radio Buttons with TKinter - Python Tkinter GUI Tutorial #12
17:44
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 102 М.
Python Tkinter File Dialogs: Opening Files from your File-system
10:35
Convert GUI App to Real Program -  Python to exe to setup wizard
23:27
Python Simplified
Рет қаралды 555 М.
Python GUI save a file (filedialog) 💾
10:26
Bro Code
Рет қаралды 44 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,6 МЛН
How Old Can a File Be?
12:11
Dev Detour
Рет қаралды 71 М.
Use a Drag & Drop Editor to Make Tkinter Python GUI Applications!
11:16