0

Why this snippet:

import tkinter as tk
print(tk.simpledialog.askstring('_', '_'))

produces this error:

AttributeError: module 'tkinter' has no attribute 'simpledialog'

There is a simpledialog module (https://docs.python.org/3/library/dialog.html#module-tkinter.simpledialog). This code works:

from tkinter import simpledialog
print(simpledialog.askstring('_', '_'))
Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72
  • 1
    If you say `import tkinter.simpledialog`, then you can say `tkinter.simpledialog.askstring`. `tkinter`, being an antique, does not use the technique of importing all of the submodules in its `__init__.py`. – Tim Roberts Nov 03 '22 at 04:17

0 Answers0