.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2025 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 class="collabsible-wrapper">
      <input id="collapsible-inheritance" class="collapsible-checkbox" type="checkbox">
      <label for="collapsible-inheritance" tabindex="0" title="Show inheritance diagram" class="collapsible-label">Inheritance diagram for class <strong>RichTextFileHandler</strong>:</label>
      <div class="collapsible-content">
         <p class="graphviz">
            <center><img src="_static/images/inheritance/wx.richtext.RichTextFileHandler_inheritance.svg" alt="Inheritance diagram of RichTextFileHandler" usemap="#dummy" class="inheritance invert-in-dark-mode"/></center>
            <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.richtext.RichTextFileHandler.html" title="The base class for file handlers." alt="" coords="5,82,259,111"/> <area shape="rect" id="node2" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="83,5,182,34"/> </map> 
         </p>
      </div>
   </div>
   <script type="text/javascript" src="_static/inheritancetoggle.js"></script>



|


|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) -> None
       
   
   The base class for file handlers.



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

      Creates a file handler object. 
                 


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




      :rtype: `None`     








   .. 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: `str`








   .. method:: GetExtension(self)

      Returns the default extension to recognise. 
                 

      :rtype: `str`








   .. method:: GetFlags(self)

      Returns flags controlling how loading and saving is done. 
                 

      :rtype: `int`








   .. method:: GetName(self)

      Returns the name of the handler. 
                 

      :rtype: `str`








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




      :rtype: `None`     








   .. method:: SetExtension(self, ext)

      Sets the default extension to recognise. 
                 


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




      :rtype: `None`     








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




      :rtype: `None`     








   .. method:: SetName(self, name)

      Sets the name of the handler. 
                 


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




      :rtype: `None`     








   .. method:: SetType(self, type)

      Sets the handler type. 
                 


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




      :rtype: `None`     








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




      :rtype: `None`     








   .. 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`

