Reputation: 201
I am using python 3.6 and have the following issue. These lines of codes apparently open two windows, but I only expect one to be opened.
from tkinter.filedialog import asksaveasfilename
file_name = asksaveasfilename()
root.withdraw()
Upvotes: 2
Views: 3976
Reputation: 76254
IIRC, you're supposed to call withdraw
before you call asksaveasfilename
. Same as in Choosing a file in Python with simple Dialog.
import tkinter
from tkinter.filedialog import asksaveasfilename
tkinter.Tk().withdraw()
file_name = asksaveasfilename()
Upvotes: 4
Reputation: 720
when you do filename = asksaveasfilename()
you call the function
and that makes tkinter open the second window put that in a function and on
a button click the second window will open
from tkinter.filedialog import asksaveasfilename
import tkinter
root = tkinter.Tk()
root.withdraw()
asksaveasfilename()
Upvotes: 1