summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/__init__.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-118760: Restore the default value of tkinter.wantobjects to 1 ↵Miss Islington (bot)2024-05-201-1/+1
| | | | | | | | (GH-118784) (GH-119251) It was set to 2 in 65f5e586a1239ed1a66d8284773d7b02ce40e480 (GH-98592). (cherry picked from commit e188527c343c74574d481b77c30063db1436e62b) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-118760: Fix errors in calling Tkinter bindings on Windows ↵Miss Islington (bot)2024-05-151-0/+3
| | | | | | | | | (GH-118782) (GH-119072) For unknown reasons some arguments for Tkinter binding can be created as a 1-tuple containing a Tcl_Obj when wantobjects is 2. (cherry picked from commit 5b88d95cc542cf02303c6fe0e8719a93544decdb) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-66410: Do not stringify arguments of Tkinter callback (GH-98592)Serhiy Storchaka2024-05-071-2/+5
| | | | | | | | | Callbacks registered in the tkinter module now take arguments as various Python objects (int, float, bytes, tuple), not just str. To restore the previous behavior set tkinter module global wantobject to 1 before creating the Tk object or call the wantobject() method of the Tk object with argument 1. Calling it with argument 2 restores the current default behavior.
* gh-71592: Add ability to trace Tcl commands executed by Tkinter (GH-118291)Serhiy Storchaka2024-05-061-4/+15
| | | | | | | | | | | | This is an experimental feature, for internal use. Setting tkinter._debug = True before creating the root window enables printing every executed Tcl command (or a Tcl command equivalent to the used Tcl C API). This will help to convert a Tkinter example into Tcl script to check whether the issue is caused by Tkinter or exists in the underlying Tcl/Tk library.
* gh-118271: Support more options for reading/writing images in Tkinter ↵Serhiy Storchaka2024-05-061-11/+111
| | | | | | | | (GH-118273) * Add PhotoImage.read() to read an image from a file. * Add PhotoImage.data() to get the image data. * Add background and grayscale parameters to PhotoImage.write().
* gh-118225: Support more options for copying images in Tkinter (GH-118228)Serhiy Storchaka2024-05-061-16/+95
| | | | | | | | * Add the PhotoImage method copy_replace() to copy a region from one image to other image, possibly with pixel zooming and/or subsampling. * Add from_coords parameter to PhotoImage methods copy(), zoom() and subsample(). * Add zoom and subsample parameters to PhotoImage method copy().
* bpo-32839: Add the after_info() method for Tkinter widgets (GH-5664)Cheryl Sabella2024-04-261-0/+15
|
* gh-116484: Fix collisions between Checkbutton and ttk.Checkbutton default ↵Serhiy Storchaka2024-03-161-1/+6
| | | | | | | | names (GH-116495) Change automatically generated tkinter.Checkbutton widget names to avoid collisions with automatically generated tkinter.ttk.Checkbutton widget names within the same parent widget.
* gh-97928: Partially restore the behavior of tkinter.Text.count() by default ↵Serhiy Storchaka2024-02-111-8/+15
| | | | | | | | | | | | | (GH-115031) By default, it preserves an inconsistent behavior of older Python versions: packs the count into a 1-tuple if only one or none options are specified (including 'update'), returns None instead of 0. Except that setting wantobjects to 0 no longer affects the result. Add a new parameter return_ints: specifying return_ints=True makes Text.count() always returning the single count as an integer instead of a 1-tuple or None.
* gh-43457: Tkinter: fix design flaws in wm_attributes() (GH-111404)Serhiy Storchaka2024-02-051-19/+32
| | | | | | | | | * When called with a single argument to get a value, it allow to omit the minus prefix. * It can be called with keyword arguments to set attributes. * w.wm_attributes(return_python_dict=True) returns a dict instead of a tuple (it will be the default in future). * Setting wantobjects to 0 no longer affects the result.
* gh-113951: Tkinter: "tag_unbind(tag, sequence, funcid)" now only unbinds ↵Serhiy Storchaka2024-02-041-11/+15
| | | | | | | | | | | "funcid" (GH-113955) Previously, "tag_unbind(tag, sequence, funcid)" methods of Text and Canvas widgets destroyed the current binding for "sequence", leaving "sequence" unbound, and deleted the "funcid" command. Now they remove only "funcid" from the binding for "sequence", keeping other commands, and delete the "funcid" command. They leave "sequence" unbound only if "funcid" was the last bound command.
* gh-110345: show Tcl/Tk patchlevel in `tkinter._test()` (GH-110350)Christopher Chavez2024-01-181-1/+1
|
* gh-113877: Fix Tkinter method winfo_pathname() on 64-bit Windows (GH-113900)Serhiy Storchaka2024-01-101-0/+2
| | | | | winfo_id() converts the result of "winfo id" command to integer, but "winfo pathname" command requires an argument to be a hexadecimal number on Win64.
* gh-75666: Tkinter: "unbind(sequence, funcid)" now only unbinds "funcid" ↵Serhiy Storchaka2023-12-061-4/+18
| | | | | | | | | | | | | (GH-111322) Previously, "widget.unbind(sequence, funcid)" destroyed the current binding for "sequence", leaving "sequence" unbound, and deleted the "funcid" command. Now it removes only "funcid" from the binding for "sequence", keeping other commands, and deletes the "funcid" command. It leaves "sequence" unbound only if "funcid" was the last bound command. Co-authored-by: GiovanniL <13402461+GiovaLomba@users.noreply.github.com>
* gh-111531: Tkinter: fix reference leaks in bind_class() and bind_all() ↵Serhiy Storchaka2023-10-311-2/+2
| | | | (GH-111533)
* gh-97928: Change the behavior of tkinter.Text.count() (GH-98484)Serhiy Storchaka2023-10-241-13/+16
| | | | | | | It now always returns an integer if one or less counting options are specified. Previously it could return a single count as a 1-tuple, an integer (only if option "update" was specified) or None if no items found. The result is now the same if wantobjects is set to 0.
* gh-72684: Tkinter: provide interface for "tk busy" subcommands (GH-107684)Serhiy Storchaka2023-08-191-0/+79
| | | | Add tkinter.Misc methods: tk_busy_hold(), tk_busy_configure(), tk_busy_cget(), tk_busy_forget(), tk_busy_current(), and tk_busy_status().
* gh-100814: Fix exception for invalid callable value of Tkinter image option ↵Serhiy Storchaka2023-08-071-4/+0
| | | | | | | (GH-107692) Passing a callable object as an option value to a Tkinter image now raises the expected TclError instead of an AttributeError.
* gh-94473: Flatten arguments in tkinter.Canvas.coords() (GH-98479)Serhiy Storchaka2023-05-221-1/+1
| | | | | It now accepts not only "x1, y1, x2, y2, ..." and "[x1, y1, x2, y2, ...]", but also "(x1, y1), (x2, y2), ..." and "[(x1, y1), (x2, y2), ...]".
* gh-103685: Fix tkinter.Menu.index() for Tk 8.7 (#103686)Christopher Chavez2023-04-241-2/+1
| | | | | | --------- Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-102778: Add sys.last_exc, deprecate sys.last_type, ↵Irit Katriel2023-03-181-0/+1
| | | | sys.last_value,sys.last_traceback (#102779)
* gh-57762: fix misleading tkinter.Tk docstring (#98837)Shantanu2022-12-221-1/+1
| | | | Mentioned as a desired change by terryjreedy on the corresponding issue, since Tk is not a subclass of Toplevel.
* gh-97928: Fix handling options starting with "-" in tkinter.Text.count() ↵Serhiy Storchaka2022-10-191-1/+1
| | | | | (GH-98436) Previously they were silently ignored. Now they are errors.
* gh-73588: Fix generation of the default name of tkinter.Checkbutton. (GH-97547)Serhiy Storchaka2022-09-271-1/+11
| | | | | | Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique.
* bpo-13553: Document tkinter.Tk args (#4786)Cheryl Sabella2022-05-101-4/+4
|
* gh-91827: Add method info_pathlevel() in tkinter (GH-91829)Serhiy Storchaka2022-05-061-0/+28
|
* Fix typos in the Lib directory (GH-28775)Christian Clauss2021-10-061-3/+3
| | | | | Fix typos in the Lib directory as identified by codespell. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* bpo-44404: tkinter `after` support callable classes (GH-26812)E-Paine2021-06-231-1/+5
|
* bpo-38659: [Enum] add _simple_enum decorator (GH-25497)Ethan Furman2021-04-211-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add: * `_simple_enum` decorator to transform a normal class into an enum * `_test_simple_enum` function to compare * `_old_convert_` to enable checking `_convert_` generated enums `_simple_enum` takes a normal class and converts it into an enum: @simple_enum(Enum) class Color: RED = 1 GREEN = 2 BLUE = 3 `_old_convert_` works much like` _convert_` does, using the original logic: # in a test file import socket, enum CheckedAddressFamily = enum._old_convert_( enum.IntEnum, 'AddressFamily', 'socket', lambda C: C.isupper() and C.startswith('AF_'), source=_socket, ) `_test_simple_enum` takes a traditional enum and a simple enum and compares the two: # in the REPL or the same module as Color class CheckedColor(Enum): RED = 1 GREEN = 2 BLUE = 3 _test_simple_enum(CheckedColor, Color) _test_simple_enum(CheckedAddressFamily, socket.AddressFamily) Any important differences will raise a TypeError
* Revert "bpo-38659: [Enum] add _simple_enum decorator (GH-25285)" (GH-25476)Ethan Furman2021-04-201-2/+3
| | | This reverts commit dbac8f40e81eb0a29dc833e6409a1abf47467da6.
* bpo-38659: [Enum] add _simple_enum decorator (GH-25285)Ethan Furman2021-04-201-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add: _simple_enum decorator to transform a normal class into an enum _test_simple_enum function to compare _old_convert_ to enable checking _convert_ generated enums _simple_enum takes a normal class and converts it into an enum: @simple_enum(Enum) class Color: RED = 1 GREEN = 2 BLUE = 3 _old_convert_ works much like _convert_ does, using the original logic: # in a test file import socket, enum CheckedAddressFamily = enum._old_convert_( enum.IntEnum, 'AddressFamily', 'socket', lambda C: C.isupper() and C.startswith('AF_'), source=_socket, ) test_simple_enum takes a traditional enum and a simple enum and compares the two: # in the REPL or the same module as Color class CheckedColor(Enum): RED = 1 GREEN = 2 BLUE = 3 _test_simple_enum(CheckedColor, Color) _test_simple_enum(CheckedAddressFamily, socket.AddressFamily) Any important differences will raise a TypeError
* bpo-33289: Return RGB triplet of ints instead of floats from ↵Cheryl Sabella2021-01-211-2/+1
| | | | tkinter.colorchooser (GH-6578)
* bpo-42759: Fix equality comparison of Variable and Font in Tkinter (GH-23968)Serhiy Storchaka2020-12-291-7/+3
| | | | Objects which belong to different Tcl interpreters are now always different, even if they have the same name.
* bpo-42721: Improve using simple dialogs without root window (GH-23897)Serhiy Storchaka2020-12-251-0/+25
| | | | | | | | | | | | | | | | | When simple query dialogs (tkinter.simpledialog), message boxes (tkinter.messagebox) or color choose dialog (tkinter.colorchooser) are created without arguments master and parent, and the default root window is not yet created, a new temporary hidden root window will be created automatically. It will not be set as the default root window and will be destroyed right after closing the dialog window. It will help to use these simple dialog windows in programs which do not need other GUI. Previously, message boxes and color chooser created the blank root window and left it after closing the dialog window, and query dialogs just raised an exception. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* bpo-15303: Support widgets with boolean value False in Tkinter (GH-23904)Serhiy Storchaka2020-12-251-8/+8
| | | Use `widget is None` instead of checking the boolean value of a widget.
* bpo-42630: Improve error reporting in Tkinter for absent default root (GH-23781)Serhiy Storchaka2020-12-191-21/+30
| | | | | | | | | | | * Tkinter functions and constructors which need a default root window raise now RuntimeError with descriptive message instead of obscure AttributeError or NameError if it is not created yet or cannot be created automatically. * Add tests for all functions which use default root window. * Fix import in the pynche script.
* bpo-41831: Restore str implementation of __str__ in tkinter.EventType (GH-22355)Serhiy Storchaka2020-10-091-3/+2
|
* bpo-41817: use new StrEnum to ensure all members are strings (GH-22348)Ethan Furman2020-09-221-7/+7
| | | * use new StrEnum to ensure all members are strings
* bpo-41384: Raise TclError in tkinter.OptionMenu (GH-21601)Akuli2020-07-271-1/+1
| | | | | ... when an unknown option is passed. TypeError was being raised because a 2to3 fix was missing. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* bpo-38738: Fix formatting of True and False. (GH-17083)Serhiy Storchaka2019-11-121-2/+2
| | | | | | | | | * "Return true/false" is replaced with "Return ``True``/``False``" if the function actually returns a bool. * Fixed formatting of some True and False literals (now in monospace). * Replaced "True/False" with "true/false" if it can be not only bool. * Replaced some 1/0 with True/False if it corresponds the code. * "Returns <bool>" is replaced with "Return <bool>".
* bpo-15999: Clean up of handling boolean arguments. (GH-15610)Serhiy Storchaka2019-09-011-3/+3
| | | | | | * Use the 'p' format unit instead of manually called PyObject_IsTrue(). * Pass boolean value instead 0/1 integers to functions that needs boolean. * Convert some arguments to boolean only once.
* bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)Serhiy Storchaka2019-08-081-0/+2
| | | | They now return NotImplemented for unsupported type of the other operand.
* bpo-29446: tkinter 'import *' only imports what it should (GH-14864)Flavian Hautbois2019-07-261-1/+5
| | | | Add __all__ to tkinter.__init__ and submodules. Replace 'import *' with explicit imports in some submodules.
* bpo-25451: Add transparency methods to tkinter.PhotoImage. (GH-10406)Zackery Spytz2019-04-051-0/+9
|
* bpo-34936: Fix TclError in tkinter.Spinbox.selection_element(). (GH-9760)Juliette Monsel2018-10-181-4/+4
|
* bpo-23831: Add moveto method to the tkinter.Canvas widget. (GH-9768)Juliette Monsel2018-10-121-0/+9
|
* bpo-34964: Make Tkinter sources more readable by adding blank lines. (GH-9822)Serhiy Storchaka2018-10-121-4/+533
|
* bpo-34829: Add missing selection_ methods to the Tkinter Spinbox. (GH-9617)Juliette Monsel2018-10-081-0/+18
| | | | | Implement the methods selection_from(), selection_range(), selection_present() and selection_to() for Tkinter Spinbox.
* bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)Serhiy Storchaka2018-06-301-1/+4
| | | | Fix passing lists and tuples of strings containing special characters '"', '\\', '{', '}' and '\n' as options to tkinter.ttk widgets.
* bpo-33283: Mention PNG as a supported format by Tcl/Tk. (GH-6479)Andrés Delfino2018-04-171-2/+2
|