MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / fromClipboard

Function fromClipboard

gui/utils/clipboard.py:38–68  ·  view source on GitHub ↗

Read text from clipboard. Explicitly uses CLIPBOARD selection, not PRIMARY. On X11 systems, wxPython can confuse between PRIMARY and CLIPBOARD selections, causing "already open" errors. This function ensures we always use CLIPBOARD. See: https://discuss.wxpython.org/t/wx-the

()

Source from the content-addressed store, hash-verified

36
37
38def fromClipboard():
39 """
40 Read text from clipboard. Explicitly uses CLIPBOARD selection, not PRIMARY.
41
42 On X11 systems, wxPython can confuse between PRIMARY and CLIPBOARD selections,
43 causing "already open" errors. This function ensures we always use CLIPBOARD.
44
45 See: https://discuss.wxpython.org/t/wx-theclipboard-pasting-different-content-on-every-second-paste/35361
46 """
47 clipboard = wx.TheClipboard
48 try:
49 # Explicitly use CLIPBOARD selection, not PRIMARY selection
50 # This prevents X11 confusion between the two clipboard types
51 clipboard.UsePrimarySelection(False)
52
53 if clipboard.Open():
54 try:
55 data = wx.TextDataObject()
56 if clipboard.GetData(data):
57 return data.GetText()
58 else:
59 logger.debug("Clipboard open but no CLIPBOARD data available")
60 return None
61 finally:
62 clipboard.Close()
63 else:
64 logger.debug("Failed to open clipboard for reading")
65 return None
66 except Exception as e:
67 logger.warning("Error reading from clipboard: {}", e)
68 return None

Callers 7

importPatternsMethod · 0.90
importPatternsMethod · 0.90
importPatternsMethod · 0.90
importFromClipboardMethod · 0.90
importSkillsMethod · 0.90
displayMethod · 0.90
activateMethod · 0.90

Calls 1

GetDataMethod · 0.80

Tested by

no test coverage detected