MCPcopy Create free account
hub / github.com/ipython/ipython / tkinter_clipboard_get

Function tkinter_clipboard_get

IPython/lib/clipboard.py:46–67  ·  view source on GitHub ↗

Get the clipboard's text using Tkinter. This is the default on systems that are not Windows or OS X. It may interfere with other UI toolkits and should be replaced with an implementation that uses that toolkit.

()

Source from the content-addressed store, hash-verified

44 return text
45
46def tkinter_clipboard_get():
47 """ Get the clipboard's text using Tkinter.
48
49 This is the default on systems that are not Windows or OS X. It may
50 interfere with other UI toolkits and should be replaced with an
51 implementation that uses that toolkit.
52 """
53 try:
54 from tkinter import Tk, TclError
55 except ImportError:
56 raise TryNext("Getting text from the clipboard on this platform requires tkinter.")
57
58 root = Tk()
59 root.withdraw()
60 try:
61 text = root.clipboard_get()
62 except TclError:
63 raise ClipboardEmpty
64 finally:
65 root.destroy()
66 text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)
67 return text
68
69

Callers 1

win_pasteFunction · 0.90

Calls 2

TryNextClass · 0.90
TkClass · 0.85

Tested by

no test coverage detected