Reputation: 359
My program uses tkinter.asksaveasfilename
function to save a text into another location but when user opens save as dialog, tkinter's empty square window also pops-up. My program works on console so I don't need the tkinter window.
I searched the web and stackoverflow but only found root.withdraw
funtion to hide tkinter window but when I use it before asksaveasfilename
function, save as dialog never pops up. If I use root.withdraw
after asksaveasfilename
function, square empty tkinter window closes after user closes the save as dialog.
Is there a way to hide tkinter window when asksaveasfilename
function is active?
Upvotes: 0
Views: 1153
Reputation: 7680
Does this work for you?:
from tkinter.filedialog import asksaveasfilename
import tkinter as tk
# Create the window
root = tk.Tk()
# Hide the window
root.withdraw()
# Now you are free to popup any dialog that you need
print(asksaveasfilename())
# Destroy the window
root.destroy()
It works for me (Windows 10). I think that it should work for Linux and MacOS too.
Upvotes: 1