Phoenix Logo

phoenix_title wx.richtext.SymbolPickerDialog

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 wx.richtext.SymbolPickerDialog.GetSymbol and test whether a font was specified with wx.richtext.SymbolPickerDialog.UseNormalFont ,fetching the specified font with 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

Inheritance diagram for class SymbolPickerDialog:

method_summary Methods Summary

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

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.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.



__init__ (self, symbol, initialFont, normalTextFont, parent, id=ID_ANY, title=_(“Symbols”), pos=DefaultPosition, size=DefaultSize, style=DEFAULT_DIALOG_STYLE|RESIZE_BORDER|CLOSE_BOX)

Constructor.

Parameters:
  • symbol (string) – The initial symbol to show. Specify a single character in a string, or an empty string.
  • initialFont (string) – The initial font to be displayed in the font list. If empty, the item normal text will be selected.
  • normalTextFont (string) – The font the dialog will use to display the symbols if the initial font is empty.
  • parent (wx.Window) – The dialog’s parent.
  • id (wx.WindowID) – The dialog’s identifier.
  • title (string) – The dialog’s caption.
  • pos (wx.Point) – The dialog’s position.
  • size (wx.Size) – The dialog’s size.
  • style (long) – The dialog’s window style.





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 the constructor for details about the parameters.

Parameters:
  • symbol (string) –
  • initialFont (string) –
  • normalTextFont (string) –
  • parent (wx.Window) –
  • id (wx.WindowID) –
  • caption (string) –
  • pos (wx.Point) –
  • size (wx.Size) –
  • style (long) –
Return type:

bool



GetFontName(self)

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

Return type:string


GetFromUnicode(self)

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

Return type:bool


GetNormalTextFontName(self)

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

Return type:string


GetSymbol(self)

Gets the current or initial symbol as a string.

Return type:string


GetSymbolChar(self)

Gets the selected symbol character as an integer.

Return type:int


HasSelection(self)

Returns True if a symbol is selected.

Return type:bool


SetFontName(self, value)

Sets the initial/selected font name.

Parameters:value (string) –


SetFromUnicode(self, value)

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

Parameters:value (bool) –


SetNormalTextFontName(self, value)

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

Parameters:value (string) –


SetSymbol(self, value)

Sets the symbol as a one or zero character string.

Parameters:value (string) –


SetUnicodeMode(self, unicodeMode)

Sets Unicode display mode.

Parameters:unicodeMode (bool) –


UseNormalFont(self)

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

Return type:bool

Properties



FontName

See GetFontName and SetFontName



FromUnicode

See GetFromUnicode and SetFromUnicode



NormalTextFontName

See GetNormalTextFontName and SetNormalTextFontName



Symbol

See GetSymbol and SetSymbol



SymbolChar

See GetSymbolChar