Commit graph

479 commits

Author SHA1 Message Date
Łukasz Langa 54d1e3f72e
bpo-45160: Fix refleak in test_ttk_guionly introduced in GH-28291 (GH-29416) 2021-11-05 09:51:31 +01:00
E-Paine add46f8476
bpo-45160: Ttk optionmenu only set variable once (GH-28291) 2021-10-21 22:25:52 +02:00
Gregory P. Smith 1dfac27dff
Cleanup a couple of comments left on PR 28775 post-merge. (GH-29079) 2021-10-20 09:17:52 -07:00
Zachary Ware 4fe454c6f5
bpo-45436: Fix tkinter tests with Tcl/Tk 8.6.11+ (GH-29077)
Since v8.6.11, a few configuration options seem to accept an empty value
where they did not previously; particularly the `type` of a `Menu`
widget, and the `compound` of any ttk widget with a label.  Providing an
explicit expected error message to `checkEnumParam` bypasses the check
of an empty value, which no longer raises `TclError`.
2021-10-19 21:54:19 -05:00
Serhiy Storchaka f59ed3c310
bpo-45229: Make tkinter tests discoverable (GH-28637) 2021-10-13 18:12:48 +02:00
Christian Clauss 745c9d9dfc
Fix typos in the Lib directory (GH-28775)
Fix typos in the Lib directory as identified by codespell.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-10-06 16:13:48 -07:00
Serhiy Storchaka 2a8127cafe
bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005) 2021-08-29 14:04:40 +03:00
E-Paine e9c8f784fa
bpo-44404: tkinter after support callable classes (GH-26812) 2021-06-23 13:30:24 +03:00
wyz23x2 4a2d98a1e9
bpo-41730: Show deprecation warnings for tkinter.tix (GH-22186)
Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
Co-authored-by: Zachary Ware <zach@python.org>
2021-05-07 10:53:23 -05:00
Serhiy Storchaka 3bb3fb3be0
bpo-43655: Tkinter and IDLE dialog windows are now recognized as dialogs by window managers on macOS and X Window (#25187) 2021-04-25 13:07:58 +03:00
Ethan Furman a02cb474f9
bpo-38659: [Enum] add _simple_enum decorator (GH-25497)
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
2021-04-21 10:20:44 -07:00
Ethan Furman 503cdc7c12
Revert "bpo-38659: [Enum] add _simple_enum decorator (GH-25285)" (GH-25476)
This reverts commit dbac8f40e8.
2021-04-19 19:12:24 -07:00
Ethan Furman dbac8f40e8
bpo-38659: [Enum] add _simple_enum decorator (GH-25285)
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
2021-04-19 18:04:53 -07:00
Cheryl Sabella 6713e869c4
bpo-33289: Return RGB triplet of ints instead of floats from tkinter.colorchooser (GH-6578) 2021-01-21 21:14:04 +02:00
Serhiy Storchaka 1df56bc059
bpo-42759: Fix equality comparison of Variable and Font in Tkinter (GH-23968)
Objects which belong to different Tcl interpreters are now always
different, even if they have the same name.
2020-12-29 12:56:55 +02:00
Serhiy Storchaka c1ae21c965
Rename Tkinter tests for widget options (GH-23944)
Every test for widget option starts now with "test_configure_"
to distinguish it from tests for widget commands.
2020-12-26 00:10:29 +02:00
Desmond Cheong 36a779e64c
bpo-35728: Add root parameter to tkinter.font.nametofont() (GH-23885) 2020-12-25 23:18:06 +02:00
Serhiy Storchaka 675c97eb6c
bpo-42721: Improve using simple dialogs without root window (GH-23897)
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>
2020-12-25 20:19:20 +02:00
Serhiy Storchaka bb70b2afe3
bpo-15303: Support widgets with boolean value False in Tkinter (GH-23904)
Use `widget is None` instead of checking the boolean value of a widget.
2020-12-25 17:04:26 +02:00
Serhiy Storchaka c6c43b2874
bpo-42685: Improve placing of simple query windows. (GH-23856)
* If parent is specified and mapped, the query widget is
  centered at the center of parent. Its position and size
  can be corrected so that it fits in the virtual root window.
* Otherwise it is centered at the center of the screen.
2020-12-24 20:26:28 +02:00
Serhiy Storchaka 3d569fd6dc
bpo-42630: Improve error reporting in Tkinter for absent default root (GH-23781)
* 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.
2020-12-19 12:17:08 +02:00
Serhiy Storchaka 5f0fe8ec70
bpo-19733: Re-enable tests for -image option in Tkinter (GH-23785) 2020-12-16 12:31:49 +02:00
E-Paine b9ced83cf4
bpo-40219: Lowered ttk LabeledScale dummy (GH-21467) 2020-12-15 21:42:55 +02:00
Serhiy Storchaka f3c3ea91a7
bpo-42328: Skip some tests with themes vista and xpnative on Windows 7 (GH-23612) 2020-12-03 10:48:26 +02:00
Serhiy Storchaka 6cc2c419f6
bpo-42142: Try to fix timeouts in ttk tests (GH-23474)
Instead of using wait_visibility() which waits event <VisibilityNotify> in dead loop
use update() which should proceed all queued events.
2020-11-30 10:24:07 +02:00
Serhiy Storchaka b0b428510c
bpo-42370: Check element before making mouse click in ttk tests (GH-23491) 2020-11-24 19:35:39 +02:00
Serhiy Storchaka dd844a2916
bpo-42328: Fix tkinter.ttk.Style.map(). (GH-23300)
The function accepts now the representation of the default state as
empty sequence (as returned by Style.map()).
The structure of the result is now the same on all platform
and does not depend on the value of wantobjects.
2020-11-22 22:48:52 +02:00
Anatoliy Platonov b4d895336a
bpo-41876: Overload __repr__ for tkinter Font objects (GH-22450) 2020-10-14 13:02:51 +03:00
Serhiy Storchaka eb38c6b7aa
bpo-41831: Restore str implementation of __str__ in tkinter.EventType (GH-22355) 2020-10-09 22:57:34 +03:00
Serhiy Storchaka f25323a307
bpo-41831: Add tests for tkinter.Event.__repr__ (GH-22354) 2020-10-09 21:45:46 +03:00
E-Paine aecf036738
bpo-41306: Allow scale value to not be rounded (GH-21715)
This fixes the test failure with Tk 6.8.10 which is caused by changes to how Tk rounds the `from`, `to` and `tickinterval` arguments. This PR uses `noconv` if the patchlevel is greater than or equal to 8.6.10 (credit to Serhiy for this idea as it is much simpler than what I previously proposed).

Going into more detail for those who want it, the Tk change was made in [commit 591f68c](591f68cb38) and means that the arguments listed above are rounded relative to the value of `from`. However, when rounding the `from` argument ([line 623](591f68cb38/generic/tkScale.c (L623))), it is rounded relative to itself (i.e. rounding `0`) and therefore the assigned value for `from` is always what is given (no matter what values of `from` and `resolution`).

Automerge-Triggered-By: @pablogsal
2020-10-08 06:30:13 -07:00
Ethan Furman ea0711a9f9
bpo-41817: use new StrEnum to ensure all members are strings (GH-22348)
* use new StrEnum to ensure all members are strings
2020-09-22 08:01:17 -07:00
Hai Shi 79bb2c93f2
bpo-40275: Use new test.support helper submodules in tests (GH-21743) 2020-08-06 13:51:29 +02:00
Akuli f1d40f941a
bpo-41384: Raise TclError in tkinter.OptionMenu (GH-21601)
... 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>
2020-07-26 21:48:17 -04:00
Terry Jan Reedy 5ea7bb25e3
bpo-39152: add missing ttk.Scale.configure return value (GH-17815)
tkinter.ttk.Scale().configure([name]) now returns a configuration tuple for name
or a list thereof for all options. Based on patch Giovanni Lombardo.
2020-01-05 11:23:58 -05:00
Gurupad Hegde 6c7bb38ff2 bpo-39136: Fixed typos (GH-17720)
funtion -> function; configuraton -> configuration; defintitions -> definitions;
focusses -> focuses; necesarily -> necessarily; follwing -> following;
Excape -> Escape,
2019-12-28 17:16:02 -05:00
Serhiy Storchaka 138ccbb022
bpo-38738: Fix formatting of True and False. (GH-17083)
* "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>".
2019-11-12 16:57:03 +02:00
Serhiy Storchaka 06cb94bc84
bpo-13153: Use OS native encoding for converting between Python and Tcl. (GH-16545)
On Windows use UTF-16 (or UTF-32 for 32-bit Tcl_UniChar) with the
"surrogatepass" error handler for converting to/from Tcl Unicode objects.

On Linux use UTF-8 with the "surrogateescape" error handler for converting
to/from Tcl String objects.

Converting strings from Tcl to Python and back now never fails
(except MemoryError).
2019-10-04 13:09:52 +03:00
Serhiy Storchaka 1f21eaa15e
bpo-15999: Clean up of handling boolean arguments. (GH-15610)
* 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.
2019-09-01 12:16:51 +03:00
Min ho Kim 39d87b5471 Fix typos mostly in comments, docs and test names (GH-15209) 2019-08-30 16:21:19 -04:00
Serhiy Storchaka 662db125cd
bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
2019-08-08 08:42:54 +03:00
Flavian Hautbois 76b645124b bpo-29446: tkinter 'import *' only imports what it should (GH-14864)
Add __all__ to tkinter.__init__ and submodules.  Replace 'import *'
with explicit imports in some submodules.
2019-07-25 21:30:33 -04:00
Zackery Spytz 50866e9ed3 bpo-25451: Add transparency methods to tkinter.PhotoImage. (GH-10406) 2019-04-05 13:17:13 +03:00
Ned Deily aeca373b33
bpo-27313: Avoid test_ttk_guionly ComboboxTest fail with macOS Cocoa Tk (GH-12011) 2019-02-24 02:28:24 -05:00
Serhiy Storchaka 569d12f448
Fix yet one error in checking Tcl version. (GH-10189) 2018-10-28 20:58:04 +02:00
Serhiy Storchaka 18d57b4d62
Fix checking for bugfix Tcl version. (GH-10185) 2018-10-28 19:48:36 +02:00
Juliette Monsel 1deea5e539 bpo-34936: Fix TclError in tkinter.Spinbox.selection_element(). (GH-9760) 2018-10-18 22:28:31 +03:00
Juliette Monsel bf034715db bpo-23831: Add moveto method to the tkinter.Canvas widget. (GH-9768) 2018-10-12 19:44:10 +03:00
Serhiy Storchaka dc0d571b64
bpo-34964: Make Tkinter sources more readable by adding blank lines. (GH-9822) 2018-10-12 19:01:00 +03:00
Juliette Monsel af5658ae93 bpo-34829: Add missing selection_ methods to the Tkinter Spinbox. (GH-9617)
Implement the methods selection_from(), selection_range(), selection_present()
and selection_to() for Tkinter Spinbox.
2018-10-08 19:29:24 +03:00