mirror of
https://github.com/python/cpython.git
synced 2025-11-03 15:11:34 +00:00
gh-126899: Add **kw to tkinter.Misc.after and tkinter.Misc.after_idle (#126900)
--------- Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
04673d2f14
commit
7ea523f47c
5 changed files with 31 additions and 8 deletions
|
|
@ -123,9 +123,9 @@ def test_tk_setPalette(self):
|
|||
def test_after(self):
|
||||
root = self.root
|
||||
|
||||
def callback(start=0, step=1):
|
||||
def callback(start=0, step=1, *, end=0):
|
||||
nonlocal count
|
||||
count = start + step
|
||||
count = start + step + end
|
||||
|
||||
# Without function, sleeps for ms.
|
||||
self.assertIsNone(root.after(1))
|
||||
|
|
@ -161,12 +161,18 @@ def callback(start=0, step=1):
|
|||
root.update() # Process all pending events.
|
||||
self.assertEqual(count, 53)
|
||||
|
||||
# Set up with callback with keyword args.
|
||||
count = 0
|
||||
timer1 = root.after(0, callback, 42, step=11, end=1)
|
||||
root.update() # Process all pending events.
|
||||
self.assertEqual(count, 54)
|
||||
|
||||
def test_after_idle(self):
|
||||
root = self.root
|
||||
|
||||
def callback(start=0, step=1):
|
||||
def callback(start=0, step=1, *, end=0):
|
||||
nonlocal count
|
||||
count = start + step
|
||||
count = start + step + end
|
||||
|
||||
# Set up with callback with no args.
|
||||
count = 0
|
||||
|
|
@ -193,6 +199,12 @@ def callback(start=0, step=1):
|
|||
with self.assertRaises(tkinter.TclError):
|
||||
root.tk.call(script)
|
||||
|
||||
# Set up with callback with keyword args.
|
||||
count = 0
|
||||
idle1 = root.after_idle(callback, 42, step=11, end=1)
|
||||
root.update() # Process all pending events.
|
||||
self.assertEqual(count, 54)
|
||||
|
||||
def test_after_cancel(self):
|
||||
root = self.root
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue