annotate Lib/lib-tk/ScrolledText.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 3feec85bba9b
children fd29cebe88dc
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):
5091
3feec85bba9b Put support for a cnf dictionary back in, since it is still supported
Guido van Rossum <guido@python.org>
parents: 3860
diff changeset
17 def __init__(self, master=None, cnf={}, **kw):
3feec85bba9b Put support for a cnf dictionary back in, since it is still supported
Guido van Rossum <guido@python.org>
parents: 3860
diff changeset
18 if kw:
3feec85bba9b Put support for a cnf dictionary back in, since it is still supported
Guido van Rossum <guido@python.org>
parents: 3860
diff changeset
19 cnf = _cnfmerge((cnf, kw))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 fcnf = {}
1712
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
21 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
22 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
23 fcnf[k] = cnf[k]
2ef9d50ab654 Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents: 1708
diff changeset
24 del cnf[k]
3860
b61939524c3c Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents: 1757
diff changeset
25 self.frame = apply(Frame, (master,), fcnf)
b61939524c3c Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents: 1757
diff changeset
26 self.vbar = Scrollbar(self.frame, name='vbar')
b61939524c3c Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents: 1757
diff changeset
27 self.vbar.pack(side=RIGHT, fill=Y)
1757
697ee89addfe Use new packing and 'name' in cnf dict
Guido van Rossum <guido@python.org>
parents: 1712
diff changeset
28 cnf['name'] = 'text'
3860
b61939524c3c Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents: 1757
diff changeset
29 apply(Text.__init__, (self, self.frame), cnf)
b61939524c3c Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents: 1757
diff changeset
30 self.pack(side=LEFT, fill=BOTH, expand=1)
b61939524c3c Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents: 1757
diff changeset
31 self['yscrollcommand'] = self.vbar.set
b61939524c3c Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents: 1757
diff changeset
32 self.vbar['command'] = self.yview
1712
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))