.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.DataFormat: ========================================================================================================================================== |phoenix_title| **wx.DataFormat** ========================================================================================================================================== A :ref:`wx.DataFormat` is an encapsulation of a platform-specific format handle which is used by the system for the clipboard and drag and drop operations. The applications are usually only interested in, for example, pasting data from the clipboard only if the data is in a format the program understands and a data format is something which uniquely identifies this format. On the system level, a data format is usually just a number ( ``CLIPFORMAT`` under Windows or ``Atom`` under X11, for example) and the standard formats are, indeed, just numbers which can be implicitly converted to :ref:`wx.DataFormat`. The standard formats are: ======================== ================================================================================================================ ``wx.DF_INVALID`` An invalid format - used as default argument for functions taking a :ref:`wx.DataFormat` argument sometimes. ``wx.DF_TEXT`` Text format (`String` ). ``wx.DF_BITMAP`` A bitmap (:ref:`wx.Bitmap`). ``wx.DF_METAFILE`` A metafile (:ref:`wx.Metafile`, Windows only). ``wx.DF_UNICODETEXT`` Unicode text format (`String` ). ``wx.DF_FILENAME`` A list of filenames. ``wx.DF_HTML`` An HTML string. This is currently only valid on Mac and MSW. ``wx.DF_PNG`` A ``PNG`` file. This is valid only on MSW. This constant is available since wxWidgets 3.1.5. ======================== ================================================================================================================ | As mentioned above, these standard formats may be passed to any function taking :ref:`wx.DataFormat` argument because :ref:`wx.DataFormat` has an implicit conversion from them (or, to be precise from the type ``DataFormat::NativeFormat`` which is the type used by the underlying platform for data formats). Aside the standard formats, the application may also use custom formats which are identified by their names (strings) and not numeric identifiers. Although internally custom format must be created (or `registered`) first, you shouldn't care about it because it is done automatically the first time the :ref:`wx.DataFormat` object corresponding to a given format name is created. The only implication of this is that you should avoid having global :ref:`wx.DataFormat` objects with non-default constructor because their constructors are executed before the program has time to perform all necessary initialisations and so an attempt to do clipboard format registration at this time will usually lead to a crash! .. seealso:: :ref:`Drag and Drop Overview `, :ref:`Drag & Drop Sample `, :ref:`wx.DataObject` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class DataFormat:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.DataFormat.__init__` Constructs a data format object for one of the standard data formats or an empty data object (use :meth:`~DataFormat.SetType` or :meth:`~DataFormat.SetId` later in this case). :meth:`~wx.DataFormat.GetId` Returns the name of a custom format (this function will fail for a standard format). :meth:`~wx.DataFormat.GetType` Returns the platform-specific number identifying the format. :meth:`~wx.DataFormat.SetId` Sets the format to be the custom format identified by the given name. :meth:`~wx.DataFormat.SetType` Sets the format to the given value, which should be one of ``DF_XXX`` constants. :meth:`~wx.DataFormat.__ne__` Returns ``True`` if the formats are different. :meth:`~wx.DataFormat.__eq__` Returns ``True`` if the formats are equal. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.DataFormat.Id` See :meth:`~wx.DataFormat.GetId` and :meth:`~wx.DataFormat.SetId` :attr:`~wx.DataFormat.Type` See :meth:`~wx.DataFormat.GetType` and :meth:`~wx.DataFormat.SetType` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.DataFormat(object) **Possible constructors**:: DataFormat(format=DF_INVALID) DataFormat(format) A DataFormat is an encapsulation of a platform-specific format handle which is used by the system for the clipboard and drag and drop operations. .. method:: __init__(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **__init__** `(self, format=DF_INVALID)` Constructs a data format object for one of the standard data formats or an empty data object (use :meth:`SetType` or :meth:`SetId` later in this case). :html:`

` **__init__** `(self, format)` Constructs a data format object for a custom format identified by its name `format`. :html:`

` .. method:: GetId(self) Returns the name of a custom format (this function will fail for a standard format). :rtype: `string` .. method:: GetType(self) Returns the platform-specific number identifying the format. :rtype: :ref:`wx.DataFormatId` .. method:: SetId(self, format) Sets the format to be the custom format identified by the given name. :param `format`: :type `format`: string .. method:: SetType(self, type) Sets the format to the given value, which should be one of ``DF_XXX`` constants. :param `type`: :type `type`: wx.DataFormatId .. method:: __ne__(self, *args, **kw) Returns ``True`` if the formats are different. |overload| Overloaded Implementations: :html:`

` **__ne__** `(self)` :param `format`: :type `format`: wx.DataFormat :html:`

` **__ne__** `(self)` :param `format`: :type `format`: wx.DataFormatId :html:`

` .. method:: __eq__(self, *args, **kw) Returns ``True`` if the formats are equal. |overload| Overloaded Implementations: :html:`

` **__eq__** `(self)` :param `format`: :type `format`: wx.DataFormat :html:`

` **__eq__** `(self)` :param `format`: :type `format`: wx.DataFormatId :html:`

` .. attribute:: Id See :meth:`~wx.DataFormat.GetId` and :meth:`~wx.DataFormat.SetId` .. attribute:: Type See :meth:`~wx.DataFormat.GetType` and :meth:`~wx.DataFormat.SetType`