PyXR

c:\python24\lib\lib-tk \ ScrolledText.py



0001 # A ScrolledText widget feels like a text widget but also has a
0002 # vertical scroll bar on its right.  (Later, options may be added to
0003 # add a horizontal bar as well, to make the bars disappear
0004 # automatically when not needed, to move them to the other side of the
0005 # window, etc.)
0006 #
0007 # Configuration options are passed to the Text widget.
0008 # A Frame widget is inserted between the master and the text, to hold
0009 # the Scrollbar widget.
0010 # Most methods calls are inherited from the Text widget; Pack methods
0011 # are redirected to the Frame widget however.
0012 
0013 from Tkinter import *
0014 from Tkinter import _cnfmerge
0015 
0016 class ScrolledText(Text):
0017     def __init__(self, master=None, cnf=None, **kw):
0018         if cnf is None:
0019             cnf = {}
0020         if kw:
0021             cnf = _cnfmerge((cnf, kw))
0022         fcnf = {}
0023         for k in cnf.keys():
0024             if type(k) == ClassType or k == 'name':
0025                 fcnf[k] = cnf[k]
0026                 del cnf[k]
0027         self.frame = Frame(master, **fcnf)
0028         self.vbar = Scrollbar(self.frame, name='vbar')
0029         self.vbar.pack(side=RIGHT, fill=Y)
0030         cnf['name'] = 'text'
0031         Text.__init__(self, self.frame, **cnf)
0032         self.pack(side=LEFT, fill=BOTH, expand=1)
0033         self['yscrollcommand'] = self.vbar.set
0034         self.vbar['command'] = self.yview
0035 
0036         # Copy geometry methods of self.frame -- hack!
0037         methods = Pack.__dict__.keys()
0038         methods = methods + Grid.__dict__.keys()
0039         methods = methods + Place.__dict__.keys()
0040 
0041         for m in methods:
0042             if m[0] != '_' and m != 'config' and m != 'configure':
0043                 setattr(self, m, getattr(self.frame, m))
0044 

Generated by PyXR 0.9.4
SourceForge.net Logo