- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
asksaveasfile() function in Python Tkinter
TKinter is a Python module which is used for GUI programming in Python. We create a Canvas and place our UI components with many properties and behaviors in it. In this article, we will see e how to use the ask essay file function to save files created through Python programs into the local drives.
We first create a canvas on which we again place a button using the TTK dot button function. Then declare another function that will use the ask fine to define the file type and save the file into location in the local drive.
from tkinter import * from tkinter import ttk from tkinter.filedialog import asksaveasfile base = Tk() base.geometry('300x250') def SaveFile(): data = [('All tyes(*.*)', '*.*')] file = asksaveasfile(filetypes = data, defaultextension = data) save_btn = ttk.Button(base, text = 'Click to save file ', command = lambda : SaveFile()) save_btn.pack(side = TOP, pady = 20,padx = 50) mainloop()
Running the above code gives us the following result −
Next on clicking the “click to save file as” button, we get the next window as below.
- askopenfile() function in Python Tkinter
- Binding function in Python Tkinter
- Tkinter Programming in Python
- Function to close the window in Tkinter
- How to return a JSON object from a Python function in Tkinter?
- How to stop Tkinter after function?
- destroy() method in Tkinter - Python
- Different messages in Tkinter - Python
- Python - geometry method in Tkinter
- after method in Python Tkinter
- Collapsible Pane in Tkinter Python
- Progressbar widget in Python Tkinter
- Mouse Position in Python Tkinter
- Develop Notepad using Tkinter in python
- Color game using Tkinter in Python