-2

I am trying to make a simple notepad using Python 3.4.1 using tkinter. I can open files using Windows Explorer window and get the path (storing file path using windows explorer browser in python , Choosing a file in Python3), but I couldn't find a way to save a file. If the user tries to saves a new file that didn't exist, it gives an error message that the file doesn't exist. I used:

from tkinter import *
app = Tk()
save_file = filedialog.askopenfilename(parent=app, title='Save')

If I type a non-existing file name and press 'Open', it gives an error message.

1
  • 2
    askopenfilename is designed for choosing files to open (as should be obvious from the name). Why not use asksaveasfilename? Commented Nov 24, 2014 at 8:17

1 Answer 1

0

Use could use the class FileChooserDialog from the module gtk:

import gtk

gtk.FileChooserDialog().run()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.