Kaydet (Commit) ad8b3baa authored tarafından Guido van Rossum's avatar Guido van Rossum

Restore the capability to pass a class (usually Pack) as an option to widget

creation; no longer support this for the config method.
üst 81652ab6
...@@ -827,8 +827,15 @@ class Widget(Misc, Pack, Place, Grid): ...@@ -827,8 +827,15 @@ class Widget(Misc, Pack, Place, Grid):
cnf = _cnfmerge((cnf, kw)) cnf = _cnfmerge((cnf, kw))
self.widgetName = widgetName self.widgetName = widgetName
Widget._setup(self, master, cnf) Widget._setup(self, master, cnf)
classes = []
for k in cnf.keys():
if type(k) is ClassType:
classes.append((k, cnf[k]))
del cnf[k]
apply(self.tk.call, apply(self.tk.call,
(widgetName, self._w) + extra + self._options(cnf)) (widgetName, self._w) + extra + self._options(cnf))
for k, v in classes:
k.config(self, v)
def config(self, cnf=None, **kw): def config(self, cnf=None, **kw):
# XXX ought to generalize this so tag_config etc. can use it # XXX ought to generalize this so tag_config etc. can use it
if kw: if kw:
...@@ -845,10 +852,6 @@ class Widget(Misc, Pack, Place, Grid): ...@@ -845,10 +852,6 @@ class Widget(Misc, Pack, Place, Grid):
x = self.tk.split(self.tk.call( x = self.tk.split(self.tk.call(
self._w, 'configure', '-'+cnf)) self._w, 'configure', '-'+cnf))
return (x[0][1:],) + x[1:] return (x[0][1:],) + x[1:]
for k in cnf.keys():
if type(k) is ClassType:
k.config(self, cnf[k])
del cnf[k]
apply(self.tk.call, (self._w, 'configure') apply(self.tk.call, (self._w, 'configure')
+ self._options(cnf)) + self._options(cnf))
configure = config configure = config
......
...@@ -827,8 +827,15 @@ class Widget(Misc, Pack, Place, Grid): ...@@ -827,8 +827,15 @@ class Widget(Misc, Pack, Place, Grid):
cnf = _cnfmerge((cnf, kw)) cnf = _cnfmerge((cnf, kw))
self.widgetName = widgetName self.widgetName = widgetName
Widget._setup(self, master, cnf) Widget._setup(self, master, cnf)
classes = []
for k in cnf.keys():
if type(k) is ClassType:
classes.append((k, cnf[k]))
del cnf[k]
apply(self.tk.call, apply(self.tk.call,
(widgetName, self._w) + extra + self._options(cnf)) (widgetName, self._w) + extra + self._options(cnf))
for k, v in classes:
k.config(self, v)
def config(self, cnf=None, **kw): def config(self, cnf=None, **kw):
# XXX ought to generalize this so tag_config etc. can use it # XXX ought to generalize this so tag_config etc. can use it
if kw: if kw:
...@@ -845,10 +852,6 @@ class Widget(Misc, Pack, Place, Grid): ...@@ -845,10 +852,6 @@ class Widget(Misc, Pack, Place, Grid):
x = self.tk.split(self.tk.call( x = self.tk.split(self.tk.call(
self._w, 'configure', '-'+cnf)) self._w, 'configure', '-'+cnf))
return (x[0][1:],) + x[1:] return (x[0][1:],) + x[1:]
for k in cnf.keys():
if type(k) is ClassType:
k.config(self, cnf[k])
del cnf[k]
apply(self.tk.call, (self._w, 'configure') apply(self.tk.call, (self._w, 'configure')
+ self._options(cnf)) + self._options(cnf))
configure = config configure = config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment