diff options
author | Guido van Rossum <guido@python.org> | 1994-06-20 07:49:28 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-06-20 07:49:28 (GMT) |
commit | 1846882254324ac5eb0a96df493c7ab1eabd866e (patch) | |
tree | 2d50f13c58392240f474855bfe348a166add7b92 /Lib/tkinter/ScrolledText.py | |
parent | 7ce61c13882dd79737eda97ae78aa81832f96aba (diff) | |
download | cpython-1846882254324ac5eb0a96df493c7ab1eabd866e.zip cpython-1846882254324ac5eb0a96df493c7ab1eabd866e.tar.gz cpython-1846882254324ac5eb0a96df493c7ab1eabd866e.tar.bz2 |
Initial revision
Diffstat (limited to 'Lib/tkinter/ScrolledText.py')
-rwxr-xr-x | Lib/tkinter/ScrolledText.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/tkinter/ScrolledText.py b/Lib/tkinter/ScrolledText.py new file mode 100755 index 0000000..9effae0 --- /dev/null +++ b/Lib/tkinter/ScrolledText.py @@ -0,0 +1,35 @@ +# A ScrolledText widget feels like a text widget but also has a +# vertical scroll bar on its right. (Later, options may be added to +# add a horizontal bar as well, to make the bars disappear +# automatically when not needed, to move them to the other side of the +# window, etc.) +# +# Configuration options are passed to the Text widget. +# A Frame widget is inserted between the master and the text, to hold +# the Scrollbar widget. +# Most methods calls are passed to the Text widget; the pack command +# is redirected to the Frame widget however. + +from Tkinter import * + +class ScrolledText(Pack, Place): + def __init__(self, master=None, cnf={}): + fcnf = {} + self.frame = Frame(master, {}) + if cnf.has_key(Pack): + self.frame.pack(cnf[Pack]) + del cnf[Pack] + self.vbar = Scrollbar(self.frame, {}) + self.vbar.pack({'side': 'right', 'fill': 'y'}) + cnf[Pack] = {'side': 'left', 'fill': 'both', + 'expand': 'yes'} + self.text = Text(self.frame, cnf) + self.text['yscrollcommand'] = (self.vbar, 'set') + self.vbar['command'] = (self.text, 'yview') + self.insert = self.text.insert + # XXX should do all Text methods... + self.pack = self.frame.pack + self.forget = self.frame.forget + self.tk = master.tk + def __str__(self): + return str(self.frame) |