diff options
author | Ned Deily <nad@acm.org> | 2012-05-16 01:13:02 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2012-05-16 01:13:02 (GMT) |
commit | a0082788e4a1e7d821f2ced3a33988882e360fb1 (patch) | |
tree | f5d8b84c2f1a4346d3c4e402eee7616185f995f4 /Lib | |
parent | c8e106babba7b54d38992ebed33ac3feb74b3cb5 (diff) | |
parent | 4d377d98a1b4ab115bcd816553600e603e388831 (diff) | |
download | cpython-a0082788e4a1e7d821f2ced3a33988882e360fb1.zip cpython-a0082788e4a1e7d821f2ced3a33988882e360fb1.tar.gz cpython-a0082788e4a1e7d821f2ced3a33988882e360fb1.tar.bz2 |
Issue #14777: merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/tkinter/__init__.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 1558cda..8063dd6 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -540,12 +540,19 @@ class Misc: The type keyword specifies the form in which the data is to be returned and should be an atom name such as STRING - or FILE_NAME. Type defaults to STRING. + or FILE_NAME. Type defaults to STRING, except on X11, where the default + is to try UTF8_STRING and fall back to STRING. This command is equivalent to: selection_get(CLIPBOARD) """ + if 'type' not in kw and self._windowingsystem == 'x11': + try: + kw['type'] = 'UTF8_STRING' + return self.tk.call(('clipboard', 'get') + self._options(kw)) + except TclError: + del kw['type'] return self.tk.call(('clipboard', 'get') + self._options(kw)) def clipboard_clear(self, **kw): @@ -627,8 +634,16 @@ class Misc: A keyword parameter selection specifies the name of the selection and defaults to PRIMARY. A keyword parameter displayof specifies a widget on the display - to use.""" + to use. A keyword parameter type specifies the form of data to be + fetched, defaulting to STRING except on X11, where UTF8_STRING is tried + before STRING.""" if 'displayof' not in kw: kw['displayof'] = self._w + if 'type' not in kw and self._windowingsystem == 'x11': + try: + kw['type'] = 'UTF8_STRING' + return self.tk.call(('selection', 'get') + self._options(kw)) + except TclError: + del kw['type'] return self.tk.call(('selection', 'get') + self._options(kw)) def selection_handle(self, command, **kw): """Specify a function COMMAND to call if the X @@ -1043,6 +1058,15 @@ class Misc: if displayof is None: return ('-displayof', self._w) return () + @property + def _windowingsystem(self): + """Internal function.""" + try: + return self._root()._windowingsystem_cached + except AttributeError: + ws = self._root()._windowingsystem_cached = \ + self.tk.call('tk', 'windowingsystem') + return ws def _options(self, cnf, kw = None): """Internal function.""" if kw: |