Python GUI save a file (filedialog) 💾

preview_player
Показать описание
Python GUI filedialog tkinter save a file tutorial for beginners

#Python #GUI #save #filedialog #tkinter #file #tutorial #beginners

from tkinter import *
from tkinter import filedialog

def saveFile():
defaultextension='.txt',
filetypes=[
("Text file",".txt"),
("HTML file", ".html"),
("All files", ".*"),
])
if file is None:
return
#filetext = input("Enter some text I guess: ") //use this if you want to use console window

window = Tk()
button = Button(text='save',command=saveFile)
text = Text(window)
Рекомендации по теме
Комментарии
Автор

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()

BroCodez
Автор

I'm developing a tool in my job and this tutorial helped me a LOOOOT. Thank you!

alejandropoirier
Автор

Nice tutorial 👍👍very very informative and useful. Thanks for your kindful. 🙏

anokhautomation
Автор

Already liked and subscribed, Commenting now to keep this channel running. Lets beat the algorithm

nikhilrao
Автор

Thanks alot for this simple and effective explaination

sanketgunjal
Автор

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.

rafy-ivanmorales
Автор

Nah bro is a national threat, packing nuclear codes like that😂😂

sidtheepic
Автор

@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)) ?

phantomviper
Автор

Very awesome tutorial, thank you! :3
but why do you have a folder named nuclear launch co...

Dangerous_Milk
Автор

en mi caso es un PDF ya creado con todas sus estancias, como hago para que tome todos los parametros y luego guarde?

devsilva
Автор

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

solomonwiredu
Автор

if i embed a matplotlib graph can i save it as a .png file using this method instead of the matplotlib provided saving method?

Kennerdoll
Автор

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.

leslieGCAX
Автор

thank you for this video, (there is little information about gui in Russia)

qwmmbtp
Автор

Thank you! you are helpful your name should be Pro coder

seifelshlkany
Автор

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

vinayaknayak
Автор

can you please write me how to save a plot by using save window in tkinter?

ahmadmureed
Автор

I want to Save file with all content of window(include Label, Button, Entry, Text) how to? please help

MsDonquihote
Автор

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.

joshtornquist
Автор

why not any one see and comment the nuclear launch codes???? XD

Sirbozo
visit shbcf.ru