File: wx.richtext.SymbolPickerDialog.txt

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (452 lines) | stat: -rw-r--r-- 14,204 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
.. wxPython Phoenix documentation

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

   Copyright: (c) 2011-2018 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>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="7,5,108,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="59,83,169,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="132,5,213,35"/> <area shape="rect" id="node3" href="wx.Window.html" title="wx.Window" alt="" coords="70,160,159,189"/> <area shape="rect" id="node8" href="wx.NonOwnedWindow.html" title="wx.NonOwnedWindow" alt="" coords="35,237,193,267"/> <area shape="rect" id="node5" href="wx.richtext.SymbolPickerDialog.html" title="wx.richtext.SymbolPickerDialog" alt="" coords="5,469,224,499"/> <area shape="rect" id="node6" href="wx.Dialog.html" title="wx.Dialog" alt="" coords="73,392,155,421"/> <area shape="rect" id="node7" href="wx.TopLevelWindow.html" title="wx.TopLevelWindow" alt="" coords="43,315,185,344"/> </map> 
   </p>

|


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

      **~~~**

      
      **__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.                  
      
      
      
      
      :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
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
                        
      
      
      
      
      **~~~**






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








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