You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some tkinter query methods return int or a raw value instead of bool #153422
A few tkinter query methods with a boolean result return int or a raw Tcl value instead of bool:
Misc.winfo_exists(), Misc.winfo_ismapped() and Misc.winfo_viewable() return int (they use getint()).
Text.edit_modified() returns the raw result of edit modified, so its type depends on wantobjects: int when it is on, str ('0'/'1') when it is off.
All the other boolean-valued query methods already return a proper bool: Misc.winfo_colormapfull(), winfo_isdark(), tk_busy_status(), wm_overrideredirect(), wm_stackorder(isabove/isbelow), Text.compare(), edit_canundo(), edit_canredo(), pendingsync(), the selection_present()/selection_includes()/validate() methods of Entry, Listbox and Spinbox, PhotoImage.transparency_get(), ttk.Widget.instate(), and the ttk.Treeview predicates (haschildren(), visible(), detached(), cellselection_includes(), cellselection_present(), tag_cell_has()).
I propose to make the four outliers consistent:
the three winfo_* methods use getboolean() instead of getint();
edit_modified() coerces the query result with getboolean() (the setter form, with an argument, is unchanged).
bool is a subclass of int, so existing boolean and arithmetic uses keep working; only code relying on the exact int/str type of the result is affected.
The winfo_* methods have coerced the result to int since the initial revision of tkinter, predating the bool type (added in Python 2.3) -- at the time there was no boolean type to return, and the choice was never revisited when bool was introduced.
IDLE uses Misc.winfo_viewable in tooltip tests, passed to assertTrue/False called, so no problem. edit_modified and edit modified are not found, so IDLE is keeping track of dirty windows otherwise.
Activity
terryjreedy commentedon Jul 9, 2026
IDLE uses
Misc.winfo_viewablein tooltip tests, passed to assertTrue/False called, so no problem.edit_modifiedandedit modifiedare not found, so IDLE is keeping track of dirty windows otherwise.gh-153422: Return bool from some tkinter query methods (GH-153429)
[3.15] gh-153422: Assert bool return type in tkinter tests (GH-153429) (
[3.14] gh-153422: Assert bool return type in tkinter tests (GH-153429) (
[3.13] gh-153422: Assert bool return type in tkinter tests (GH-153429) (