[Python-checkins] r69460 - python/trunk/Lib/lib-tk/ttk.py

guilherme.polo python-checkins at python.org
Mon Feb 9 17:09:17 CET 2009


Author: guilherme.polo
Date: Mon Feb 9 17:09:17 2009
New Revision: 69460
Log:
Turned setup_master public
Modified:
 python/trunk/Lib/lib-tk/ttk.py
Modified: python/trunk/Lib/lib-tk/ttk.py
==============================================================================
--- python/trunk/Lib/lib-tk/ttk.py	(original)
+++ python/trunk/Lib/lib-tk/ttk.py	Mon Feb 9 17:09:17 2009
@@ -23,7 +23,7 @@
 # Extensions
 "LabeledScale", "OptionMenu",
 # functions
- "tclobjs_to_py"]
+ "tclobjs_to_py", "setup_master"]
 
 import Tkinter
 
@@ -47,25 +47,6 @@
 master.tk.eval('package require tile') # TclError may be raised here
 master._tile_loaded = True
 
-
-def _setup_master(master=None):
- """If master is not None, itself is returned. If master is None,
- the default master is returned if there is one, otherwise a new
- master is created and returned.
-
- If it is not allowed to use the default root and master is None,
- RuntimeError is raised."""
- if master is None:
- if Tkinter._support_default_root:
- master = Tkinter._default_root or Tkinter.Tk()
- else:
- raise RuntimeError(
- "No master specified and Tkinter is "
- "configured to not support default root")
- return master
-
-
-
 def _format_optdict(optdict, script=False, ignore=None):
 """Formats optdict to a tuple to pass it to tk.call.
 
@@ -368,6 +349,22 @@
 
 return adict
 
+def setup_master(master=None):
+ """If master is not None, itself is returned. If master is None,
+ the default master is returned if there is one, otherwise a new
+ master is created and returned.
+
+ If it is not allowed to use the default root and master is None,
+ RuntimeError is raised."""
+ if master is None:
+ if Tkinter._support_default_root:
+ master = Tkinter._default_root or Tkinter.Tk()
+ else:
+ raise RuntimeError(
+ "No master specified and Tkinter is "
+ "configured to not support default root")
+ return master
+
 
 class Style(object):
 """Manipulate style database."""
@@ -375,7 +372,7 @@
 _name = "ttk::style"
 
 def __init__(self, master=None):
- master = _setup_master(master)
+ master = setup_master(master)
 
 if not getattr(master, '_tile_loaded', False):
 # Load tile now, if needed
@@ -556,7 +553,7 @@
 active, disabled, focus, pressed, selected, background,
 readonly, alternate, invalid
 """
- master = _setup_master(master)
+ master = setup_master(master)
 if not getattr(master, '_tile_loaded', False):
 # Load tile now, if needed
 _load_tile(master)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /