Feature or enhancement
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.
Linked PRs
Feature or enhancement
A few
tkinterquery methods with a boolean result returnintor a raw Tcl value instead ofbool:Misc.winfo_exists(),Misc.winfo_ismapped()andMisc.winfo_viewable()returnint(they usegetint()).Text.edit_modified()returns the raw result ofedit modified, so its type depends onwantobjects:intwhen 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(), theselection_present()/selection_includes()/validate()methods ofEntry,ListboxandSpinbox,PhotoImage.transparency_get(),ttk.Widget.instate(), and thettk.Treeviewpredicates (haschildren(),visible(),detached(),cellselection_includes(),cellselection_present(),tag_cell_has()).I propose to make the four outliers consistent:
winfo_*methods usegetboolean()instead ofgetint();edit_modified()coerces the query result withgetboolean()(the setter form, with an argument, is unchanged).boolis a subclass ofint, so existing boolean and arithmetic uses keep working; only code relying on the exactint/strtype of the result is affected.The
winfo_*methods have coerced the result tointsince the initial revision of tkinter, predating thebooltype (added in Python 2.3) -- at the time there was no boolean type to return, and the choice was never revisited whenboolwas introduced.Linked PRs