from tkinter import * from tkinter import filedialog def saveFile(): file = filedialog.asksaveasfile(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", defaultextension='.txt', filetypes=[ ("Text file",".txt"), ("HTML file", ".html"), ("All files", ".*"), ]) if file is None: return filetext = str(text.get(1.0,END)) #filetext = input("Enter some text I guess: ") //use this if you want to use console window file.write(filetext) file.close() window = Tk() button = Button(text='save',command=saveFile) button.pack() text = Text(window) text.pack() window.mainloop()
@blaukampfflieger3 жыл бұрын
Thank you :)
@bibashshrestha94713 жыл бұрын
Tq but i m curious about another thing. Suppose we have an output already in tkinter window when we run a code so i want exactly same that is in tkinter window to download as a file instead of taking input from user and saving as a gile
@bibashshrestha94713 жыл бұрын
Is there a way?
@thesebas30903 жыл бұрын
only a real Bro leaves the code in the comments and description, thanks!
@alejandropoirier64932 жыл бұрын
I'm developing a tool in my job and this tutorial helped me a LOOOOT. Thank you!
@rahitechworld5894 жыл бұрын
Nice video
@nikhilrao67013 жыл бұрын
Already liked and subscribed, Commenting now to keep this channel running. Lets beat the algorithm Broooooooooooooooooooooo
@sanketgunjal60794 жыл бұрын
Thanks alot for this simple and effective explaination
@BroCodez4 жыл бұрын
thanks for watching Sanket!
@Hossein51828 күн бұрын
thank you for your amazing videos, good job
@kevinrussell6530 Жыл бұрын
Great video......as usual!
@johnsonmcdonald2923 жыл бұрын
Appreciate this. Thanks a lot!
@Yashhhmek286 ай бұрын
Such a nice tutorial ❤
@rafy-ivanmorales30773 жыл бұрын
Rafy-Ivan Morales 0 seconds ago I'm a new student trying to learn, so I can become a programmer with python and I have a project on how to make a port scan. So far I already make a port scan with Python3, and it scans fine, give a date and everything working good so far. I see on your video tutorial you give example on how to send and receiving data. I would like to ask for your advice if you can and guide me on how I will add this 3 in a Python script, I have: 2. System should look for all the ports between the range of 1 to 1025 3. If the Ports is open, it should create a file and add an entry for port number 4. In case of any exception for instance “host is not available”, “host name could not be resolved” or due to any other error, you need to write that exception into the same file. Thank you and Merry Christmas.
@peterschrimpel93753 жыл бұрын
nice, 3 steps done
@lordmanuels86776 ай бұрын
This video is great!!
@christianihechi7 ай бұрын
Thank you once again Bro!
@sidtheepic11038 ай бұрын
Nah bro is a national threat, packing nuclear codes like that😂😂
@Sirbozo6 ай бұрын
why not any one see and comment the nuclear launch codes???? XD
@KevinIsAMilitaryGenius3 ай бұрын
mine keeps saying AttributeError: 'str' object has no attribute 'write' even though my code is exactly like this:file.write(filetext), and this is the line that it has problems with also when i tried to open the saved files on notpad it didnt recognize them and wanted me to create a new file, even though with the file we saved was asociated with the html property, i even made sure to see the properties segment to be sure it was html
@vinayaknayak54804 жыл бұрын
Hi bro..need ur help.. How can I save the processed image to a folder using tkinter?I mean how can I take any image as an input in this code..plz help
@demon42094 жыл бұрын
heres some code for you for the background u place the image and the image will be shown in the background bg = PhotoImage(file="Images/back.png") canvas.create_image(5, 25, image=bg, anchor="nw")
@solomonwiredu Жыл бұрын
I'm developing a finance app to do some pretty calculations but I don't know how to save my results which is in a tkinter window as a pdf
@playerwin203 жыл бұрын
When i click save it wont work
@tamptus347910 ай бұрын
I miss a button to create a folder in the filesavedialog
@Dangerous_Milk2 жыл бұрын
Very awesome tutorial, thank you! :3 but why do you have a folder named nuclear launch co...
@MsDonquihote Жыл бұрын
I want to Save file with all content of window(include Label, Button, Entry, Text) how to? please help
@joshtornquist19374 жыл бұрын
hey bro, can you give me some advice? My program (1) fetches files from a website and (2) saves it to a folder on the user's computer. The problem is that within the code the user would have to copy down the directory path each time. I'm trying to find a way to (1) open the dialog box and (2) allow the user to choose where those files--the files the program will fetch--will be saved to, and then (3) let the program save the files to the newly chosen file location. Thank you! Also sorry if this isn't well explained. New to coding.
@BroCodez4 жыл бұрын
sorry I'm not sure I understand. Do you mean such as having a default file location set up to read/write files to?
@joshtornquist19374 жыл бұрын
@@BroCodez Sort of. Again, pretty new to coding so I apologize. Let me try again . . . So right now, in my code, in order for some scraped files to be stored, I have to copy and paste the directory: edgar.download_index( *'/Users/josht/Desktop/EDGAR'* , 2018,skip_all_present_except_last=False) I'm trying to utilize the file dialog so that someone using this program can choose where to have those scraped files saved. In turn, this would automatically paste the directory chosen by the user in that line of code shown above. The result: _Open File Dialog > Choose Location > File Path Pasted Into Code > Code Continues_ I hope that's a little bit better explained than before. Thanks bro!
@BroCodez4 жыл бұрын
I see, this might work: after using file dialog, you could get the file location with file.name to return the file path, or even store it in a separate string variable. #************************************* def saveFile(): file = filedialog.asksaveasfile() file_location = file.name #************************************* edgar.download_index( file_location, 2018,skip_all_present_except_last=False)
@ahmadmureed47392 жыл бұрын
can you please write me how to save a plot by using save window in tkinter?
@Dani-zy6cf2 жыл бұрын
If you don't want to specify an specific file path for save the file, you can try this def saveFile(): file = filedialog.asksaveasfile(defaultextension='.txt',filetypes=[("Text file",".txt"),("HTML file", ".html"),("All files", ".*")]) if file is None: return filetext = str(text.get(1.0,END)) #filetext = input("Enter some text I guess: ") //use this if you want to use console window file.write(filetext) file.close()
@alexdynamo1385 Жыл бұрын
It very useful for me
@notacupofmilk2021 Жыл бұрын
Why does bro code have nuclear launch codes
@nadaviloz116 ай бұрын
thank you very much
@deepdaddy12084 жыл бұрын
we meet again bro, great vid
@BroCodez4 жыл бұрын
thank you
@hayzelbula918726 күн бұрын
🎉🎉🎉😂😂😂❤
@phantomviper82973 жыл бұрын
@Bro Code did you do something to prevent the 'file.write(filetext)' from returning an error "filetext is not defined' once you commented out the 'filetext = str(text.get(1.0,END)) ?
@devsilva71553 жыл бұрын
en mi caso es un PDF ya creado con todas sus estancias, como hago para que tome todos los parametros y luego guarde?
@kjk5398763 жыл бұрын
thank you bro
@48-_2 жыл бұрын
nuclear launch codes O_O
@ОГУРЕЦ-ч2д4 жыл бұрын
thank you for this video ,(there is little information about gui in Russia)
@fentonmsu4 жыл бұрын
Да я знаю, но есть несколько капелек.
@Kennerdoll3 жыл бұрын
if i embed a matplotlib graph can i save it as a .png file using this method instead of the matplotlib provided saving method?
@leslieGCA7X4 жыл бұрын
How can i read my file and take it as a variable for using it inside the program?, if i use file as a global variable then pop ups again the asktoopenafile windows. i dont know if you can help me.
@beingzero75412 жыл бұрын
Wow!!!!
@cristiucvladimir79097 ай бұрын
thanks bro
@seifelshlkany50322 жыл бұрын
Thank you! you are helpful your name should be Pro coder
@telckiewell2 жыл бұрын
why do u use camel case and no _?
@lockedgaming60813 жыл бұрын
hey, is there a way for it not to be able to have text?
@ghaithdev Жыл бұрын
Is it possible to supply a default file name?
@demon42094 жыл бұрын
hey bro is there a way to safe file as written in tkinter example i have text boxes etc and i need them to safe however i tried this code but the txt file came back as empty is there a way to fix this?
@johnkerch91353 жыл бұрын
same man lmao. any fix yet?
@estudosacademicos52373 жыл бұрын
Muito bom...
@flxshaep6322 жыл бұрын
wont show up for me
@user-yd4zc6lt8z4 жыл бұрын
Bro how do I save an image using tkinter? Please answer...I'm searching for it since 2 days
@BroCodez4 жыл бұрын
Do you mean like a PhotoImage?
@user-yd4zc6lt8z4 жыл бұрын
I made a Qrcode maker so I wanted to save image into PNG format just by pressing a button
@flxshaep6322 жыл бұрын
i get this wierd thing. on filetext = str(text.get(1.0,END)) it says "function" object has no attribute "get" i have no idead what i did wrong i even copied ur line of text but still the same disgusting ass problem P.S i get this error when i close out of the save tab P.S again. I also get the same thing on text.write
@bharaths78163 жыл бұрын
Can We Use Option Save As PDF To Save It As PDF?? Waiting For Your Reply
@bibashshrestha94713 жыл бұрын
Instead waiting for reply try it yourself bro...
@joyedet13632 жыл бұрын
Tried it, it saved. But it's not opening
@gustavoaponte1814 Жыл бұрын
meow meow meow~!
@arjunbhardwaj75262 жыл бұрын
this is me helping you
@spike666spike666 Жыл бұрын
Thanks for the awesome video! Now how to use encode=('utf-8') within this code.