Mercurial > cpython-lru_cache-weakref
annotate Lib/tkinter/ScrolledText.py @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | b61939524c3c |
| children | 3feec85bba9b |
| rev | line source |
|---|---|
| 1664 | 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. | |
|
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 | 12 |
| 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 | 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): |
|
3860
b61939524c3c
Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents:
1757
diff
changeset
|
17 def __init__(self, master=None, **cnf): |
| 1664 | 18 fcnf = {} |
|
1712
2ef9d50ab654
Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents:
1708
diff
changeset
|
19 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
|
20 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
|
21 fcnf[k] = cnf[k] |
|
2ef9d50ab654
Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents:
1708
diff
changeset
|
22 del cnf[k] |
|
3860
b61939524c3c
Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents:
1757
diff
changeset
|
23 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
|
24 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
|
25 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
|
26 cnf['name'] = 'text' |
|
3860
b61939524c3c
Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents:
1757
diff
changeset
|
27 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
|
28 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
|
29 self['yscrollcommand'] = self.vbar.set |
|
b61939524c3c
Change to use keyword args instead of dicts
Guido van Rossum <guido@python.org>
parents:
1757
diff
changeset
|
30 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
|
31 |
|
2ef9d50ab654
Totally changed, now it is actually derived from Text
Guido van Rossum <guido@python.org>
parents:
1708
diff
changeset
|
32 # 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
|
33 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
|
34 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
|
35 setattr(self, m, getattr(self.frame, m)) |
