[Python-checkins] r63535 - in sandbox/trunk/ttk-gsoc: README src/2.x/ttk.py src/3.x/ttk.py
guilherme.polo
python-checkins at python.org
Thu May 22 14:35:26 CEST 2008
Author: guilherme.polo
Date: Thu May 22 14:35:25 2008
New Revision: 63535
Log:
Version is now 0.1;
No more XXX comments;
Added instructions on README on how to check if you can use the ttk
module or not;
Some other minor changes.
Modified:
sandbox/trunk/ttk-gsoc/README
sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
Modified: sandbox/trunk/ttk-gsoc/README
==============================================================================
--- sandbox/trunk/ttk-gsoc/README (original)
+++ sandbox/trunk/ttk-gsoc/README Thu May 22 14:35:25 2008
@@ -13,6 +13,10 @@
samples passing the appropriate PYTHONPATH (ttk-gsoc/src/2.x or
ttk-gsoc/src/3.x depending on your python version) or placing the ttk
module somewhere in sys.path.
+If you are not sure if you have Tile installed correctly or if your
+tkinter is compiled against Tk 8.5, you could try creating an instance of
+of any class present in the ttk or Tkinter module, like Tkinter.Tk(),
+and if no TclError exception is raised then you meet the requirements.
[1] I've tested it with Tile 0.8.2 and it works, but I would recommend
upgrading to Tcl/Tk 8.5 so you get antialiased fonts and other
Modified: sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/2.x/ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/src/2.x/ttk.py Thu May 22 14:35:25 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.0.9"
+__version__ = "0.1"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -24,14 +24,15 @@
import Tkinter
# Verify if Tk is new enough to not need Tile checking
-REQUIRE_TILE = True if Tkinter.TkVersion < 8.5 else False
+_REQUIRE_TILE = True if Tkinter.TkVersion < 8.5 else False
def _loadttk(loadtk):
# This extends the default Tkinter.Tk._loadtk method so we can be
# sure that ttk is available for use, or not.
- def f(self):
+ def _wrapper(self):
loadtk(self)
- if REQUIRE_TILE:
+
+ if _REQUIRE_TILE:
import os
tilelib = os.environ.get('TILE_LIBRARY')
if tilelib:
@@ -40,12 +41,9 @@
# command
self.tk.eval('global auto_path; '
'lappend auto_path {%s}' % tilelib)
- # XXX Maybe I should catch a possible TclError and display
- # a Warning telling Ttk won't be available ? Or maybe I
- # shouldn't even be doing all this.
- self.tk.eval('package require tile')
+ self.tk.eval('package require tile') # TclError may be raised here
- return f
+ return _wrapper
Tkinter.Tk._loadtk = _loadttk(Tkinter.Tk._loadtk)
@@ -273,8 +271,7 @@
res.append((name, opts))
indx += 1
- # grab name's options
- while indx < len(ltuple):
+ while indx < len(ltuple): # grab name's options
opt, val = ltuple[indx:indx + 2]
if not opt.startswith('-'): # found next name
break
@@ -488,16 +485,16 @@
return self.tk.call(self._w, "identify", x, y)
- def instate(self, statespec, callback=None, *args):
+ def instate(self, statespec, callback=None, *args, **kw):
"""Test the widget's state.
If callback is not specified, returns 1 if the widget state
matches statespec and 0 otherwise. If callback is specified,
- then it will be invoked with *args if the widget state matches
- statespec. statespec is expected to be a sequence."""
+ then it will be invoked with *args, **kw if the widget state
+ matches statespec. statespec is expected to be a sequence."""
ret = self.tk.call(self._w, "instate", ' '.join(statespec))
if ret and callback:
- return callback(*args)
+ return callback(*args, **kw)
return ret
@@ -605,7 +602,7 @@
return self.tk.call(self._w, "validate")
-class Combobox(Entry):
+class Combobox(Widget, Entry):
"""Ttk Combobox widget combines a text field with a pop-down list of
values."""
@@ -842,7 +839,7 @@
# The only, and good, difference I see is about mnemonics, which works
# after calling this method. Control-Tab and Shift-Control-Tab always
# works (here at least).
- self.tk.call("ttk::notebook::enableTraversal", self)
+ self.tk.call("ttk::notebook::enableTraversal", self._w)
class Panedwindow(Widget, Tkinter.PanedWindow):
Modified: sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/3.x/ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/src/3.x/ttk.py Thu May 22 14:35:25 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.0.9"
+__version__ = "0.1"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -24,14 +24,15 @@
import tkinter
# Verify if Tk is new enough to not need Tile checking
-REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False
+_REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False
def _loadttk(loadtk):
# This extends the default tkinter.Tk._loadtk method so we can be
# sure that ttk is available for use, or not.
- def f(self):
+ def _wrapper(self):
loadtk(self)
- if REQUIRE_TILE:
+
+ if _REQUIRE_TILE:
import os
tilelib = os.environ.get('TILE_LIBRARY')
if tilelib:
@@ -40,12 +41,9 @@
# command
self.tk.eval('global auto_path; '
'lappend auto_path {%s}' % tilelib)
- # XXX Maybe I should catch a possible TclError and display
- # a Warning telling Ttk won't be available ? Or maybe I
- # shouldn't even be doing all this.
- self.tk.eval('package require tile')
+ self.tk.eval('package require tile') # TclError may be raised here
- return f
+ return _wrapper
tkinter.Tk._loadtk = _loadttk(tkinter.Tk._loadtk)
@@ -273,8 +271,7 @@
res.append((name, opts))
indx += 1
- # grab name's options
- while indx < len(ltuple):
+ while indx < len(ltuple): # grab name's options
opt, val = ltuple[indx:indx + 2]
if not opt.startswith('-'): # found next name
break
@@ -488,16 +485,16 @@
return self.tk.call(self._w, "identify", x, y)
- def instate(self, statespec, callback=None, *args):
+ def instate(self, statespec, callback=None, *args, **kw):
"""Test the widget's state.
If callback is not specified, returns 1 if the widget state
matches statespec and 0 otherwise. If callback is specified,
- then it will be invoked with *args if the widget state matches
- statespec. statespec is expected to be a sequence."""
+ then it will be invoked with *args, **kw if the widget state
+ matches statespec. statespec is expected to be a sequence."""
ret = self.tk.call(self._w, "instate", ' '.join(statespec))
if ret and callback:
- return callback(*args)
+ return callback(*args, **kw)
return ret
@@ -605,7 +602,7 @@
return self.tk.call(self._w, "validate")
-class Combobox(Entry):
+class Combobox(Widget, Entry):
"""Ttk Combobox widget combines a text field with a pop-down list of
values."""
@@ -842,7 +839,7 @@
# The only, and good, difference I see is about mnemonics, which works
# after calling this method. Control-Tab and Shift-Control-Tab always
# works (here at least).
- self.tk.call("ttk::notebook::enableTraversal", self)
+ self.tk.call("ttk::notebook::enableTraversal", self._w)
class Panedwindow(Widget, tkinter.PanedWindow):
More information about the Python-checkins
mailing list