*********** wx.FileType *********** Inheritance diagram for `wx.FileType`: | .. inheritance-diagram:: wx.FileType | Description =========== This class holds information about a given *file type*. File type is the same as MIME type under Unix, but under Windows it corresponds more to an extension than to MIME type (in fact, several extensions may correspond to a file type). This object may be created in several different ways: the program might know the file extension and wish to find out the corresponding MIME type or, conversely, it might want to find the right extension for the file to which it writes the contents of given MIME type. Depending on how it was created some fields may be unknown so the return value of all the accessors **must** be checked: ``False`` will be returned if the corresponding information couldn't be found. The objects of this class are never created by the application code but are returned by `wx.MimeTypesManager.GetFileTypeFromMimeType `_ and `wx.MimeTypesManager.GetFileTypeFromExtension `_ methods. But it is your responsibility to delete the returned pointer when you're done with it! A brief reminder about what the MIME types are (see the RFC 1341 for more information): basically, it is just a pair category/type (for example, "text/plain") where the category is a basic indication of what a file is. Examples of categories are "application", "image", "text", "binary", and type is a precise definition of the document format: "plain" in the example above means just ASCII text without any formatting, while "text/html" is the HTML document source. A MIME type may have one or more associated extensions: "text/plain" will typically correspond to the extension ".txt", but may as well be associated with ".ini" or ".conf". .. seealso:: `wx.MimeTypesManager `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `ExpandCommand <#ExpandCommand>`_ * `GetAllCommands <#GetAllCommands>`_ * `GetDescription <#GetDescription>`_ * `GetExtensions <#GetExtensions>`_ * `GetIcon <#GetIcon>`_ * `GetIconInfo <#GetIconInfo>`_ * `GetMimeType <#GetMimeType>`_ * `GetMimeTypes <#GetMimeTypes>`_ * `GetOpenCommand <#GetOpenCommand>`_ * `GetPrintCommand <#GetPrintCommand>`_ * `SetCommand <#SetCommand>`_ * `SetDefaultIcon <#SetDefaultIcon>`_ * `Unassociate <#Unassociate>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `AllCommands <#AllCommands>`_ * `Description <#Description>`_ * `Extensions <#Extensions>`_ * `Icon <#Icon>`_ * `IconInfo <#IconInfo>`_ * `MimeType <#MimeType>`_ * `MimeTypes <#MimeTypes>`_ * `OpenCommand <#OpenCommand>`_ * `PrintCommand <#PrintCommand>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(ftInfo) Constructor. **Parameters:** * `ftInfo` (`wx.FileTypeInfo`) | **Returns:** `wx.FileType `_ -------- .. method:: ExpandCommand(command, filename, mimetype="") This function is primarily intended for `GetOpenCommand <#GetOpenCommand>`_ and `GetPrintCommand <#GetPrintCommand>`_ usage but may be also used by the application directly if, for example, you want to use some non-default command to open the file. The function replaces all occurrences of: ========================== =================== Format Specification With ========================== =================== %s the full file name %t the MIME type %{param} the value of the parameter `param` ========================== =================== If there is no "%s" in the command string (and the string is not empty), it is assumed that the command reads the data on stdin and so the effect is the same as "%s" were appended to the string. Unlike all other functions of this class, there is no error return for this function. **Parameters:** * `command` (string) * `filename` (string) * `mimetype` (string) | **Returns:** `string` -------- .. method:: GetAllCommands(filename, mimetype="") | **Parameters:** * `filename` (string) * `mimetype` (string) | **Returns:** `PyObject` -------- .. method:: GetDescription() Returns a string filled with a brief description for this file type: for example, "text document" for the "text/plain" MIME type. | **Returns:** `PyObject` -------- .. method:: GetExtensions() Returns an array filled with all extensions associated with this file type: for example, it may contain the following two elements for the MIME type "text/html" (notice the absence of the leading dot): "html" and "htm". | **Returns:** `list of strings` .. note:: On Windows, this function is currently not implemented: there is no (efficient) way to retrieve associated extensions from the given MIME type on this platform, so it will only return ``True`` if the `wx.FileType` object was created by `GetFileTypeFromExtension <#GetFileTypeFromExtension>`_ function in the first place. -------- .. method:: GetIcon() Returns the location of the icon for this MIME type. A `wx.Icon `_ may be created from this icon later. | **Returns:** `wx.Icon `_ .. note:: **Windows:** The function returns the icon shown by Explorer for the files of the specified type. **Mac:** This function is not implemented and always returns ``False``. **Unix:** MIME manager gathers information about icons from GNOME and KDE settings and thus `GetIcon` success depends on availability of these desktop environments. -------- .. method:: GetIconInfo() `No docstrings available for this method.` -------- .. method:: GetMimeType() Returns a string filled with full MIME type specification for this file type: for example, "text/plain". | **Returns:** `string` -------- .. method:: GetMimeTypes() Same as `GetMimeType <#GetMimeType>`_ but returns array of MIME types. This array will contain only one item in most cases but sometimes, notably under Unix with KDE, may contain more MIME types. This happens when one file extension is mapped to different MIME types by KDE, mailcap and mime.types. | **Returns:** `list of strings` -------- .. method:: GetOpenCommand(filename, mimetype="") If ``True`` is returned, the string pointed to by `filename` is filled with the command which must be executed (see `wx.Execute `_) in order to open the file of the given type. **Parameters:** * `filename` (string) * `mimetype` (string) | **Returns:** `PyObject` .. seealso:: `wx.Execute `_ -------- .. method:: GetPrintCommand(filename, mimetype="") If the function returns ``True``, the string pointed to by `filename` is filled with the command which must be executed (see `wx.Execute `_) in order to print the file of the given type. **Parameters:** * `filename` (string) * `mimetype` (string) | **Returns:** `PyObject` .. seealso:: `wx.Execute `_ -------- .. method:: SetCommand(cmd, verb, overwriteprompt=True) | **Parameters:** * `cmd` (string) * `verb` (string) * `overwriteprompt` (bool) | **Returns:** `bool` -------- .. method:: SetDefaultIcon(cmd="", index=0) | **Parameters:** * `cmd` (string) * `index` (int) **Returns:** `bool` -------- .. method:: Unassociate() `No docstrings available for this method.` -------- Properties ^^^^^^^^^^ .. attribute:: AllCommands See `GetAllCommands <#GetAllCommands>`_ .. attribute:: Description See `GetDescription <#GetDescription>`_ .. attribute:: Extensions See `GetExtensions <#GetExtensions>`_ .. attribute:: Icon See `GetIcon <#GetIcon>`_ .. attribute:: IconInfo See `GetIconInfo <#GetIconInfo>`_ .. attribute:: MimeType See `GetMimeType <#GetMimeType>`_ .. attribute:: MimeTypes See `GetMimeTypes <#GetMimeTypes>`_ .. attribute:: OpenCommand See `GetOpenCommand <#GetOpenCommand>`_ .. attribute:: PrintCommand See `GetPrintCommand <#GetPrintCommand>`_