Skip to content
Prev Previous commit
Next Next commit
Changes per review.
  • Loading branch information
csabella committed Mar 4, 2018
commit 51bfe2bfa150a4b9346306518d27cbb19b0e805d
22 changes: 10 additions & 12 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,19 +780,17 @@ def after_cancel(self, id):
def after_info(self, id=None):
"""Return information about existing event handlers.

With no argument, return a list of the identifiers for all existing
event handlers created by the after command for this interpreter.
If id is supplied, it specifies an existing handler; id must have been
the return value from some previous call to after or after_idle and it
must not have triggered yet or been canceled. If the id doesn't exist,
a TclError is raised. Othewise, the return value is a tuple
containing (script, type) where type is either 'idle' or 'timer' to
indicate what kind of event handler it is.
With no argument, return a tuple of the identifiers for all existing
event handlers created by the after and after_idle commands for this
interpreter. If id is supplied, it specifies an existing handler; id
must have been the return value from some previous call to after or
after_idle and it must not have triggered yet or been canceled. If the
id doesn't exist, a TclError is raised. Othewise, the return value is
Comment thread
terryjreedy marked this conversation as resolved.
Outdated
a tuple containing (script, type) where script is a reference to the
function to be called by the event handler and type is either 'idle'
or 'timer' to indicate what kind of event handler it is.
"""
if id is None:
return self.tk.call('after', 'info')
else:
return self.tk.call('after', 'info', id)
return self.tk.splitlist(self.tk.call('after', 'info', id))
Comment thread
terryjreedy marked this conversation as resolved.
Outdated
Comment thread
serhiy-storchaka marked this conversation as resolved.

def bell(self, displayof=0):
"""Ring a display's bell."""
Expand Down
13 changes: 10 additions & 3 deletions Lib/tkinter/test/test_tkinter/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ def callback():

def test_after_info(self):
root = self.root

# No events.
self.assertEqual(root.after_info(), ())

# Add timer.
timer = root.after(1, lambda: 'break')

Expand All @@ -172,12 +176,12 @@ def test_after_info(self):
# Only contains new events and not 'timer'.
self.assertEqual(root.after_info(), (idle1, timer2, timer1))
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated

# With a paramter returns a tuple of (script, type).
# With a parameter returns a tuple of (script, type).
timer1_info = root.after_info(timer1)
Comment thread
csabella marked this conversation as resolved.
Outdated
self.assertIn('lambda', timer1_info[0])
self.assertEqual(len(timer1_info), 2)
self.assertEqual(timer1_info[1], 'timer')
idle1_info = root.after_info(idle1)
self.assertIn('lambda', idle1_info[0])
self.assertEqual(len(idle1_info), 2)
self.assertEqual(idle1_info[1], 'idle')

root.after_cancel(timer1)
Expand All @@ -190,6 +194,9 @@ def test_after_info(self):
with self.assertRaises(tkinter.TclError):
root.after_info(idle1)

# No events.
self.assertEqual(root.after_info(), ())


tests_gui = (MiscTest, )

Expand Down