-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.

Community
  • 1
  • 1
  • 2
    `askopenfilename` is designed for choosing files to *open* (as should be obvious from the name). Why not use `asksaveasfilename`? – jonrsharpe Nov 24 '14 at 08:17

1 Answers1

0

Use could use the class FileChooserDialog from the module gtk:

import gtk

gtk.FileChooserDialog().run()
user3426575
  • 1,723
  • 12
  • 18