[Python-checkins] r62581 - in sandbox/trunk/ttk-gsoc: Doc Doc/library Doc/library/tk.rst.diff Doc/library/ttk.rst Lib Lib/lib-tk Lib/lib-tk/Ttk.py lib-tk
guilherme.polo
python-checkins at python.org
Tue Apr 29 16:47:28 CEST 2008
Author: guilherme.polo
Date: Tue Apr 29 16:47:27 2008
New Revision: 62581
Log:
Moved lib-tk to Lib/lib-tk so it matches the correct python structure.
Added Doc/library. tk.rst.diff is a minor diff for adding ttk.rst to
its toctree. ttk.rst is empty for now.
Removed unused import at Lib/lib-tk/Ttk.py and now it overrides
Tkinter.Tk._loadtk to check for Ttk presence. Previously it was
overriding Tkinter.BaseWidget._setup (which would call
Tkinter.Tk._loadtk) but in some situations it would be bad to
depend on BaseWidget, for example:
import Tkinter, Ttk
tk = Tkinter.Tk() # Tile not checked yet, not a problem for Tk 8.5
style = Ttk.Style() # fails telling ttk::style is not available
The difference now is that it will raise a TclError when creating
Tk instance if you are trying to use Ttk without it being available.
Added:
sandbox/trunk/ttk-gsoc/Doc/
sandbox/trunk/ttk-gsoc/Doc/library/
sandbox/trunk/ttk-gsoc/Doc/library/tk.rst.diff
sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
sandbox/trunk/ttk-gsoc/Lib/
sandbox/trunk/ttk-gsoc/Lib/lib-tk/
- copied from r62515, /sandbox/trunk/ttk-gsoc/lib-tk/
sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py
- copied, changed from r62580, /sandbox/trunk/ttk-gsoc/lib-tk/Ttk.py
Removed:
sandbox/trunk/ttk-gsoc/lib-tk/
Added: sandbox/trunk/ttk-gsoc/Doc/library/tk.rst.diff
==============================================================================
--- (empty file)
+++ sandbox/trunk/ttk-gsoc/Doc/library/tk.rst.diff Tue Apr 29 16:47:27 2008
@@ -0,0 +1,12 @@
+Index: Doc/library/tk.rst
+===================================================================
+--- Doc/library/tk.rst (revision 62383)
++++ Doc/library/tk.rst (working copy)
+@@ -30,6 +30,7 @@
+ .. toctree::
+
+ tkinter.rst
++ ttk.rst
+ tix.rst
+ scrolledtext.rst
+ turtle.rst
Added: sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
==============================================================================
--- (empty file)
+++ sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst Tue Apr 29 16:47:27 2008
@@ -0,0 +1,11 @@
+:mod:`Ttk` --- Empty
+====================
+
+.. module:: Ttk
+ :synposis: Empty
+.. sectionauthor:: Guilherme Polo <ggpolo at gmail.com>
+
+
+.. index:: single: Ttk
+
+Booh!
Copied: sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py (from r62580, /sandbox/trunk/ttk-gsoc/lib-tk/Ttk.py)
==============================================================================
--- /sandbox/trunk/ttk-gsoc/lib-tk/Ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py Tue Apr 29 16:47:27 2008
@@ -20,25 +20,23 @@
"Style", "Widget"]
import Tkinter
-import _tkinter
# Verify if Tk is new enough to not need Tile checking
REQUIRE_TILE = True if Tkinter.TkVersion < 8.5 else False
# XXX Looking at FixTk.py it seems something like TILE_LIBRARY env check
# should be added there and possibly here before tile package check.
-def _setup(tksetup):
- # Extend default Tkinter.BaseWidget._setup staticmethod so we can be
- # sure that Ttk is available for use, or not.
- def f(self, master, cnf):
- tksetup(self, master, cnf)
+def _loadttk(loadtk):
+ # Extend default Tkinter.Tk._loadtk method so we can be sure that
+ # Ttk is available for use, or not.
+ def f(self):
+ loadtk(self)
if REQUIRE_TILE:
self.tk.eval('package require tile')
-
+
return f
-Tkinter.BaseWidget._setup = _setup(Tkinter.BaseWidget._setup)
-
+Tkinter.Tk._loadtk = _loadttk(Tkinter.Tk._loadtk)
class Style(object):
"""Manipulate style database."""
@@ -47,9 +45,9 @@
def __init__(self, master=None):
if not master:
- master = Tkinter._default_root
- if not master:
- raise RuntimeError("Too early to manipulate styles")
+ if not Tkinter._default_root:
+ Tkinter._default_root = Tkinter.Tk()
+ master = Tkinter._default_root
self.tk = master.tk
@@ -106,8 +104,8 @@
return self.tk.call(self._name, "layout", style, layoutspec)
- def element_create(self, elementname, type, **kw):
- """Create a new element in the current theme of given type."""
+ def element_create(self, elementName, etype, **kw):
+ """Create a new element in the current theme of given etype."""
raise NotImplementedError
More information about the Python-checkins
mailing list