Python GUI save a file (filedialog) 💾

  Рет қаралды 44,377

Bro Code

Bro Code

Күн бұрын

Пікірлер: 73
@BroCodez
@BroCodez 4 жыл бұрын
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()
@blaukampfflieger
@blaukampfflieger 3 жыл бұрын
Thank you :)
@bibashshrestha9471
@bibashshrestha9471 3 жыл бұрын
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
@bibashshrestha9471
@bibashshrestha9471 3 жыл бұрын
Is there a way?
@thesebas3090
@thesebas3090 3 жыл бұрын
only a real Bro leaves the code in the comments and description, thanks!
@alejandropoirier6493
@alejandropoirier6493 2 жыл бұрын
I'm developing a tool in my job and this tutorial helped me a LOOOOT. Thank you!
@rahitechworld589
@rahitechworld589 4 жыл бұрын
Nice video
@nikhilrao6701
@nikhilrao6701 3 жыл бұрын
Already liked and subscribed, Commenting now to keep this channel running. Lets beat the algorithm Broooooooooooooooooooooo
@sanketgunjal6079
@sanketgunjal6079 4 жыл бұрын
Thanks alot for this simple and effective explaination
@BroCodez
@BroCodez 4 жыл бұрын
thanks for watching Sanket!
@Hossein518
@Hossein518 28 күн бұрын
thank you for your amazing videos, good job
@kevinrussell6530
@kevinrussell6530 Жыл бұрын
Great video......as usual!
@johnsonmcdonald292
@johnsonmcdonald292 3 жыл бұрын
Appreciate this. Thanks a lot!
@Yashhhmek28
@Yashhhmek28 6 ай бұрын
Such a nice tutorial ❤
@rafy-ivanmorales3077
@rafy-ivanmorales3077 3 жыл бұрын
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.
@peterschrimpel9375
@peterschrimpel9375 3 жыл бұрын
nice, 3 steps done
@lordmanuels8677
@lordmanuels8677 6 ай бұрын
This video is great!!
@christianihechi
@christianihechi 7 ай бұрын
Thank you once again Bro!
@sidtheepic1103
@sidtheepic1103 8 ай бұрын
Nah bro is a national threat, packing nuclear codes like that😂😂
@Sirbozo
@Sirbozo 6 ай бұрын
why not any one see and comment the nuclear launch codes???? XD
@KevinIsAMilitaryGenius
@KevinIsAMilitaryGenius 3 ай бұрын
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
@vinayaknayak5480
@vinayaknayak5480 4 жыл бұрын
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
@demon4209
@demon4209 4 жыл бұрын
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
@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
@playerwin20
@playerwin20 3 жыл бұрын
When i click save it wont work
@tamptus3479
@tamptus3479 10 ай бұрын
I miss a button to create a folder in the filesavedialog
@Dangerous_Milk
@Dangerous_Milk 2 жыл бұрын
Very awesome tutorial, thank you! :3 but why do you have a folder named nuclear launch co...
@MsDonquihote
@MsDonquihote Жыл бұрын
I want to Save file with all content of window(include Label, Button, Entry, Text) how to? please help
@joshtornquist1937
@joshtornquist1937 4 жыл бұрын
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.
@BroCodez
@BroCodez 4 жыл бұрын
sorry I'm not sure I understand. Do you mean such as having a default file location set up to read/write files to?
@joshtornquist1937
@joshtornquist1937 4 жыл бұрын
​@@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!
@BroCodez
@BroCodez 4 жыл бұрын
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)
@ahmadmureed4739
@ahmadmureed4739 2 жыл бұрын
can you please write me how to save a plot by using save window in tkinter?
@Dani-zy6cf
@Dani-zy6cf 2 жыл бұрын
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
@alexdynamo1385 Жыл бұрын
It very useful for me
@notacupofmilk2021
@notacupofmilk2021 Жыл бұрын
Why does bro code have nuclear launch codes
@nadaviloz11
@nadaviloz11 6 ай бұрын
thank you very much
@deepdaddy1208
@deepdaddy1208 4 жыл бұрын
we meet again bro, great vid
@BroCodez
@BroCodez 4 жыл бұрын
thank you
@hayzelbula9187
@hayzelbula9187 26 күн бұрын
🎉🎉🎉😂😂😂❤
@phantomviper8297
@phantomviper8297 3 жыл бұрын
@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)) ?
@devsilva7155
@devsilva7155 3 жыл бұрын
en mi caso es un PDF ya creado con todas sus estancias, como hago para que tome todos los parametros y luego guarde?
@kjk539876
@kjk539876 3 жыл бұрын
thank you bro
@48-_
@48-_ 2 жыл бұрын
nuclear launch codes O_O
@ОГУРЕЦ-ч2д
@ОГУРЕЦ-ч2д 4 жыл бұрын
thank you for this video ,(there is little information about gui in Russia)
@fentonmsu
@fentonmsu 4 жыл бұрын
Да я знаю, но есть несколько капелек.
@Kennerdoll
@Kennerdoll 3 жыл бұрын
if i embed a matplotlib graph can i save it as a .png file using this method instead of the matplotlib provided saving method?
@leslieGCA7X
@leslieGCA7X 4 жыл бұрын
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.
@beingzero7541
@beingzero7541 2 жыл бұрын
Wow!!!!
@cristiucvladimir7909
@cristiucvladimir7909 7 ай бұрын
thanks bro
@seifelshlkany5032
@seifelshlkany5032 2 жыл бұрын
Thank you! you are helpful your name should be Pro coder
@telckiewell
@telckiewell 2 жыл бұрын
why do u use camel case and no _?
@lockedgaming6081
@lockedgaming6081 3 жыл бұрын
hey, is there a way for it not to be able to have text?
@ghaithdev
@ghaithdev Жыл бұрын
Is it possible to supply a default file name?
@demon4209
@demon4209 4 жыл бұрын
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?
@johnkerch9135
@johnkerch9135 3 жыл бұрын
same man lmao. any fix yet?
@estudosacademicos5237
@estudosacademicos5237 3 жыл бұрын
Muito bom...
@flxshaep632
@flxshaep632 2 жыл бұрын
wont show up for me
@user-yd4zc6lt8z
@user-yd4zc6lt8z 4 жыл бұрын
Bro how do I save an image using tkinter? Please answer...I'm searching for it since 2 days
@BroCodez
@BroCodez 4 жыл бұрын
Do you mean like a PhotoImage?
@user-yd4zc6lt8z
@user-yd4zc6lt8z 4 жыл бұрын
I made a Qrcode maker so I wanted to save image into PNG format just by pressing a button
@flxshaep632
@flxshaep632 2 жыл бұрын
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
@bharaths7816
@bharaths7816 3 жыл бұрын
Can We Use Option Save As PDF To Save It As PDF?? Waiting For Your Reply
@bibashshrestha9471
@bibashshrestha9471 3 жыл бұрын
Instead waiting for reply try it yourself bro...
@joyedet1363
@joyedet1363 2 жыл бұрын
Tried it, it saved. But it's not opening
@gustavoaponte1814
@gustavoaponte1814 Жыл бұрын
meow meow meow~!
@arjunbhardwaj7526
@arjunbhardwaj7526 2 жыл бұрын
this is me helping you
@spike666spike666
@spike666spike666 Жыл бұрын
Thanks for the awesome video! Now how to use encode=('utf-8') within this code.
@barbodrz8645
@barbodrz8645 Ай бұрын
this video is just make a html ide🎉
@KhalilSplash
@KhalilSplash Ай бұрын
Nuclear Launch Codes 💀
@philtoa334
@philtoa334 3 жыл бұрын
: )
@Data_Falcon
@Data_Falcon 7 ай бұрын
bro
@jhassee
@jhassee 2 жыл бұрын
Helping you, help me, By commenting
Learn Python tkinter GUI menubars easy 🧾
10:49
Bro Code
Рет қаралды 22 М.
Read And Write To Text Files - Python Tkinter GUI Tutorial #100
14:33
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Saving and loading in pygame with json
25:23
Clear Code
Рет қаралды 30 М.
Open Files Dialog Box - Python Tkinter GUI Tutorial #15
12:34
Codemy.com
Рет қаралды 195 М.
Malware development 101: Creating your first ever MALWARE
28:00
Leet Cipher
Рет қаралды 395 М.
Intermediate Python Tutorial - Creating a Text Editor App
24:00
Tech With Tim
Рет қаралды 39 М.
Learn Python tkinter GUI listboxes easy 📋
15:00
Bro Code
Рет қаралды 23 М.
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 102 М.
Become a shell wizard in ~12 mins
12:25
CODE IS EVERYTHING
Рет қаралды 263 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,6 МЛН
Python calculator app 🖩
15:08
Bro Code
Рет қаралды 82 М.
Learn Python tkinter GUI scales easy 🌡️
10:20
Bro Code
Рет қаралды 15 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН