python-2.5.2/win32/Lib/lib-tk/ScrolledText.py
changeset 0 ae805ac0140d
equal deleted inserted replaced
-1:000000000000 0:ae805ac0140d
       
     1 # A ScrolledText widget feels like a text widget but also has a
       
     2 # vertical scroll bar on its right.  (Later, options may be added to
       
     3 # add a horizontal bar as well, to make the bars disappear
       
     4 # automatically when not needed, to move them to the other side of the
       
     5 # window, etc.)
       
     6 #
       
     7 # Configuration options are passed to the Text widget.
       
     8 # A Frame widget is inserted between the master and the text, to hold
       
     9 # the Scrollbar widget.
       
    10 # Most methods calls are inherited from the Text widget; Pack methods
       
    11 # are redirected to the Frame widget however.
       
    12 
       
    13 from Tkinter import *
       
    14 from Tkinter import _cnfmerge
       
    15 
       
    16 class ScrolledText(Text):
       
    17     def __init__(self, master=None, cnf=None, **kw):
       
    18         if cnf is None:
       
    19             cnf = {}
       
    20         if kw:
       
    21             cnf = _cnfmerge((cnf, kw))
       
    22         fcnf = {}
       
    23         for k in cnf.keys():
       
    24             if type(k) == ClassType or k == 'name':
       
    25                 fcnf[k] = cnf[k]
       
    26                 del cnf[k]
       
    27         self.frame = Frame(master, **fcnf)
       
    28         self.vbar = Scrollbar(self.frame, name='vbar')
       
    29         self.vbar.pack(side=RIGHT, fill=Y)
       
    30         cnf['name'] = 'text'
       
    31         Text.__init__(self, self.frame, **cnf)
       
    32         self.pack(side=LEFT, fill=BOTH, expand=1)
       
    33         self['yscrollcommand'] = self.vbar.set
       
    34         self.vbar['command'] = self.yview
       
    35 
       
    36         # Copy geometry methods of self.frame -- hack!
       
    37         methods = Pack.__dict__.keys()
       
    38         methods = methods + Grid.__dict__.keys()
       
    39         methods = methods + Place.__dict__.keys()
       
    40 
       
    41         for m in methods:
       
    42             if m[0] != '_' and m != 'config' and m != 'configure':
       
    43                 setattr(self, m, getattr(self.frame, m))