diff -r 943d3e289ab4 Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py Wed Oct 17 17:33:26 2012 +0300 +++ b/Lib/tkinter/__init__.py Thu May 09 13:39:25 2013 -0300 @@ -2849,9 +2849,13 @@ self.tk.call((self._w, 'set') + args) +import itertools class Text(Widget, XView, YView): """Text widget which can display text in various forms.""" + + peer_count = itertools.count(1) + def __init__(self, master=None, cnf={}, **kw): """Construct a text widget with the parent MASTER. @@ -3075,13 +3079,18 @@ def mark_previous(self, index): """Return the name of the previous mark before INDEX.""" return self.tk.call(self._w, 'mark', 'previous', index) or None - def peer_create(self, newPathName, cnf={}, **kw): # new in Tk 8.5 - """Creates a peer text widget with the given newPathName, and any - optional standard configuration options. By default the peer will - have the same start and and end line as the parent widget, but - these can be overriden with the standard configuration options.""" - self.tk.call(self._w, 'peer', 'create', newPathName, - *self._options(cnf, kw)) + def peer_create(self, newPathName=None, cnf={}, **kw): # new in Tk 8.5 + """Creates a peer text widget and any optional standard + configuration options. By default the peer will have the same + start and and end line as the parent widget, but these can be + overriden with the standard configuration options.""" + if newPathName is None: + basename = self.master._w if self.master._w != '.' else '' + newPathName = '%sp%d' % (basename, next(self.peer_count)) + self.tk.call(self._w, 'peer', 'create', '.' + newPathName, + *self._options(cnf, kw)) + peer = _textpeer(self.master, newPathName) + return peer def peer_names(self): # new in Tk 8.5 """Returns a list of peers of this widget (this does not include the widget itself).""" @@ -3213,6 +3222,11 @@ """Obsolete function, use see.""" self.tk.call((self._w, 'yview', '-pickplace') + what) +class _textpeer(Text): + """Internal class used to represent a text peer.""" + def __init__(self, master, name): + BaseWidget._setup(self, master, {'name': name}) + class _setit: """Internal class. It wraps the command in the widget OptionMenu."""