GUI and Desktop Modules

tkinter.simpledialog

Collects text or numeric input through modal dialogs. askinteger, askfloat and askstring return the requested type or None if cancelled. Numeric helpers support bounds; cancellation must be handled separately from valid zero. The example mocks the dialog object rather than opening a window.

Formal Syntax & Structure

python syntaxpython
import tkinter.simpledialog

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from tkinter.simpledialog import askintegerfrom unittest.mock import patchwith patch("tkinter.simpledialog._QueryInteger") as dialog:    dialog.return_value.result = 0    print(askinteger("Count", "How many?"))
Python Reference