Home | Trees | Index | Help |
|
---|
Package wx :: Class DataObject |
|
object
--+
|
DataObject
DataObjectComposite
,
DataObjectSimple
,
URLDataObject
A wx.DataObject represents data that can be copied to or from the clipboard, or dragged and dropped. The important thing about wx.DataObject is that this is a 'smart' piece of data unlike usual 'dumb' data containers such as memory buffers or files. Being 'smart' here means that the data object itself should know what data formats it supports and how to render itself in each of supported formats.
NOTE: This class is an abstract base class and can not be used
directly from Python. If you need a custom type of data object then
you should instead derive from wx.PyDataObjectSimple
or use
wx.CustomDataObject
.
Not surprisingly, being 'smart' comes at a price of added complexity. This is reasonable for the situations when you really need to support multiple formats, but may be annoying if you only want to do something simple like cut and paste text.
To provide a solution for both cases, wxWidgets has two predefined
classes which derive from wx.DataObject: wx.DataObjectSimple
and
wx.DataObjectComposite
. wx.DataObjectSimple
is the simplest
wx.DataObject possible and only holds data in a single format (such as
text or bitmap) and wx.DataObjectComposite
is the simplest way to
implement a wx.DataObject which supports multiple simultaneous formats
because it achievs this by simply holding several
wx.DataObjectSimple
objects.
Please note that the easiest way to use drag and drop and the
clipboard with multiple formats is by using wx.DataObjectComposite
,
but it is not the most efficient one as each wx.DataObjectSimple
would contain the whole data in its respective formats. Now imagine
that you want to paste 200 pages of text in your proprietary format,
as well as Word, RTF, HTML, Unicode and plain text to the clipboard
and even today's computers are in trouble. For this case, you will
have to derive from wx.DataObject directly and make it enumerate its
formats and provide the data in the requested format on
demand. (TODO: This is currently not possible from Python. Make
it so.)
Note that the platform transfer mechanisms for the clipboard and drag and drop, do not copy any data out of the source application until another application actually requests the data. This is in contrast to the 'feel' offered to the user of a program who would normally think that the data resides in the clipboard after having pressed 'Copy' - in reality it is only declared to be available.
Method Summary | |
---|---|
__init__(self)
| |
__del__(self)
| |
__repr__(self)
| |
[formats] |
Returns a list of all the wx.DataFormats that this dataobject supports in the given direction. |
String |
Get the data bytes in the specified format, returns None on failure. |
size_t |
Get the (total) size of data for the given format |
size_t |
Returns the number of available formats for rendering or setting the data. |
DataFormat |
Returns the preferred format for either rendering the data (if dir is Get, its default value) or for setting it. |
bool |
Returns True if this format is supported. |
bool |
Set the data in the specified format from the bytes in the the data string. |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
Return hash(x)... | |
Return a new object with type S, a subtype of T... | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
Return str(x)... |
Class Variable Summary | |
---|---|
int |
Both = 3 |
int |
Get = 1 |
int |
Set = 2 |
Method Details |
---|
GetAllFormats(self, dir=Get)Returns a list of all the wx.DataFormats that this dataobject supports in the given direction.
|
GetDataHere(self, format)Get the data bytes in the specified format, returns None on failure.
|
GetDataSize(self, format)Get the (total) size of data for the given format
|
GetFormatCount(self, dir=Get)Returns the number of available formats for rendering or setting the data.
|
GetPreferredFormat(self, dir=Get)Returns the preferred format for either rendering the data (if dir is Get, its default value) or for setting it. Usually this will be the native format of the wx.DataObject.
|
IsSupported(self, format, dir=Get)Returns True if this format is supported.
|
SetData(self, format, data)Set the data in the specified format from the bytes in the the data string.
|
Class Variable Details |
---|
Both
|
Get
|
Set
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1.20050511.rpd on Sat Jun 16 17:01:58 2007 | http://epydoc.sf.net |