Merge pull request #655 from RobinD42/fix-issue633

Update clipboard sample code
This commit is contained in:
Robin Dunn
2017-12-28 21:58:58 -06:00
committed by GitHub

View File

@@ -1,20 +1,19 @@
# Write some text to the clipboard
if wx.TheClipboard.Open():
# This data objects are held by the clipboard,
# so do not delete them in the app.
wx.TheClipboard.SetData(wx.TextDataObject("Some text"))
wx.TheClipboard.Close()
# Test if text content is available
not_empty = wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT))
# Read some text
text_data = wx.TextDataObject()
if wx.TheClipboard.Open():
if wx.TheClipboard.IsSupported(wx.DF_TEXT):
data = wx.TextDataObject()
wx.TheClipboard.GetData(data)
wx.MessageBox(data.GetText())
success = wx.TheClipboard.GetData(text_data)
wx.TheClipboard.Close()
if success:
return text_data.GetText()