Advertisement
Guest User

Untitled

a guest
May 9th, 2013
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.43 KB | None | 0 0
  1. diff -r 943d3e289ab4 Lib/tkinter/__init__.py
  2. --- a/Lib/tkinter/__init__.py   Wed Oct 17 17:33:26 2012 +0300
  3. +++ b/Lib/tkinter/__init__.py   Thu May 09 13:39:25 2013 -0300
  4. @@ -2849,9 +2849,13 @@
  5.          self.tk.call((self._w, 'set') + args)
  6.  
  7.  
  8. +import itertools
  9.  
  10.  class Text(Widget, XView, YView):
  11.      """Text widget which can display text in various forms."""
  12. +
  13. +    peer_count = itertools.count(1)
  14. +
  15.      def __init__(self, master=None, cnf={}, **kw):
  16.          """Construct a text widget with the parent MASTER.
  17.  
  18. @@ -3075,13 +3079,18 @@
  19.      def mark_previous(self, index):
  20.          """Return the name of the previous mark before INDEX."""
  21.          return self.tk.call(self._w, 'mark', 'previous', index) or None
  22. -    def peer_create(self, newPathName, cnf={}, **kw): # new in Tk 8.5
  23. -        """Creates a peer text widget with the given newPathName, and any
  24. -        optional standard configuration options. By default the peer will
  25. -        have the same start and and end line as the parent widget, but
  26. -        these can be overriden with the standard configuration options."""
  27. -        self.tk.call(self._w, 'peer', 'create', newPathName,
  28. -            *self._options(cnf, kw))
  29. +    def peer_create(self, newPathName=None, cnf={}, **kw): # new in Tk 8.5
  30. +        """Creates a peer text widget and any optional standard
  31. +        configuration options. By default the peer will have the same
  32. +        start and and end line as the parent widget, but these can be
  33. +        overriden with the standard configuration options."""
  34. +        if newPathName is None:
  35. +            basename = self.master._w if self.master._w != '.' else ''
  36. +            newPathName = '%sp%d' % (basename, next(self.peer_count))
  37. +        self.tk.call(self._w, 'peer', 'create', '.' + newPathName,
  38. +                *self._options(cnf, kw))
  39. +        peer = _textpeer(self.master, newPathName)
  40. +        return peer
  41.      def peer_names(self): # new in Tk 8.5
  42.          """Returns a list of peers of this widget (this does not include
  43.          the widget itself)."""
  44. @@ -3213,6 +3222,11 @@
  45.          """Obsolete function, use see."""
  46.          self.tk.call((self._w, 'yview', '-pickplace') + what)
  47.  
  48. +class _textpeer(Text):
  49. +    """Internal class used to represent a text peer."""
  50. +    def __init__(self, master, name):
  51. +        BaseWidget._setup(self, master, {'name': name})
  52. +
  53.  
  54.  class _setit:
  55.      """Internal class. It wraps the command in the widget OptionMenu."""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement