annotate Lib/tkinter/ScrolledText.py @ 3720:b341def4eef8 legacy-trunk

Ignore latex intermediate products.
author Guido van Rossum <guido@python.org>
date Wed, 26 Jun 1996 19:30:01 +0000
parents 697ee89addfe
children b61939524c3c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # A ScrolledText widget feels like a text widget but also has a
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # vertical scroll bar on its right. (Later, options may be added to
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # add a horizontal bar as well, to make the bars disappear
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # automatically when not needed, to move them to the other side of the
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 # window, etc.)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 #
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 # Configuration options are passed to the Text widget.
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 # A Frame widget is inserted between the master and the text, to hold
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 # the Scrollbar widget.
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
10 # Most methods calls are inherited from the Text widget; Pack methods
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
11 # are redirected to the Frame widget however.
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 from Tkinter import *
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
14 from Tkinter import _cnfmerge
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
16 class ScrolledText(Text):
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 def __init__(self, master=None, cnf={}):
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
18 cnf = _cnfmerge(cnf)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 fcnf = {}
1757
697ee89addfe Use new packing and 'name' in cnf dict
Guido van Rossum <guido@python.org>
parents: 1712
diff changeset
20 vcnf = {'name': 'vbar',
697ee89addfe Use new packing and 'name' in cnf dict
Guido van Rossum <guido@python.org>
parents: 1712
diff changeset
21 Pack: {'side': 'right', 'fill': 'y'},}
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
22 for k in cnf.keys():
1757
697ee89addfe Use new packing and 'name' in cnf dict
Guido van Rossum <guido@python.org>
parents: 1712
diff changeset
23 if type(k) == ClassType or k == 'name':
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
24 fcnf[k] = cnf[k]
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
25 del cnf[k]
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
26 self.frame = Frame(master, fcnf)
1757
697ee89addfe Use new packing and 'name' in cnf dict
Guido van Rossum <guido@python.org>
parents: 1712
diff changeset
27 self.vbar = Scrollbar(self.frame, vcnf)
1708
de2dc1bc4bae Added bind and tag_config methods; minor lay-out change
Guido van Rossum <guido@python.org>
parents: 1706
diff changeset
28 cnf[Pack] = {'side': 'left', 'fill': 'both', 'expand': 'yes'}
1757
697ee89addfe Use new packing and 'name' in cnf dict
Guido van Rossum <guido@python.org>
parents: 1712
diff changeset
29 cnf['name'] = 'text'
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
30 Text.__init__(self, self.frame, cnf)
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
31 self['yscrollcommand'] = (self.vbar, 'set')
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
32 self.vbar['command'] = (self, 'yview')
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
33
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
34 # Copy Pack methods of self.frame -- hack!
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
35 for m in Pack.__dict__.keys():
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
36 if m[0] != '_' and m != 'config':
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
37 setattr(self, m, getattr(self.frame, m))