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

Function toClipboard

gui/utils/clipboard.py:8–35  ·  view source on GitHub ↗

Copy text to 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-thecl

(text)

Source from the content-addressed store, hash-verified

6
7
8def toClipboard(text):
9 """
10 Copy text to clipboard. Explicitly uses CLIPBOARD selection, not PRIMARY.
11
12 On X11 systems, wxPython can confuse between PRIMARY and CLIPBOARD selections,
13 causing "already open" errors. This function ensures we always use CLIPBOARD.
14
15 See: https://discuss.wxpython.org/t/wx-theclipboard-pasting-different-content-on-every-second-paste/35361
16 """
17 clipboard = wx.TheClipboard
18 try:
19 # Explicitly use CLIPBOARD selection, not PRIMARY selection
20 # This prevents X11 confusion between the two clipboard types
21 clipboard.UsePrimarySelection(False)
22
23 if clipboard.Open():
24 try:
25 data = wx.TextDataObject(text)
26 clipboard.SetData(data)
27 return True
28 finally:
29 clipboard.Close()
30 else:
31 logger.debug("Failed to open clipboard for writing")
32 return False
33 except Exception as e:
34 logger.warning("Error writing to clipboard: {}", e)
35 return False
36
37
38def fromClipboard():

Callers 12

exportPatternsMethod · 0.90
exportPatternsMethod · 0.90
cbMethod · 0.90
exportPatternsMethod · 0.90
exportSkillsMethod · 0.90
exportSkillsCondensedMethod · 0.90
exportSkillsEveMonMethod · 0.90
exportSkillsMethod · 0.90
activateMethod · 0.90
activateMethod · 0.90
activateMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected