summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilherme Polo <ggpolo@gmail.com>2009-02-09 16:09:17 (GMT)
committerGuilherme Polo <ggpolo@gmail.com>2009-02-09 16:09:17 (GMT)
commit190c35f928f22ac46dfc219467965b18ee8eabe7 (patch)
treebfc90e4d465f48d99e3211e862dbd1520d43439d
parentc97c9096ed05c89041b2aab9578489ca634c9375 (diff)
downloadcpython-190c35f928f22ac46dfc219467965b18ee8eabe7.zip
cpython-190c35f928f22ac46dfc219467965b18ee8eabe7.tar.gz
cpython-190c35f928f22ac46dfc219467965b18ee8eabe7.tar.bz2
Turned setup_master public
-rw-r--r--Lib/lib-tk/ttk.py41
1 files changed, 19 insertions, 22 deletions
diff --git a/Lib/lib-tk/ttk.py b/Lib/lib-tk/ttk.py
index c2907c9..f112f0e 100644
--- a/Lib/lib-tk/ttk.py
+++ b/Lib/lib-tk/ttk.py
@@ -23,7 +23,7 @@ __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label",
# Extensions
"LabeledScale", "OptionMenu",
# functions
- "tclobjs_to_py"]
+ "tclobjs_to_py", "setup_master"]
import Tkinter
@@ -47,25 +47,6 @@ def _load_tile(master):
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 @@ def tclobjs_to_py(adict):
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 @@ class Style(object):
_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 @@ class Widget(Tkinter.Widget):
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)