***************** wx.TextDataObject ***************** Inheritance diagram for `wx.TextDataObject`: | .. inheritance-diagram:: wx.TextDataObject | Description =========== `wx.TextDataObject` is a specialization of `wx.DataObject `_ for text data. It can be used without change to paste data into the `wx.Clipboard `_ or a `wx.DropSource `_. A user may wish to derive a new class from this class for providing text on-demand in order to minimize memory consumption when offering data in several formats, such as plain text and RTF because by default the text is stored in a string in this class, but it might as well be generated when requested. For this, `GetTextLength <#GetTextLength>`_ and `GetText <#GetText>`_ will have to be overridden. .. note:: Note that if you already have the text inside a string, you will not achieve any efficiency gain by overriding these functions because copying strings is already a very efficient operation. .. note:: **wxPython note:** If you wish to create a derived `wx.TextDataObject` class in wxPython you should derive the class from `wx.PyTextDataObject `_ in order to get Python-aware capabilities for the various virtual methods. .. seealso:: `wx.DataObject `_, `wx.DataObjectSimple `_, `wx.FileDataObject `_, `wx.BitmapDataObject `_ Derived From ^^^^^^^^^^^^^ * `wx.DataObjectSimple `_ * `wx.DataObject `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.PyTextDataObject `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `GetText <#GetText>`_ * `GetTextLength <#GetTextLength>`_ * `SetText <#SetText>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Text <#Text>`_ * `TextLength <#TextLength>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(text="") Constructor, may be used to initialise the text (otherwise `SetText <#SetText>`_ should be used later). **Parameters:** * `text` (string) | **Returns:** `wx.TextDataObject `_ -------- .. method:: GetText() Returns the text associated with the data object. You may wish to override this method when offering data on-demand, but this is not required by wxWidgets' internals. Use this method to get data in text form from the `wx.Clipboard `_. | **Returns:** `string` -------- .. method:: GetTextLength() Returns the data size. By default, returns the size of the text data set in the constructor or using `SetText <#SetText>`_. This can be overridden to provide text size data on-demand. It is recommended to return the text length plus 1 for a trailing zero, but this is not strictly required. | **Returns:** `long` -------- .. method:: SetText(strText) Sets the text associated with the data object. This method is called when the data object receives the data and, by default, copies the text into the member variable. If you want to process the text on the fly you may wish to override this function. **Parameters:** * `strText` (string) -------- Properties ^^^^^^^^^^ .. attribute:: Text See `GetText <#GetText>`_ and `SetText <#SetText>`_ .. attribute:: TextLength See `GetTextLength <#GetTextLength>`_