Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created September 25, 2020 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/88d807e26a6dcab743a5179ef266a3d0 to your computer and use it in GitHub Desktop.
Save amankharwal/88d807e26a6dcab743a5179ef266a3d0 to your computer and use it in GitHub Desktop.
def save_file():
"""Save the current file as a new file."""
filepath = asksaveasfilename(
defaultextension="txt",
filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")],
)
if not filepath:
return
with open(filepath, "w") as output_file:
text = txt_edit.get("1.0", tk.END)
output_file.write(text)
window.title(f"Thecleverprogrammer - {filepath}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment