[Python-checkins] r63938 - in sandbox/trunk/ttk-gsoc/src: 2.x/ttk.py 3.x/ttk.py idlelib_ttk.diff
guilherme.polo
python-checkins at python.org
Wed Jun 4 16:08:46 CEST 2008
Author: guilherme.polo
Date: Wed Jun 4 16:08:45 2008
New Revision: 63938
Log:
_dict_from_tcltuple converts 'integers' to integers now, when possible;
Correction of paramaters' passage done at Lib/idlelib/dynOptionMenuWidget.py
Modified:
sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
sandbox/trunk/ttk-gsoc/src/idlelib_ttk.diff
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 Wed Jun 4 16:08:45 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.1"
+__version__ = "0.1.1"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -249,16 +249,19 @@
opt_start = 1 if cut_minus else 0
for opt, val in zip(iter(ttuple[::2]), iter(ttuple[1::2])):
-
- try:
- if ' ' in val: # val could be the padding option
- val = map(int, val.split())
- except (AttributeError, TypeError, ValueError):
- # it is not a bool, neither a string and not even a tuple or list
- pass
- else: # but could be a statespec val
- if val and hasattr(val, "__len__") and hasattr(val[0], "typename"):
- val = _list_from_statespec(val)
+ if isinstance(val, basestring):
+ try:
+ if ' ' in val: # could be the padding option
+ val = map(int, val.split())
+ elif val.isdigit():
+ val = int(val)
+ except (AttributeError, TypeError, ValueError):
+ # leave val untouched for now
+ pass
+
+ elif val and hasattr(val, '__len__') and hasattr(val[0], 'typename'):
+ # could be a statespec
+ val = _list_from_statespec(val)
opts.append((str(opt)[opt_start:], val))
@@ -1357,11 +1360,11 @@
def set_menu(self, default=None, *values):
"""Build a new menu of radiobuttons with *values and optionally
a default value."""
- menu = self._menu
+ menu = self['menu']
menu.delete(0, 'end')
- for v in values:
- menu.add_radiobutton(label=v,
- command=Tkinter._setit(self._variable, v, self._callback))
+ for val in values:
+ menu.add_radiobutton(label=val,
+ command=Tkinter._setit(self._variable, val, self._callback))
if default:
self._variable.set(default)
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 Wed Jun 4 16:08:45 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.1"
+__version__ = "0.1.1"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -249,16 +249,19 @@
opt_start = 1 if cut_minus else 0
for opt, val in zip(iter(ttuple[::2]), iter(ttuple[1::2])):
-
- try:
- if ' ' in val: # val could be the padding option
- val = list(map(int, val.split()))
- except (AttributeError, TypeError, ValueError):
- # it is not a bool, neither a string and not even a tuple or list
- pass
- else: # but could be a statespec val
- if val and hasattr(val, "__len__") and hasattr(val[0], "typename"):
- val = _list_from_statespec(val)
+ if isinstance(val, str):
+ try:
+ if ' ' in val: # could be the padding option
+ val = list(map(int, val.split()))
+ elif val.isdigit():
+ val = int(val)
+ except (AttributeError, TypeError, ValueError):
+ # leave val untouched for now
+ pass
+
+ elif val and hasattr(val, '__len__') and hasattr(val[0], 'typename'):
+ # could be a statespec
+ val = _list_from_statespec(val)
opts.append((str(opt)[opt_start:], val))
@@ -1359,9 +1362,9 @@
a default value."""
menu = self['menu']
menu.delete(0, 'end')
- for v in values:
- menu.add_radiobutton(label=v,
- command=tkinter._setit(self._variable, v, self._callback))
+ for val in values:
+ menu.add_radiobutton(label=val,
+ command=tkinter._setit(self._variable, val, self._callback))
if default:
self._variable.set(default)
Modified: sandbox/trunk/ttk-gsoc/src/idlelib_ttk.diff
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib_ttk.diff (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib_ttk.diff Wed Jun 4 16:08:45 2008
@@ -145,7 +145,7 @@
import macosxSupport
+if idleConf.GetOption('main', 'General', 'use-ttk', type='int'):
-+ from ttk import Scrollbar
++ from ttk import Scrollbar, Button, Radiobutton
class Idb(bdb.Bdb):
@@ -1662,7 +1662,7 @@
- for item in valueList:
- self['menu'].add_command(label=item,
+ if TTK:
-+ self.set_menu(valueList[0], *valueList[1:])
++ self.set_menu(value, *valueList)
+ else:
+ menu = self['menu']
+ menu.delete(0,'end')
More information about the Python-checkins
mailing list