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

==========================================================================================================================================
|phoenix_title|  **wx.richtext.SymbolPickerDialog**
==========================================================================================================================================

:ref:`wx.richtext.SymbolPickerDialog`  presents the user with a choice of fonts and a grid of available characters.          

This modal dialog provides the application with a selected symbol and optional font selection. 

Although this dialog is contained in the rich text library, the dialog is generic and can be used in other contexts. 

To use the dialog, pass a default symbol specified as a string, an initial font name, and a current font name. The difference between the initial font and current font is that the initial font determines what the font control will be set to when the dialog shows - an empty string will show the selection `normal`  text. The current font, on the other hand, is used by the dialog to determine what font to display the characters in, even when no initial font is selected. This allows the user (and application) to distinguish between inserting a symbol in the current font, and inserting it with a specified font. 

When the dialog is dismissed, the application can get the selected symbol with :meth:`wx.richtext.SymbolPickerDialog.GetSymbol`   and test whether a font was specified with :meth:`wx.richtext.SymbolPickerDialog.UseNormalFont` ,fetching the specified font with :meth:`wx.richtext.SymbolPickerDialog.GetFontName` . 

Here's a realistic example, inserting the supplied symbol into a rich text control in either the current font or specified font. 

::

    ctrl = self.FindWindow(ID_RICHTEXT_CTRL)

    attr = wx.TextAttr()
    attr.SetFlags(wx.TEXT_ATTR_FONT)
    ctrl.GetStyle(ctrl.GetInsertionPoint(), attr)

    currentFontName = ''
    if (attr.HasFont() and attr.GetFont().IsOk()):
        currentFontName = attr.GetFont().GetFaceName()

    # Don't set the initial font in the dialog (so the user is choosing
    # 'normal text', i.e. the current font) but do tell the dialog
    # what 'normal text' is.

    dlg = wx.richtext.SymbolPickerDialog("*", '', currentFontName, self)

    if dlg.ShowModal() == wx.ID_OK:

        if dlg.HasSelection():

            insertionPoint = ctrl.GetInsertionPoint()

            ctrl.WriteText(dlg.GetSymbol())

            if not dlg.UseNormalFont():

                font = attr.GetFont()
                font.SetFaceName(dlg.GetFontName())
                attr.SetFont(font)
                ctrl.SetStyle(insertionPoint, insertionPoint+1, attr)











|

|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>SymbolPickerDialog</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.SymbolPickerDialog_inheritance.png" alt="Inheritance diagram of SymbolPickerDialog" 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.SymbolPickerDialog.html" title="wx.richtext.SymbolPickerDialog" alt="" coords="5,469,236,499"/> <area shape="rect" id="node2" href="wx.Dialog.html" title="wx.Dialog" alt="" coords="77,392,164,421"/> <area shape="rect" id="node3" href="wx.TopLevelWindow.html" title="wx.TopLevelWindow" alt="" coords="43,315,198,344"/> <area shape="rect" id="node4" href="wx.NonOwnedWindow.html" title="wx.NonOwnedWindow" alt="" coords="37,237,205,267"/> <area shape="rect" id="node5" href="wx.Window.html" title="wx.Window" alt="" coords="72,160,169,189"/> <area shape="rect" id="node6" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="62,83,179,112"/> <area shape="rect" id="node7" href="wx.Object.html" title="wx.Object" alt="" coords="17,5,104,35"/> <area shape="rect" id="node8" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="129,5,235,35"/> </map> 
   </p>
   </div>

|


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

================================================================================ ================================================================================
:meth:`~wx.richtext.SymbolPickerDialog.__init__`                                 Default constructor.
:meth:`~wx.richtext.SymbolPickerDialog.Create`                                   Creation: see :ref:`the constructor <wx.richtext.SymbolPickerDialog>`  for details about the parameters.
:meth:`~wx.richtext.SymbolPickerDialog.GetClassDefaultAttributes`                
:meth:`~wx.richtext.SymbolPickerDialog.GetFontName`                              Returns the font name (the font reflected in the font list).
:meth:`~wx.richtext.SymbolPickerDialog.GetFromUnicode`                           Returns ``True`` if the dialog is showing the full range of Unicode characters.
:meth:`~wx.richtext.SymbolPickerDialog.GetNormalTextFontName`                    Gets the font name used for displaying symbols in the absence of a selected font.
:meth:`~wx.richtext.SymbolPickerDialog.GetSymbol`                                Gets the current or initial symbol as a string.
:meth:`~wx.richtext.SymbolPickerDialog.GetSymbolChar`                            Gets the selected symbol character as an integer.
:meth:`~wx.richtext.SymbolPickerDialog.HasSelection`                             Returns ``True`` if a symbol is selected.
:meth:`~wx.richtext.SymbolPickerDialog.SetFontName`                              Sets the initial/selected font name.
:meth:`~wx.richtext.SymbolPickerDialog.SetFromUnicode`                           Sets the internal flag indicating that the full Unicode range should be displayed.
:meth:`~wx.richtext.SymbolPickerDialog.SetNormalTextFontName`                    Sets the name of the font to be used in the absence of a selected font.
:meth:`~wx.richtext.SymbolPickerDialog.SetSymbol`                                Sets the symbol as a one or zero character string.
:meth:`~wx.richtext.SymbolPickerDialog.SetUnicodeMode`                           Sets Unicode display mode.
:meth:`~wx.richtext.SymbolPickerDialog.UseNormalFont`                            Returns ``True`` if the has specified normal text - that is, there is no selected font.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.richtext.SymbolPickerDialog.FontName`                                 See :meth:`~wx.richtext.SymbolPickerDialog.GetFontName` and :meth:`~wx.richtext.SymbolPickerDialog.SetFontName`
:attr:`~wx.richtext.SymbolPickerDialog.FromUnicode`                              See :meth:`~wx.richtext.SymbolPickerDialog.GetFromUnicode` and :meth:`~wx.richtext.SymbolPickerDialog.SetFromUnicode`
:attr:`~wx.richtext.SymbolPickerDialog.NormalTextFontName`                       See :meth:`~wx.richtext.SymbolPickerDialog.GetNormalTextFontName` and :meth:`~wx.richtext.SymbolPickerDialog.SetNormalTextFontName`
:attr:`~wx.richtext.SymbolPickerDialog.Symbol`                                   See :meth:`~wx.richtext.SymbolPickerDialog.GetSymbol` and :meth:`~wx.richtext.SymbolPickerDialog.SetSymbol`
:attr:`~wx.richtext.SymbolPickerDialog.SymbolChar`                               See :meth:`~wx.richtext.SymbolPickerDialog.GetSymbolChar`
================================================================================ ================================================================================


|


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


.. class:: wx.richtext.SymbolPickerDialog(Dialog)

   **Possible constructors**::

       SymbolPickerDialog()
       
       SymbolPickerDialog(symbol, initialFont, normalTextFont, parent,
                          id=ID_ANY, title=_("Symbols"), pos=DefaultPosition, size=DefaultSize,
                          style=DEFAULT_DIALOG_STYLE|RESIZE_BORDER|CLOSE_BOX)
       
   
   SymbolPickerDialog presents the user with a choice of fonts and a
   grid of available characters.



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



      |overload| Overloaded Implementations:

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

      
      **__init__** `(self)`
      
      Default constructor.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, symbol, initialFont, normalTextFont, parent, id=ID_ANY, title=_("Symbols"), pos=DefaultPosition, size=DefaultSize, style=DEFAULT_DIALOG_STYLE|RESIZE_BORDER|CLOSE_BOX)`
      
      Constructor.                  
      
      
      
      
      :param `symbol`: The initial symbol to show. Specify a single character in a string, or an empty string.   
      :type `symbol`: string
      :param `initialFont`: The initial font to be displayed in the font list. If empty, the item normal text will be selected.   
      :type `initialFont`: string
      :param `normalTextFont`: The font the dialog will use to display the symbols if the initial font is empty.   
      :type `normalTextFont`: string
      :param `parent`: The dialog's parent.   
      :type `parent`: wx.Window
      :param `id`: The dialog's identifier.   
      :type `id`: wx.WindowID
      :param `title`: The dialog's caption.   
      :type `title`: string
      :param `pos`: The dialog's position.   
      :type `pos`: wx.Point
      :param `size`: The dialog's size.   
      :type `size`: wx.Size
      :param `style`: The dialog's window style.   
      :type `style`: long
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Create(self, symbol, initialFont, normalTextFont, parent, id=ID_ANY, caption=GetTranslation("Symbols"), pos=DefaultPosition, size=Size(400,300), style=DEFAULT_DIALOG_STYLE|RESIZE_BORDER|CLOSE_BOX)

      Creation: see :ref:`the constructor <wx.richtext.SymbolPickerDialog>`  for details about the parameters.                  


      :param `symbol`: 
      :type `symbol`: string
      :param `initialFont`: 
      :type `initialFont`: string
      :param `normalTextFont`: 
      :type `normalTextFont`: string
      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `caption`: 
      :type `caption`: string
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long




      :rtype: `bool`








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




      :param `variant`: 
      :type `variant`: wx.WindowVariant




      :rtype: :ref:`VisualAttributes`








   .. method:: GetFontName(self)

      Returns the font name (the font reflected in the font list).                  

      :rtype: `string`








   .. method:: GetFromUnicode(self)

      Returns ``True`` if the dialog is showing the full range of Unicode characters.                  

      :rtype: `bool`








   .. method:: GetNormalTextFontName(self)

      Gets the font name used for displaying symbols in the absence of a selected font.                  

      :rtype: `string`








   .. method:: GetSymbol(self)

      Gets the current or initial symbol as a string.                  

      :rtype: `string`








   .. method:: GetSymbolChar(self)

      Gets the selected symbol character as an integer.                  

      :rtype: `int`








   .. method:: HasSelection(self)

      Returns ``True`` if a symbol is selected.                  

      :rtype: `bool`








   .. method:: SetFontName(self, value)

      Sets the initial/selected font name.                  


      :param `value`: 
      :type `value`: string







   .. method:: SetFromUnicode(self, value)

      Sets the internal flag indicating that the full Unicode range should be displayed.                  


      :param `value`: 
      :type `value`: bool







   .. method:: SetNormalTextFontName(self, value)

      Sets the name of the font to be used in the absence of a selected font.                  


      :param `value`: 
      :type `value`: string







   .. method:: SetSymbol(self, value)

      Sets the symbol as a one or zero character string.                  


      :param `value`: 
      :type `value`: string







   .. method:: SetUnicodeMode(self, unicodeMode)

      Sets Unicode display mode.                  


      :param `unicodeMode`: 
      :type `unicodeMode`: bool







   .. method:: UseNormalFont(self)

      Returns ``True`` if the has specified normal text - that is, there is no selected font.                  

      :rtype: `bool`








   .. attribute:: FontName

      See :meth:`~wx.richtext.SymbolPickerDialog.GetFontName` and :meth:`~wx.richtext.SymbolPickerDialog.SetFontName`


   .. attribute:: FromUnicode

      See :meth:`~wx.richtext.SymbolPickerDialog.GetFromUnicode` and :meth:`~wx.richtext.SymbolPickerDialog.SetFromUnicode`


   .. attribute:: NormalTextFontName

      See :meth:`~wx.richtext.SymbolPickerDialog.GetNormalTextFontName` and :meth:`~wx.richtext.SymbolPickerDialog.SetNormalTextFontName`


   .. attribute:: Symbol

      See :meth:`~wx.richtext.SymbolPickerDialog.GetSymbol` and :meth:`~wx.richtext.SymbolPickerDialog.SetSymbol`


   .. attribute:: SymbolChar

      See :meth:`~wx.richtext.SymbolPickerDialog.GetSymbolChar`

