summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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))