While you have the clipboard open, you can manipulate the data object it holds in a couple of different ways. You can place your object on the clipboard with Set-Data(data), where the data parameter is any wx.DataObject instance. You can empty the clipboard with the method Clear(). If you want the data on the clipboard to survive after the close of your application, you must call the method Flush(), which instructs the system to hold on to your data. Otherwise, the wxPython clipboard object is cleared when your application exits.
Here is the code to add text to the clipboard:
text_data = wx.TextDataObject("hi there")
Was this article helpful?