Putting objects on the clipboard

The clipboard and drag and drop features are closely related in wxPython. In both cases, the inter-window communication is mediated using an instance of wx.DataObject or one of its subclasses. The wx.DataObject is a special data object which contains metadata describing the formats that can be used to output the data. We'll start by discussing the clipboard, and then we'll talk about how drag and drop is handled differently.

There are three elements to a cut and paste operation.

If the source is in your application, your application is responsible for creating an instance of wx.DataObject and handing it off to the clipboard object. Often, the source for the clipboard data is external to your application.

The clipboard is a global object that holds onto the data and interacts with the underlying system clipboard as needed.

The target object is responsible for retrieving the wx.DataObject from the clipboard and converting it into some kind of useful data for your application.

Was this article helpful?

0 0

Post a comment