1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 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 :ref:`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 :ref:`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
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>MimeTypesManager</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.MimeTypesManager_inheritance.png" alt="Inheritance diagram of MimeTypesManager" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.MimeTypesManager.html" title="wx.MimeTypesManager" alt="" coords="5,5,173,35"/> </map>
</p>
|
|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 don 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`
|