.. 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.MimeTypesManager: ========================================================================================================================================== |phoenix_title| **wx.MimeTypesManager** ========================================================================================================================================== This class allows the application to retrieve information about all known MIME types from a system-specific location and the filename extensions to the MIME types and vice versa. MIME stands for "Multipurpose Internet Mail Extensions" and was originally used in mail protocols. It's standardized by several RFCs. Under Windows, the MIME type information is queried from registry. Under Linux and Unix, it is queried from the XDG data directories. Currently, :ref:`wx.MimeTypesManager` is limited to `reading` MIME type information. The application should not construct its own manager: it should use the object pointer `wx.TheMimeTypesManager` . The functions :meth:`~wx.MimeTypesManager.GetFileTypeFromMimeType` and :meth:`~wx.MimeTypesManager.GetFileTypeFromExtension` return a :ref:`wx.FileType` object which may be further queried for file description, icon and other attributes. |phoenix_title| Helper functions ================================ All of these functions are static (i.e. don't need a :ref:`wx.MimeTypesManager` object to call them) and provide some useful operations for string representations of MIME types. Their usage is recommended instead of directly working with MIME types using `String` functions. - :meth:`wx.MimeTypesManager.IsOfType` |phoenix_title| Query database ============================== These functions are the heart of this class: they allow to find a file type object from either file extension or MIME type. If the function is successful, it returns a pointer to the :ref:`wx.FileType` object which must be deleted by the caller, otherwise ``None`` will be returned. - :meth:`wx.MimeTypesManager.GetFileTypeFromMimeType` - :meth:`wx.MimeTypesManager.GetFileTypeFromExtension` .. seealso:: :ref:`wx.FileType` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class MimeTypesManager:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.MimeTypesManager.__init__` Constructor puts the object in the "working" state. :meth:`~wx.MimeTypesManager.AddFallbacks` This function may be used to provide hard-wired fallbacks for the MIME types and extensions that might not be present in the system MIME database. :meth:`~wx.MimeTypesManager.Associate` Create a new association using the fields of :ref:`wx.FileTypeInfo` (at least the MIME type and the extension should be set). :meth:`~wx.MimeTypesManager.EnumAllFileTypes` Returns a list of all known file types. :meth:`~wx.MimeTypesManager.GetFileTypeFromExtension` Gather information about the files with given extension and return the corresponding :ref:`wx.FileType` object or ``None`` if the extension is unknown. :meth:`~wx.MimeTypesManager.GetFileTypeFromMimeType` Gather information about the files with given MIME type and return the corresponding :ref:`wx.FileType` object or ``None`` if the MIME type is unknown. :meth:`~wx.MimeTypesManager.IsOfType` This function returns ``True`` if either the given `mimeType` is exactly the same as `wildcard` or if it has the same category and the subtype of `wildcard` is ''. :meth:`~wx.MimeTypesManager.Unassociate` Undo :meth:`~MimeTypesManager.Associate` . ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.MimeTypesManager(object) **Possible constructors**:: MimeTypesManager() This class allows the application to retrieve information about all known MIME types from a system-specific location and the filename extensions to the MIME types and vice versa. .. method:: __init__(self) Constructor puts the object in the "working" state. .. method:: AddFallbacks(self, fallbacks) This function may be used to provide hard-wired fallbacks for the MIME types and extensions that might not be present in the system MIME database. Please see the typetest sample for an example of using it. :param `fallbacks`: :type `fallbacks`: wx.FileTypeInfo .. method:: Associate(self, ftInfo) Create a new association using the fields of :ref:`wx.FileTypeInfo` (at least the MIME type and the extension should be set). :param `ftInfo`: :type `ftInfo`: wx.FileTypeInfo :rtype: :ref:`wx.FileType` .. method:: EnumAllFileTypes(self) Returns a list of all known file types. :rtype: `list of strings` .. method:: GetFileTypeFromExtension(self, extension) Gather information about the files with given extension and return the corresponding :ref:`wx.FileType` object or ``None`` if the extension is unknown. The `extension` parameter may have, or not, the leading dot, if it has it, it is stripped automatically. It must not however be empty. :param `extension`: :type `extension`: string :rtype: :ref:`wx.FileType` .. method:: GetFileTypeFromMimeType(self, mimeType) Gather information about the files with given MIME type and return the corresponding :ref:`wx.FileType` object or ``None`` if the MIME type is unknown. :param `mimeType`: :type `mimeType`: string :rtype: :ref:`wx.FileType` .. staticmethod:: IsOfType(mimeType, wildcard) This function returns ``True`` if either the given `mimeType` is exactly the same as `wildcard` or if it has the same category and the subtype of `wildcard` is ''. Note that the 'x' wildcard is not allowed in `mimeType` itself. The comparison done by this function is case insensitive so it is not necessary to convert the strings to the same case before calling it. :param `mimeType`: :type `mimeType`: string :param `wildcard`: :type `wildcard`: string :rtype: `bool` .. method:: Unassociate(self, ft) Undo :meth:`Associate` . :param `ft`: :type `ft`: wx.FileType :rtype: `bool`