6

I would like to use the dialog boxes and message boxes without opening a tkinter window.

Can someone teach me how to disable the window, or how to recreate the window, or show me a different solution which allows me to do such things.

The messageboxes are the same all around, the one I want to try to take advantage of the most is filedialog.askopenfile, filedialog.askdirectory, filedialog.asksaveasfilename.

  • 1
    Welcome to StackOverflow. Did you try looking for tutorials online? Such as this by Googling: http://www.python-course.eu/tkinter_dialogs.php If so, please show effort, which is what you've done and tried, along with the code, that way we can help in a better way. – matrixanomaly Jun 06 '15 at 03:11
  • possible duplicate of [How do I get rid of Python Tkinter root window?](http://stackoverflow.com/questions/1406145/how-do-i-get-rid-of-python-tkinter-root-window) – fhdrsdg Jun 08 '15 at 10:52
  • @matrixanomaly What does your link have to do with the tkinter window from the question? – root Feb 27 '22 at 11:11

1 Answers1

11

Something like this?

from Tkinter import *
import tkFileDialog
import tkMessageBox

Tk().withdraw()
tkFileDialog.askopenfilename()
tkMessageBox.showerror("message", "words")
maccartm
  • 2,035
  • 14
  • 23
  • The problem with this solution is that it hides the file dialog from the task bar. If other windows are in front of the file dialog, you have to minimize each of those windows one by one, or look for the file dialog in the Task View rather than task bar. – root Feb 27 '22 at 11:09