From ce7333945f8f90ad59d079ba393b16323934944f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 28 Dec 2017 14:19:35 -0800 Subject: [PATCH] Update clipboard sample code --- .../python/converted/wx.Clipboard.1.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/wx.Clipboard.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.Clipboard.1.py index 9955a8cd..3a9706ba 100644 --- a/docs/sphinx/rest_substitutions/snippets/python/converted/wx.Clipboard.1.py +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.Clipboard.1.py @@ -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()