[Python-checkins] r67259 - sandbox/trunk/tkinter-polo/src/Tkinter.py
guilherme.polo
python-checkins at python.org
Tue Nov 18 13:20:46 CET 2008
Author: guilherme.polo
Date: Tue Nov 18 13:20:46 2008
New Revision: 67259
Log:
Added a function that returns a master to the caller, if possible.
Modified:
sandbox/trunk/tkinter-polo/src/Tkinter.py
Modified: sandbox/trunk/tkinter-polo/src/Tkinter.py
==============================================================================
--- sandbox/trunk/tkinter-polo/src/Tkinter.py (original)
+++ sandbox/trunk/tkinter-polo/src/Tkinter.py Tue Nov 18 13:20:46 2008
@@ -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 Tkinter.Tk()
+ else:
+ raise RuntimeError("No master specified and Tkinter is "
+ "configured to not support default root")
+ return master
+
def _tkerror(err):
"""Internal function."""
pass
More information about the Python-checkins
mailing list