diff -r 204a43c452cc Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py Sat Oct 22 23:18:31 2016 +0300 +++ b/Lib/tkinter/__init__.py Wed Oct 26 20:34:07 2016 +0200 @@ -771,6 +771,87 @@ def bell(self, displayof=0): """Ring a display's bell.""" self.tk.call(('bell',) + self._displayof(displayof)) + def tk_busy_cget(self, option): + '''Queries the tk_busy() configuration options. + + The widget must have been previously made busy by + the busy_hold() command. Returns the present value + of the specified option. Option may have + any of the values accepted by busy_hold(). + ''' + return self.tk.call('tk', 'busy', 'cget', self._w, '-'+option) + busy_cget = tk_busy_cget + def tk_busy_configure(self, cnf=None, **kw): + '''Queries or modifies the tk_busy() configuration options. + + The widget must have been previously made busy by + busy_hold(). Options may have any of the values accepted by + busy_hold(). + Please note that the option database is referenced by the + widget. For example, if a Frame widget is to be made busy, + the busy cursor can be specified for it by: + + w.option_add("*Frame.BusyCursor", "gumby") + ''' + if kw: + cnf = _cnfmerge((cnf, kw)) + elif cnf: + cnf = _cnfmerge(cnf) + if cnf is None: + return self._getconfigure( + 'tk', 'busy', 'configure', self._w) + if isinstance(cnf, str): + return self._getconfigure1( + 'tk', 'busy', 'configure', self._w, '-'+cnf) + self.tk.call(( + 'tk', 'busy', 'configure', self._w) + self._options(cnf)) + tk_busy_config = busy_configure = busy_config = tk_busy_configure + def tk_busy_current(self, pattern=None): + '''Returns all widgets that are currently busy. + + If a pattern is given, only busy widgets whose path names + match PATTERN are returned. + ''' + return [self._nametowidget(x) for x in + self.tk.splitlist(self.tk.call( + 'tk', 'busy', 'current', pattern))] + busy_current = tk_busy_current + def tk_busy_forget(self): + '''Releases tk_busy() resources for this widget. + + Releases resources allocated by the busy() command for + this widget, including the transparent window. + User events will again be received by the widget. Resources + are also released when the widget is destroyed. The widget + must have been specified in the busy_hold() operation, + otherwise an exception is raised. + ''' + self.tk.call('tk', 'busy', 'forget', self._w) + busy_forget = tk_busy_forget + def tk_busy_hold(self, **kw): + '''Makes this widget (and its child widgets) appear busy. + + A transparent window is put in front of the specified widget. + This transparent window is mapped the next time + idle tasks are processed, and the specified + widget and its descendants will be blocked from user + interactions. Normally update() should be called immediately + afterward to insure that the hold operation is in effect before + the application starts its processing. The following + configuration options are valid: cursor + ''' + self.tk.call(( + 'tk', 'busy', 'hold', self._w) + self._options(kw)) + tk_busy = busy_hold = busy = tk_busy_hold + def tk_busy_status(self): + '''Returns the busy status of this widget. + + If the widget presently can not receive user interactions, + True is returned, otherwise False. + ''' + return self.tk.getboolean(self.tk.call( + 'tk', 'busy', 'status', self._w)) + busy_status = tk_busy_status # Clipboard handling: def clipboard_get(self, **kw): diff -r 204a43c452cc Lib/tkinter/test/test_tkinter/test_misc.py --- a/Lib/tkinter/test/test_tkinter/test_misc.py Sat Oct 22 23:18:31 2016 +0300 +++ b/Lib/tkinter/test/test_tkinter/test_misc.py Wed Oct 26 20:34:07 2016 +0200 @@ -20,6 +20,31 @@ for name in str(b).split('.'): self.assertFalse(name.isidentifier(), msg=repr(name)) + def test_tk_busy(self): + root = self.root + root.tk_busy_hold(cursor='gumby') + self.assertEqual(root.tk_busy_cget('cursor'), 'gumby') + root.tk_busy_configure(cursor='heart') + self.assertIn('heart', root.tk_busy_configure()['cursor']) + self.assertRaisesRegex(tkinter.TclError, + 'unknown option "-spam"', + root.tk_busy_configure, spam='eggs') + self.assertTrue(root.tk_busy_status()) + self.assertIn(root, root.tk_busy_current()) + self.assertNotIn(root, root.tk_busy_current('spam')) + root.tk_busy_forget() + self.assertRaisesRegex(tkinter.TclError, + 'can\'t find busy window "."', + root.busy_configure) + self.assertRaisesRegex(tkinter.TclError, + 'can\'t find busy window "."', + root.busy_cget, 'cursor') + self.assertRaisesRegex(tkinter.TclError, + 'can\'t find busy window "."', + root.busy_forget) + self.assertFalse(root.busy_status()) + self.assertFalse(root.busy_current()) + def test_tk_setPalette(self): root = self.root root.tk_setPalette('black')