Get a file name with tkinter.filedialog.asksaveasfilename to append in it
<p>from an GUI application designed with <code>tkinter</code>, I wish to save some datas in a file in appending mode. To get the file's name I use <code>asksaveasfilename</code> from <code>filedialog</code> module. Here is the code:</p>

<pre><code>from tkinter.filedialog import asksaveasfilename

def save_file():

    file_name = asksaveasfilename()

    if file_name:
        f = open(file_name, 'a')
        contents = tab_chrono.text_area.get(1.0, 'end')
        f.write(contents)
        f.close()
</code></pre>

<p>The problem happens when I select in the dialog an existing file, I got a warning that the file will be overwritten. It is not true since I append in the file. 
Is there a way to get rid of this warning ? Or do I have to rewrite a <code>askappendfilename</code> myself ? This is missing in <code>filedialog</code> module.
<a href="https://i.stack.imgur.com/mPL5s.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/mPL5s.jpg" alt="enter image description here"></a></p>

<p>The <code>asksaveasfilename</code> dialog accepts a <code>confirmoverwrite</code> argument to enable or disable the file existence check.</p>

<pre><code>file_name = asksaveasfilename(confirmoverwrite=False)
</code></pre>

<p>This can be found in the Tk manual for <a href="http://www.tcl.tk/man/tcl8.5/TkCmd/getOpenFile.htm" rel="nofollow">tk_getSaveFile</a> but doesn't appear to be documented for tkinter. It was introduced in Tk 8.5.11 so is relatively new in Tk terms (released Nov 2011).</p>

python tkinter filedialog