#2906: accept lists for options, and some cosmetic fixes in Tkinter.

This commit is contained in:
Georg Brandl 2008-05-29 07:19:00 +00:00
parent bb87e2b686
commit bf1eb637bd

View file

@ -1051,6 +1051,12 @@ class Misc:
if k[-1] == '_': k = k[:-1] if k[-1] == '_': k = k[:-1]
if hasattr(v, '__call__'): if hasattr(v, '__call__'):
v = self._register(v) v = self._register(v)
elif isinstance(v, (tuple, list)):
for item in v:
if not isinstance(item, (basestring, int)):
break
else:
v = ' '.join(map(str, v))
res = res + ('-'+k, v) res = res + ('-'+k, v)
return res return res
def nametowidget(self, name): def nametowidget(self, name):
@ -1090,7 +1096,6 @@ class Misc:
if self._tclCommands is None: if self._tclCommands is None:
self._tclCommands = [] self._tclCommands = []
self._tclCommands.append(name) self._tclCommands.append(name)
#print '+ Tkinter created command', name
return name return name
register = _register register = _register
def _root(self): def _root(self):
@ -1744,6 +1749,7 @@ class Pack:
expand=bool - expand widget if parent size grows expand=bool - expand widget if parent size grows
fill=NONE or X or Y or BOTH - fill widget if widget grows fill=NONE or X or Y or BOTH - fill widget if widget grows
in=master - use master to contain this widget in=master - use master to contain this widget
in_=master - see 'in' option description
ipadx=amount - add internal padding in x direction ipadx=amount - add internal padding in x direction
ipady=amount - add internal padding in y direction ipady=amount - add internal padding in y direction
padx=amount - add padding in x direction padx=amount - add padding in x direction
@ -1781,7 +1787,8 @@ class Place:
Base class to use the methods place_* in every widget.""" Base class to use the methods place_* in every widget."""
def place_configure(self, cnf={}, **kw): def place_configure(self, cnf={}, **kw):
"""Place a widget in the parent widget. Use as options: """Place a widget in the parent widget. Use as options:
in=master - master relative to which the widget is placed. in=master - master relative to which the widget is placed
in_=master - see 'in' option description
x=amount - locate anchor of this widget at position x of master x=amount - locate anchor of this widget at position x of master
y=amount - locate anchor of this widget at position y of master y=amount - locate anchor of this widget at position y of master
relx=amount - locate anchor of this widget between 0.0 and 1.0 relx=amount - locate anchor of this widget between 0.0 and 1.0
@ -1797,13 +1804,9 @@ class Place:
relheight=amount - height of this widget between 0.0 and 1.0 relheight=amount - height of this widget between 0.0 and 1.0
relative to height of master (1.0 is the same relative to height of master (1.0 is the same
height as the master) height as the master)
bordermode="inside" or "outside" - whether to take border width of master widget bordermode="inside" or "outside" - whether to take border width of
into account master widget into account
""" """
for k in ['in_']:
if k in kw:
kw[k[:-1]] = kw[k]
del kw[k]
self.tk.call( self.tk.call(
('place', 'configure', self._w) ('place', 'configure', self._w)
+ self._options(cnf, kw)) + self._options(cnf, kw))
@ -1838,6 +1841,7 @@ class Grid:
column=number - use cell identified with given column (starting with 0) column=number - use cell identified with given column (starting with 0)
columnspan=number - this widget will span several columns columnspan=number - this widget will span several columns
in=master - use master to contain this widget in=master - use master to contain this widget
in_=master - see 'in' option description
ipadx=amount - add internal padding in x direction ipadx=amount - add internal padding in x direction
ipady=amount - add internal padding in y direction ipady=amount - add internal padding in y direction
padx=amount - add padding in x direction padx=amount - add padding in x direction