Index: Tkinter.py =================================================================== --- Tkinter.py (revision 67239) +++ Tkinter.py (revision 67259) @@ -132,12 +132,25 @@ Call this function to inhibit that the first instance of Tk is used for windows without an explicit parent window. """ - global _support_default_root + global _support_default_root, _default_root _support_default_root = 0 - global _default_root _default_root = None del _default_root +def setup_master(master=None): + """If master is not None, itself is returned. Otherwise attempt + getting a new master or the default one and return it. + + If it is not allowed to use the default root and master is None, + RuntimeError is raised.""" + if master is None: + if _support_default_root: + master = _default_root or Tk() + else: + raise RuntimeError("No master specified and Tkinter is " + "configured to not support default root") + return master + def _tkerror(err): """Internal function.""" pass