GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Table of Contents
  • wx.TextDataObject
  • Show Source
  • index
  • modules
  • next
  • previous
  • Home
  • Gallery
  • wx

This view

  • Original page
  • New address

GeezerVison is showing docs.wxpython.org — wx.TextDataObject — wxPython 4.3.2 Docs

phoenix_title wx.TextDataObject¶

wx.TextDataObject is a specialization of wx.DataObjectSimple 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, in which case GetText should be overridden.

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 (data is not actually copied because Strings are reference counted).

See also

Drag and Drop Overview, wx.DataObject, wx.DataObjectSimple, wx.FileDataObject, wx.BitmapDataObject


class_hierarchy Class Hierarchy¶

Inheritance diagram for class TextDataObject:

Inheritance diagram of TextDataObject


method_summary Methods Summary¶

__init__

Constructor, may be used to initialise the text (otherwise SetText should be used later).

GetAllFormats

Returns a list of wx.DataFormat objects which this data object

GetFormat

Returns the preferred format supported by this object.

GetFormatCount

Returns 2 under Mac and wxGTK, where text data coming from the clipboard may be provided as ( DF_TEXT ), in ANSI (wxGTK) or UTF8 (wxMac), or as Unicode text ( DF_UNICODETEXT ).

GetText

Returns the text associated with the data object.

GetTextLength

SetData

SetText

Sets the text associated with the data object.


property_summary Properties Summary¶

AllFormats

See GetAllFormats

Format

See GetFormat

FormatCount

See GetFormatCount

Text

See GetText and SetText

TextLength

See GetTextLength


api Class API¶

class wx.TextDataObject(DataObjectSimple)¶

Possible constructors:

TextDataObject(text='') -> None

TextDataObject is a specialization of DataObjectSimple for text data.


Methods¶

__init__(self, text='')¶

Constructor, may be used to initialise the text (otherwise SetText should be used later).

Parameters:

text (string)

Return type:

None



GetAllFormats(self, dir=DataObject.Get)¶

Returns a list of wx.DataFormat objects which this data object supports transferring in the given direction.

Return type:

Any



GetFormat(self)¶

Returns the preferred format supported by this object.

This is DF_TEXT or DF_UNICODETEXT depending on the platform.

Return type:

wx.DataFormat



GetFormatCount(self, dir=DataObject.Get)¶

Returns 2 under Mac and wxGTK, where text data coming from the clipboard may be provided as ( DF_TEXT ), in ANSI (wxGTK) or UTF8 (wxMac), or as Unicode text ( DF_UNICODETEXT ).

Returns 1 under other platforms (e.g. wxMSW).

Parameters:

dir (DataObject.Direction)

Return type:

int



GetText(self)¶

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.

Return type:

str



GetTextLength(self)¶

Don’t use or call this function, it simply returns the length of the text plus one for compatibility purposes.

Return type:

int



SetData(self, format, buf)¶
Return type:

bool



SetText(self, 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)

Return type:

None


Properties¶

AllFormats¶

See GetAllFormats



Format¶

See GetFormat



FormatCount¶

See GetFormatCount



Text¶

See GetText and SetText



TextLength¶

See GetTextLength

© Copyright 2012-2026, The wxPython Team. Created using Sphinx 9.1.0 and the python-docs-theme.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.