************ wx.Clipboard ************ Inheritance diagram for `wx.Clipboard`: | .. inheritance-diagram:: wx.Clipboard | Description =========== A class for manipulating the clipboard. To use the clipboard, you call member functions of the global `wx.TheClipboard` object. Call `Open <#Open>`_ to get ownership of the clipboard. If this operation returns ``True``, you now own the clipboard. Call `SetData <#SetData>`_ to put data on the clipboard, or `GetData <#GetData>`_ to retrieve data from the clipboard. Call `Close <#Close>`_ to close the clipboard and relinquish ownership. You should keep the clipboard open only momentarily. For example:: # Try to open the clipboard... if wx.TheClipboard.Open(): # Create a wx.TextDataObject do = wx.TextDataObject() do.SetText("Hello from wxPython!") # Add the data to the clipboard wx.TheClipboard.SetData(do) # Close the clipboard wx.TheClipboard.Close() else: # oops... something went wrong! wx.MessageBox("Unable to open the clipboard", "Error") .. seealso:: `wx.DataObject `_, `wx.TextDataObject `_, `wx.BitmapDataObject `_ Derived From ^^^^^^^^^^^^^ * `wx.Object `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `AddData <#AddData>`_ * `Clear <#Clear>`_ * `Close <#Close>`_ * `Flush <#Flush>`_ * `Get <#Get>`_ * `GetData <#GetData>`_ * `IsOpened <#IsOpened>`_ * `IsSupported <#IsSupported>`_ * `Open <#Open>`_ * `SetData <#SetData>`_ * `UsePrimarySelection <#UsePrimarySelection>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__() `No docstrings available for this method.` -------- .. method:: AddData(data) Call this function to add the data object to the clipboard. You may call this function repeatedly after having cleared the clipboard using `Clear <#Clear>`_. After this function has been called, the clipboard owns the data, so do not delete the data explicitly. **Parameters:** * `data` (`wx.DataObject `_) | **Returns:** `bool` .. seealso:: `SetData <#SetData>`_ -------- .. method:: Clear() Clears the global clipboard object and the system's clipboard if possible. -------- .. method:: Close() Call this function to close the clipboard, having opened it with `Open <#Open>`_. -------- .. method:: Flush() Flushes the clipboard: this means that the data which is currently on clipboard will stay available even after the application exits (possibly eating memory), otherwise the clipboard will be emptied on exit. Returns ``False`` if the operation is unsuccessful for any reason. | **Returns:** `bool` -------- .. method:: Get() Returns global instance (`wx.TheClipboard`) of the object. | **Returns:** `wx.Clipboard `_ -------- .. method:: GetData(data) Call this function to fill `data` with data on the clipboard, if available in the required format. Returns ``True`` on success. **Parameters:** * `data` (`wx.DataObject `_) | **Returns:** `bool` -------- .. method:: IsOpened() Returns ``True`` if the clipboard has been opened. | **Returns:** `bool` -------- .. method:: IsSupported(format) Returns ``True`` if there is data which matches the data format of the given data object currently *available* on the clipboard. **Parameters:** * `format` (`wx.DataFormat `_) | **Returns:** `bool` -------- .. method:: Open() Call this function to open the clipboard before calling `SetData <#SetData>`_ and `GetData <#GetData>`_. Call `Close <#Close>`_ when you have finished with the clipboard. You should keep the clipboard open for only a very short time. Returns ``True`` on success. This should be tested (as in the sample shown above). | **Returns:** `bool` -------- .. method:: SetData(data) Call this function to set the data object to the clipboard. This function will clear all previous contents in the clipboard, so calling it several times does not make any sense. After this function has been called, the clipboard owns the data, so do not delete the data explicitly. **Parameters:** * `data` (`wx.DataObject `_) | **Returns:** `bool` .. seealso:: `AddData <#AddData>`_ -------- .. method:: UsePrimarySelection(primary=True) On platforms supporting it (currently only GTK), selects the so called ``PRIMARY SELECTION`` as the clipboard as opposed to the normal clipboard, if `primary` is ``True``. **Parameters:** * `primary` (bool)