.. 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.richtext.RichTextFileHandler:

==========================================================================================================================================
|phoenix_title|  **wx.richtext.RichTextFileHandler**
==========================================================================================================================================

The base class for file handlers.          







         



.. seealso:: :ref:`wx.richtext.RichTextBuffer`, :ref:`wx.richtext.RichTextCtrl`    







|

|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>RichTextFileHandler</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.richtext.RichTextFileHandler_inheritance.png" alt="Inheritance diagram of RichTextFileHandler" 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.richtext.RichTextFileHandler.html" title="wx.richtext.RichTextFileHandler" alt="" coords="5,83,232,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="75,5,162,35"/> </map> 
   </p>
   </div>

|


|sub_classes| Known Subclasses
==============================

:ref:`wx.richtext.RichTextHTMLHandler`, :ref:`wx.richtext.RichTextPlainTextHandler`, :ref:`wx.richtext.RichTextXMLHandler`

|


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

================================================================================ ================================================================================
:meth:`~wx.richtext.RichTextFileHandler.__init__`                                Creates a file handler object.
:meth:`~wx.richtext.RichTextFileHandler.CanHandle`                               Returns ``True`` if we handle this filename (if using files).
:meth:`~wx.richtext.RichTextFileHandler.CanLoad`                                 Returns ``True`` if we can load using this handler.
:meth:`~wx.richtext.RichTextFileHandler.CanSave`                                 Returns ``True`` if we can save using this handler.
:meth:`~wx.richtext.RichTextFileHandler.DoLoadFile`                              Override to load content from `stream`  into `buffer`.
:meth:`~wx.richtext.RichTextFileHandler.DoSaveFile`                              Override to save content to `stream`  from `buffer`.
:meth:`~wx.richtext.RichTextFileHandler.GetEncoding`                             Returns the encoding to use when saving a file.
:meth:`~wx.richtext.RichTextFileHandler.GetExtension`                            Returns the default extension to recognise.
:meth:`~wx.richtext.RichTextFileHandler.GetFlags`                                Returns flags controlling how loading and saving is done.
:meth:`~wx.richtext.RichTextFileHandler.GetName`                                 Returns the name of the handler.
:meth:`~wx.richtext.RichTextFileHandler.GetType`                                 Returns the handler type.
:meth:`~wx.richtext.RichTextFileHandler.IsVisible`                               Returns ``True`` if this handler should be visible to the user.
:meth:`~wx.richtext.RichTextFileHandler.LoadFile`                                Loads the buffer from a stream.
:meth:`~wx.richtext.RichTextFileHandler.SaveFile`                                Saves the buffer to a stream.
:meth:`~wx.richtext.RichTextFileHandler.SetEncoding`                             Sets the encoding to use when saving a file.
:meth:`~wx.richtext.RichTextFileHandler.SetExtension`                            Sets the default extension to recognise.
:meth:`~wx.richtext.RichTextFileHandler.SetFlags`                                Sets flags that change the behaviour of loading or saving.
:meth:`~wx.richtext.RichTextFileHandler.SetName`                                 Sets the name of the handler.
:meth:`~wx.richtext.RichTextFileHandler.SetType`                                 Sets the handler type.
:meth:`~wx.richtext.RichTextFileHandler.SetVisible`                              Sets whether the handler should be visible to the user (via the application's load and save dialogs).
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.richtext.RichTextFileHandler.Encoding`                                See :meth:`~wx.richtext.RichTextFileHandler.GetEncoding` and :meth:`~wx.richtext.RichTextFileHandler.SetEncoding`
:attr:`~wx.richtext.RichTextFileHandler.Extension`                               See :meth:`~wx.richtext.RichTextFileHandler.GetExtension` and :meth:`~wx.richtext.RichTextFileHandler.SetExtension`
:attr:`~wx.richtext.RichTextFileHandler.Flags`                                   See :meth:`~wx.richtext.RichTextFileHandler.GetFlags` and :meth:`~wx.richtext.RichTextFileHandler.SetFlags`
:attr:`~wx.richtext.RichTextFileHandler.Name`                                    See :meth:`~wx.richtext.RichTextFileHandler.GetName` and :meth:`~wx.richtext.RichTextFileHandler.SetName`
:attr:`~wx.richtext.RichTextFileHandler.Type`                                    See :meth:`~wx.richtext.RichTextFileHandler.GetType` and :meth:`~wx.richtext.RichTextFileHandler.SetType`
================================================================================ ================================================================================


|


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


.. class:: wx.richtext.RichTextFileHandler(Object)

   **Possible constructors**::

       RichTextFileHandler(name="", ext="", type=0)
       
   
   The base class for file handlers.



   .. method:: __init__(self, name=EmptyString, ext=EmptyString, type=0)

      Creates a file handler object.                  


      :param `name`: 
      :type `name`: string
      :param `ext`: 
      :type `ext`: string
      :param `type`: 
      :type `type`: int







   .. method:: CanHandle(self, filename)

      Returns ``True`` if we handle this filename (if using files).                  

      By default, checks the extension.                  


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




      :rtype: `bool`








   .. method:: CanLoad(self)

      Returns ``True`` if we can load using this handler.                  

      :rtype: `bool`








   .. method:: CanSave(self)

      Returns ``True`` if we can save using this handler.                  

      :rtype: `bool`








   .. method:: DoLoadFile(self, buffer, stream)

      Override to load content from `stream`  into `buffer`.                  


      :param `buffer`: 
      :type `buffer`: wx.richtext.RichTextBuffer
      :param `stream`: 
      :type `stream`: wx.InputStream




      :rtype: `bool`








   .. method:: DoSaveFile(self, buffer, stream)

      Override to save content to `stream`  from `buffer`.                  


      :param `buffer`: 
      :type `buffer`: wx.richtext.RichTextBuffer
      :param `stream`: 
      :type `stream`: wx.OutputStream




      :rtype: `bool`








   .. method:: GetEncoding(self)

      Returns the encoding to use when saving a file.                  

      If empty, a suitable encoding is chosen.                  

      :rtype: `string`








   .. method:: GetExtension(self)

      Returns the default extension to recognise.                  

      :rtype: `string`








   .. method:: GetFlags(self)

      Returns flags controlling how loading and saving is done.                  

      :rtype: `int`








   .. method:: GetName(self)

      Returns the name of the handler.                  

      :rtype: `string`








   .. method:: GetType(self)

      Returns the handler type.                  

      :rtype: `int`








   .. method:: IsVisible(self)

      Returns ``True`` if this handler should be visible to the user.                  

      :rtype: `bool`








   .. method:: LoadFile(self, *args, **kw)



      |overload| Overloaded Implementations:

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

      
      **LoadFile** `(self, buffer, stream)`
      
      Loads the buffer from a stream.                  
      
      Not all handlers will implement file loading.                  
      
      
      :param `buffer`: 
      :type `buffer`: wx.richtext.RichTextBuffer
      :param `stream`: 
      :type `stream`: wx.InputStream
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **LoadFile** `(self, buffer, filename)`
      
      Loads the buffer from a file.                  
      
      
      :param `buffer`: 
      :type `buffer`: wx.richtext.RichTextBuffer
      :param `filename`: 
      :type `filename`: string
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SaveFile(self, *args, **kw)



      |overload| Overloaded Implementations:

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

      
      **SaveFile** `(self, buffer, stream)`
      
      Saves the buffer to a stream.                  
      
      Not all handlers will implement file saving.                  
      
      
      :param `buffer`: 
      :type `buffer`: wx.richtext.RichTextBuffer
      :param `stream`: 
      :type `stream`: wx.OutputStream
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SaveFile** `(self, buffer, filename)`
      
      Saves the buffer to a file.                  
      
      
      :param `buffer`: 
      :type `buffer`: wx.richtext.RichTextBuffer
      :param `filename`: 
      :type `filename`: string
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetEncoding(self, encoding)

      Sets the encoding to use when saving a file.                  

      If empty, a suitable encoding is chosen.                  


      :param `encoding`: 
      :type `encoding`: string







   .. method:: SetExtension(self, ext)

      Sets the default extension to recognise.                  


      :param `ext`: 
      :type `ext`: string







   .. method:: SetFlags(self, flags)

      Sets flags that change the behaviour of loading or saving.                  

      See the documentation for each handler class to see what flags are relevant for each handler. 

      You call this function directly if you are using a file handler explicitly (without going through the text control or buffer LoadFile/SaveFile API). Or, you can call the control or buffer's SetHandlerFlags function to set the flags that will be used for subsequent load and save operations.                  


      :param `flags`: 
      :type `flags`: int







   .. method:: SetName(self, name)

      Sets the name of the handler.                  


      :param `name`: 
      :type `name`: string







   .. method:: SetType(self, type)

      Sets the handler type.                  


      :param `type`: 
      :type `type`: int







   .. method:: SetVisible(self, visible)

      Sets whether the handler should be visible to the user (via the application's load and save dialogs).                  


      :param `visible`: 
      :type `visible`: bool







   .. attribute:: Encoding

      See :meth:`~wx.richtext.RichTextFileHandler.GetEncoding` and :meth:`~wx.richtext.RichTextFileHandler.SetEncoding`


   .. attribute:: Extension

      See :meth:`~wx.richtext.RichTextFileHandler.GetExtension` and :meth:`~wx.richtext.RichTextFileHandler.SetExtension`


   .. attribute:: Flags

      See :meth:`~wx.richtext.RichTextFileHandler.GetFlags` and :meth:`~wx.richtext.RichTextFileHandler.SetFlags`


   .. attribute:: Name

      See :meth:`~wx.richtext.RichTextFileHandler.GetName` and :meth:`~wx.richtext.RichTextFileHandler.SetName`


   .. attribute:: Type

      See :meth:`~wx.richtext.RichTextFileHandler.GetType` and :meth:`~wx.richtext.RichTextFileHandler.SetType`

