.. 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.MemoryFSHandler:

==========================================================================================================================================
|phoenix_title|  **wx.MemoryFSHandler**
==========================================================================================================================================

This :ref:`wx.FileSystem`  handler can store arbitrary data in memory stream and make them accessible via an URL. 
         

It is particularly suitable for storing bitmaps from resources or included XPM files so that they can be used with HTML or :ref:`wx.html2.WebView`. 

Filenames are prefixed with  ``"memory:"`` , e.g.   ``"memory:myfile.html"`` . 

Example: 

::

        def OnAbout(self, event):

            bcur = wx.BeginBusyCursor()

            wx.FileSystem.AddHandler(wx.MemoryFSHandler)
            wx.MemoryFSHandler.AddFile("logo.pcx", wx.Bitmap("logo.pcx", wx.BITMAP_TYPE_PCX))
            wx.MemoryFSHandler.AddFile("about.htm",
                                       "<html><body>About: "
                                       "<img src=\"memory:logo.pcx\"></body></html>")

            dlg = wx.Dialog(self, -1, _("About"))

            topsizer = wx.BoxSizer(wx.VERTICAL)

            html = wx.html.HtmlWindow(dlg, size=wx.Size(380, 160), style=wx.HW_SCROLLBAR_NEVER)
            html.SetBorders(0)
            html.LoadPage("memory:about.htm")
            html.SetSize(html.GetInternalRepresentation().GetWidth(),
                         html.GetInternalRepresentation().GetHeight())

            topsizer.Add(html, 1, wx.ALL, 10)
            topsizer.Add(wx.StaticLine(dlg, -1), 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10)
            topsizer.Add(wx.Button(dlg, wx.ID_OK, "Ok"),
                         0, wx.ALL | wx.ALIGN_RIGHT, 15)

            dlg.SetAutoLayout(True)
            dlg.SetSizer(topsizer)
            topsizer.Fit(dlg)
            dlg.Centre()
            dlg.ShowModal()

            wx.MemoryFSHandler.RemoveFile("logo.pcx")
            wx.MemoryFSHandler.RemoveFile("about.htm")










         



.. seealso:: :meth:`wx.MemoryFSHandler.AddFileWithMimeType`     







|

|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>MemoryFSHandler</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.MemoryFSHandler_inheritance.svg" alt="Inheritance diagram of MemoryFSHandler" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.MemoryFSHandler.html" title="This wx.FileSystem  handler can store arbitrary data in memory stream and make them accessible via an URL." alt="" coords="6,159,194,188"/> <area shape="rect" id="node2" href="wx.FileSystemHandler.html" title="Classes derived from wx.FileSystemHandler  are used to access virtual file systems." alt="" coords="5,82,195,111"/> <area shape="rect" id="node3" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="51,5,150,34"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.MemoryFSHandler.__init__`                                             Constructor.
:meth:`~wx.MemoryFSHandler.AddFile`                                              Adds a file to the list of the files stored in memory.
:meth:`~wx.MemoryFSHandler.AddFileWithMimeType`                                  Add a file from text data, which will first be converted to utf-8 encoded bytes.
:meth:`~wx.MemoryFSHandler.RemoveFile`                                           Removes a file from memory ``FS`` and frees the occupied memory.
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.MemoryFSHandler(FileSystemHandler)

   **Possible constructors**::

       MemoryFSHandler() -> None
       
   
   This FileSystem handler can store arbitrary data in memory stream
   and make them accessible via an URL.



   .. method:: __init__(self)

      Constructor. 
                 

      :rtype: `None`     








   .. staticmethod:: AddFile(*args, **kw)



      |overload| **Overloaded Implementations:**

      :html:`<hr class="overloadsep" /><br />`

      
      **AddFile** `(filename, image, type)`
      
      Adds a file to the list of the files stored in memory. 
                       
      
      Stored data (bitmap, text or raw data) will be copied into private memory stream and available under name  ``"memory:"``   +  `filename`. 
      
      When using the overload taking  `String`       data, if the string contains only Latin-1 characters (which includes strings created using  :meth:`String.From8BitData` ), its data is used as is. Otherwise, the ``UTF-8`` representation of the string is stored as the data associated with the given `filename`. 
      
      
                      
      
      
      :param `filename`: 
      :type `filename`: string
      :param `image`: 
      :type `image`: wx.Image
      :param `type`: 
      :type `type`: wx.BitmapType
      
      
      
      
      :rtype: `None`     
      
      
      
      
      
      
      
      .. note:: 
      
         you must use a `type`  value (aka image format) that wxWidgets can save (e.g. ``JPG``, ``PNG``, see :ref:`wx.Image`  documentation)!  
      
      
      
      
      
      
      
      .. seealso:: :meth:`AddFileWithMimeType`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **AddFile** `(filename, bitmap, type)`
      
      Adds a file to the list of the files stored in memory. 
                       
      
      Stored data (bitmap, text or raw data) will be copied into private memory stream and available under name  ``"memory:"``   +  `filename`. 
      
      When using the overload taking  `String`       data, if the string contains only Latin-1 characters (which includes strings created using  :meth:`String.From8BitData` ), its data is used as is. Otherwise, the ``UTF-8`` representation of the string is stored as the data associated with the given `filename`. 
      
      
                      
      
      
      :param `filename`: 
      :type `filename`: string
      :param `bitmap`: 
      :type `bitmap`: wx.Bitmap
      :param `type`: 
      :type `type`: wx.BitmapType
      
      
      
      
      :rtype: `None`     
      
      
      
      
      
      
      
      .. note:: 
      
         you must use a `type`  value (aka image format) that wxWidgets can save (e.g. ``JPG``, ``PNG``, see :ref:`wx.Image`  documentation)!  
      
      
      
      
      
      
      
      .. seealso:: :meth:`AddFileWithMimeType`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **AddFile** `(filename, textdata)`
      
      Add a file from text data, which will first be converted to utf-8 encoded bytes. 
      
      :rtype: `None`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **AddFile** `(filename, binarydata)`
      
      Add a file from raw data in a python buffer compatible object. 
      
      :rtype: `None`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. staticmethod:: AddFileWithMimeType(*args, **kw)



      |overload| **Overloaded Implementations:**

      :html:`<hr class="overloadsep" /><br />`

      
      **AddFileWithMimeType** `(filename, textdata, mimetype)`
      
      Add a file from text data, which will first be converted to utf-8 encoded bytes. 
      
      :rtype: `None`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **AddFileWithMimeType** `(filename, binarydata, mimetype)`
      
      Add a file from raw data in a python buffer compatible object. 
      
      :rtype: `None`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. staticmethod:: RemoveFile(filename)

      Removes a file from memory ``FS`` and frees the occupied memory. 
                 


      :param `filename`: 
      :type `filename`: string




      :rtype: `None`     







