Change to use keyword args instead of dicts

This commit is contained in:
Guido van Rossum 1996-07-30 18:35:38 +00:00
parent 8cf2db47ba
commit 053313a507
2 changed files with 16 additions and 20 deletions

View File

@ -14,22 +14,20 @@ from Tkinter import *
from Tkinter import _cnfmerge from Tkinter import _cnfmerge
class ScrolledText(Text): class ScrolledText(Text):
def __init__(self, master=None, cnf={}): def __init__(self, master=None, **cnf):
cnf = _cnfmerge(cnf)
fcnf = {} fcnf = {}
vcnf = {'name': 'vbar',
Pack: {'side': 'right', 'fill': 'y'},}
for k in cnf.keys(): for k in cnf.keys():
if type(k) == ClassType or k == 'name': if type(k) == ClassType or k == 'name':
fcnf[k] = cnf[k] fcnf[k] = cnf[k]
del cnf[k] del cnf[k]
self.frame = Frame(master, fcnf) self.frame = apply(Frame, (master,), fcnf)
self.vbar = Scrollbar(self.frame, vcnf) self.vbar = Scrollbar(self.frame, name='vbar')
cnf[Pack] = {'side': 'left', 'fill': 'both', 'expand': 'yes'} self.vbar.pack(side=RIGHT, fill=Y)
cnf['name'] = 'text' cnf['name'] = 'text'
Text.__init__(self, self.frame, cnf) apply(Text.__init__, (self, self.frame), cnf)
self['yscrollcommand'] = (self.vbar, 'set') self.pack(side=LEFT, fill=BOTH, expand=1)
self.vbar['command'] = (self, 'yview') self['yscrollcommand'] = self.vbar.set
self.vbar['command'] = self.yview
# Copy Pack methods of self.frame -- hack! # Copy Pack methods of self.frame -- hack!
for m in Pack.__dict__.keys(): for m in Pack.__dict__.keys():

View File

@ -14,22 +14,20 @@ from Tkinter import *
from Tkinter import _cnfmerge from Tkinter import _cnfmerge
class ScrolledText(Text): class ScrolledText(Text):
def __init__(self, master=None, cnf={}): def __init__(self, master=None, **cnf):
cnf = _cnfmerge(cnf)
fcnf = {} fcnf = {}
vcnf = {'name': 'vbar',
Pack: {'side': 'right', 'fill': 'y'},}
for k in cnf.keys(): for k in cnf.keys():
if type(k) == ClassType or k == 'name': if type(k) == ClassType or k == 'name':
fcnf[k] = cnf[k] fcnf[k] = cnf[k]
del cnf[k] del cnf[k]
self.frame = Frame(master, fcnf) self.frame = apply(Frame, (master,), fcnf)
self.vbar = Scrollbar(self.frame, vcnf) self.vbar = Scrollbar(self.frame, name='vbar')
cnf[Pack] = {'side': 'left', 'fill': 'both', 'expand': 'yes'} self.vbar.pack(side=RIGHT, fill=Y)
cnf['name'] = 'text' cnf['name'] = 'text'
Text.__init__(self, self.frame, cnf) apply(Text.__init__, (self, self.frame), cnf)
self['yscrollcommand'] = (self.vbar, 'set') self.pack(side=LEFT, fill=BOTH, expand=1)
self.vbar['command'] = (self, 'yview') self['yscrollcommand'] = self.vbar.set
self.vbar['command'] = self.yview
# Copy Pack methods of self.frame -- hack! # Copy Pack methods of self.frame -- hack!
for m in Pack.__dict__.keys(): for m in Pack.__dict__.keys():