summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-07-06 21:54:39 (GMT)
committerGuido van Rossum <guido@python.org>1994-07-06 21:54:39 (GMT)
commit460b6bb1920a718c2189e5e35ff6dac38ebd8224 (patch)
treecc58894569476bfbb10c5f9ba73dd5d819835524
parent72cb020b19e82bb48bbd81f2db7348aca0033f4f (diff)
downloadcpython-460b6bb1920a718c2189e5e35ff6dac38ebd8224.zip
cpython-460b6bb1920a718c2189e5e35ff6dac38ebd8224.tar.gz
cpython-460b6bb1920a718c2189e5e35ff6dac38ebd8224.tar.bz2
Totally changed, now it is actually derived from Text
(This breaks something in MimeViewer.py, don't know what yet)
-rw-r--r--Lib/lib-tk/ScrolledText.py51
-rwxr-xr-xLib/tkinter/ScrolledText.py51
2 files changed, 40 insertions, 62 deletions
diff --git a/Lib/lib-tk/ScrolledText.py b/Lib/lib-tk/ScrolledText.py
index 4092d4f..2683696 100644
--- a/Lib/lib-tk/ScrolledText.py
+++ b/Lib/lib-tk/ScrolledText.py
@@ -7,40 +7,29 @@
# 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.
+# Most methods calls are inherited from the Text widget; Pack methods
+# are redirected to the Frame widget however.
from Tkinter import *
+from Tkinter import _cnfmerge
-class ScrolledText(Pack, Place):
+class ScrolledText(Text):
def __init__(self, master=None, cnf={}):
+ cnf = _cnfmerge(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'})
+ for k in cnf.keys():
+ if type(k) == ClassType:
+ fcnf[k] = cnf[k]
+ del cnf[k]
+ self.frame = Frame(master, fcnf)
+ self.vbar = Scrollbar(self.frame, {
+ 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.bind = self.text.bind
- self.forget = self.frame.forget
- self.delete = self.text.delete
- self.insert = self.text.insert
- self.index = self.text.index
- self.get = self.text.get
- self.mark_set = self.text.mark_set
- self.tag_add = self.text.tag_add
- self.tag_delete = self.text.tag_delete
- self.tag_remove = self.text.tag_remove
- self.tag_config = self.text.tag_config
- self.yview = self.text.yview
- self.yview_pickplace = self.text.yview_pickplace
- self.tk = master.tk
- def __str__(self):
- return str(self.frame)
+ Text.__init__(self, self.frame, cnf)
+ self['yscrollcommand'] = (self.vbar, 'set')
+ self.vbar['command'] = (self, 'yview')
+
+ # Copy Pack methods of self.frame -- hack!
+ for m in Pack.__dict__.keys():
+ if m[0] != '_' and m != 'config':
+ setattr(self, m, getattr(self.frame, m))
diff --git a/Lib/tkinter/ScrolledText.py b/Lib/tkinter/ScrolledText.py
index 4092d4f..2683696 100755
--- a/Lib/tkinter/ScrolledText.py
+++ b/Lib/tkinter/ScrolledText.py
@@ -7,40 +7,29 @@
# 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.
+# Most methods calls are inherited from the Text widget; Pack methods
+# are redirected to the Frame widget however.
from Tkinter import *
+from Tkinter import _cnfmerge
-class ScrolledText(Pack, Place):
+class ScrolledText(Text):
def __init__(self, master=None, cnf={}):
+ cnf = _cnfmerge(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'})
+ for k in cnf.keys():
+ if type(k) == ClassType:
+ fcnf[k] = cnf[k]
+ del cnf[k]
+ self.frame = Frame(master, fcnf)
+ self.vbar = Scrollbar(self.frame, {
+ 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.bind = self.text.bind
- self.forget = self.frame.forget
- self.delete = self.text.delete
- self.insert = self.text.insert
- self.index = self.text.index
- self.get = self.text.get
- self.mark_set = self.text.mark_set
- self.tag_add = self.text.tag_add
- self.tag_delete = self.text.tag_delete
- self.tag_remove = self.text.tag_remove
- self.tag_config = self.text.tag_config
- self.yview = self.text.yview
- self.yview_pickplace = self.text.yview_pickplace
- self.tk = master.tk
- def __str__(self):
- return str(self.frame)
+ Text.__init__(self, self.frame, cnf)
+ self['yscrollcommand'] = (self.vbar, 'set')
+ self.vbar['command'] = (self, 'yview')
+
+ # Copy Pack methods of self.frame -- hack!
+ for m in Pack.__dict__.keys():
+ if m[0] != '_' and m != 'config':
+ setattr(self, m, getattr(self.frame, m))