File: wx.TextCtrl.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 (1122 lines) | stat: -rw-r--r-- 31,140 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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
.. 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.TextCtrl:

==========================================================================================================================================
|phoenix_title|  **wx.TextCtrl**
==========================================================================================================================================

A text control allows text to be displayed and edited.          

It may be single line or multi-line. Notice that a lot of methods of the text controls are found in the base :ref:`wx.TextEntry`  class which is a common base class for :ref:`wx.TextCtrl`  and other controls using a single line text entry field (e.g. :ref:`wx.ComboBox`). 





.. _TextCtrl-styles:

|styles| Window Styles
================================

This class supports the following styles: 

  

- ``wx.TE_PROCESS_ENTER``: The control will generate the event  ``wxEVT_TEXT_ENTER``   (otherwise pressing Enter key is either processed internally by the control or used for navigation between dialog controls).   
- ``wx.TE_PROCESS_TAB``: The control will receive  ``wxEVT_CHAR``   events for ``TAB`` pressed - normally, ``TAB`` is used for passing to the next control in a dialog instead. For the control created with this style, you can still use Ctrl-Enter to pass to the next control from the keyboard.   
- ``wx.TE_MULTILINE``: The text control allows multiple lines. If this style is not specified, line break characters should not be used in the controls value.  
- ``wx.TE_PASSWORD``: The text will be echoed as asterisks.  
- ``wx.TE_READONLY``: The text will not be user-editable.  
- ``wx.TE_RICH``: Use rich text control under Win32, this allows to have more than ``64KB`` of text in the control even under Win9x. This style is ignored under other platforms.  
- ``wx.TE_RICH2``: Use rich text control version 2.0 or 3.0 under Win32, this style is ignored under other platforms  
- ``wx.TE_AUTO_URL``: Highlight the URLs and generate the TextUrlEvents when mouse events occur over them. This style is only supported for ``wx.TE_RICH`` Win32 and multi-line wxGTK2 text controls.  
- ``wx.TE_NOHIDESEL``: By default, the Windows text control doesn't show the selection when it doesn't have focus - use this style to force it to always show it. It doesn't do anything under other platforms.  
- ``wx.HSCROLL``: A horizontal scrollbar will be created and used, so that text won't be wrapped. No effect under ``GTK1``.  
- ``wx.TE_NO_VSCROLL``: For multiline controls only: vertical scrollbar will never be created. This limits the amount of text which can be entered into the control to what can be displayed in it under MSW but not under GTK2. Currently not implemented for the other platforms.  
- ``wx.TE_LEFT``: The text in the control will be left-justified (default).  
- ``wx.TE_CENTRE``: The text in the control will be centered (currently wxMSW and wxGTK2 only).  
- ``wx.TE_RIGHT``: The text in the control will be right-justified (currently wxMSW and wxGTK2 only).  
- ``wx.TE_DONTWRAP``: Same as ``wx.HSCROLL`` style: don't wrap at all, show horizontal scrollbar instead.  
- ``wx.TE_CHARWRAP``: Wrap the lines too long to be shown entirely at any position (wxUniv and wxGTK2 only).  
- ``wx.TE_WORDWRAP``: Wrap the lines too long to be shown entirely at word boundaries (wxUniv and wxGTK2 only).  
- ``wx.TE_BESTWRAP``: Wrap the lines at word boundaries or at any other character if there are words longer than the window width (this is the default).  
- ``TE_CAPITALIZE``: On PocketPC and Smartphone, causes the first letter to be capitalized.  

Note that alignment styles (wx``wx.TE_LEFT``, ``wx.TE_CENTRE`` and ``wx.TE_RIGHT``) can be changed dynamically after control creation on wxMSW and wxGTK. ``wx.TE_READONLY``, ``wx.TE_PASSWORD`` and wrapping styles can be dynamically changed under wxGTK but not wxMSW. The other styles can be only set during control creation.




|phoenix_title| TextCtrl Text Format
====================================

The multiline text controls always store the text as a sequence of lines separated by  ``'\n'``   characters, i.e. in the Unix text format even on non-Unix platforms. This allows the user code to ignore the differences between the platforms but at a price: the indices in the control such as those returned by  :meth:`~wx.TextCtrl.GetInsertionPoint`  or :meth:`~wx.TextCtrl.GetSelection`  can **not**  be used as indices into the string returned by :meth:`~wx.TextCtrl.GetValue`  as they're going to be slightly off for platforms using  ``"\\r\\n"``   as separator (as Windows does). Instead, if you need to obtain a substring between the 2 indices obtained from the control with the help of the functions mentioned above, you should use :meth:`~wx.TextCtrl.GetRange`. And the indices themselves can only be passed to other methods, for example :meth:`~wx.TextCtrl.SetInsertionPoint`  or :meth:`~wx.TextCtrl.SetSelection`. To summarize: never use the indices returned by (multiline) :ref:`wx.TextCtrl`  as indices into the string it contains, but only as arguments to be passed back to the other :ref:`wx.TextCtrl`  methods. This problem doesn't arise for single-line platforms however where the indices in the control do correspond to the positions in the value string.  



|phoenix_title| TextCtrl Styles
================================

Multi-line text controls support styling, i.e. provide a possibility to set colours and font for individual characters in it (note that under Windows  ``TE_RICH``   style is required for style support). To use the styles you can either call  :meth:`~wx.TextCtrl.SetDefaultStyle`  before inserting the text or call :meth:`~wx.TextCtrl.SetStyle`  later to change the style of the text already in the control (the first solution is much more efficient). In either case, if the style doesn't specify some of the attributes (for example you only want to set the text colour but without changing the font nor the text background), the values of the default style will be used for them. If there is no default style, the attributes of the text control itself are used. So the following code correctly describes what it does: the second call to :meth:`~wx.TextCtrl.SetDefaultStyle`  doesn't change the text foreground colour (which stays red) while the last one doesn't change the background colour (which stays grey): ::

        text.SetDefaultStyle(wx.TextAttr(wx.RED))
        text.AppendText("Red text\n")
        text.SetDefaultStyle(wx.TextAttr(wx.NullColour, wx.LIGHT_GREY))
        text.AppendText("Red on grey text\n")
        text.SetDefaultStyle(wx.TextAttr(wx.BLUE))
        text.AppendText("Blue on grey text\n")





|phoenix_title| TextCtrl and C++ Streams
========================================

This class multiply-inherits from  ``std::streambuf``   (except for some really old compilers using non-standard iostream library), allowing code such as the following: ::

# C++-style stream support is not implemented for Python.

Note that even if your compiler doesn't support this (the symbol  ``HAS_TEXT_WINDOW_STREAM``   has value of 0 then) you can still use  :ref:`wx.TextCtrl`  itself in a stream-like manner: ::

# C++-style stream support is not implemented for Python.

However the possibility to create a  ``std::ostream``   associated with  :ref:`wx.TextCtrl`  may be useful if you need to redirect the output of a function taking a  ``std::ostream``   as parameter to a text control. Another commonly requested need is to redirect  ``std::cout``   to the text control. This may be done in the following way: ::

# C++-style stream support is not implemented for Python.

But wxWidgets provides a convenient class to make it even simpler so instead you may just do ::

# C++-style stream support is not implemented for Python.

See :ref:`StreamToTextRedirector`  for more details.  



|phoenix_title| Event Handling
===============================

The following commands are processed by default event handlers in :ref:`wx.TextCtrl`:  ``ID_CUT`` ,   ``ID_COPY`` ,   ``ID_PASTE`` ,   ``ID_UNDO`` ,   ``ID_REDO`` . The associated UI update events are also processed automatically, when the control has the focus. 



.. _TextCtrl-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive one of the :ref:`wx.CommandEvent` parameters.

- EVT_TEXT: Respond to a  ``wxEVT_TEXT``   event, generated when the text changes. Notice that this event will be sent when the text controls contents changes  :meth:`wx.TextCtrl.SetValue`   is called); see :meth:`wx.TextCtrl.ChangeValue`   for a function which does not send this event. This event is however not sent during the control creation.  
- EVT_TEXT_ENTER: Respond to a  ``wxEVT_TEXT_ENTER``   event, generated when enter is pressed in a text control which must have ``wx.TE_PROCESS_ENTER`` style for this event to be generated.   
- EVT_TEXT_URL: A mouse event occurred over an URL in the text control (wxMSW and wxGTK2 only currently).  
- EVT_TEXT_MAXLEN: This event is generated when the user tries to enter more text into the control than the limit set by :meth:`wx.TextCtrl.SetMaxLength` , see its description.  






.. seealso:: :meth:`wx.TextCtrl.Create` , :ref:`wx.Validator`    







|

|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>TextCtrl</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.TextCtrl_inheritance.png" alt="Inheritance diagram of TextCtrl" 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.Control.html" title="wx.Control" alt="" coords="129,237,217,267"/> <area shape="rect" id="node5" href="wx.TextCtrl.html" title="wx.TextCtrl" alt="" coords="69,315,157,344"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="129,160,217,189"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="75,5,156,35"/> <area shape="rect" id="node7" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="117,83,228,112"/> <area shape="rect" id="node4" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="181,5,283,35"/> <area shape="rect" id="node6" href="wx.TextEntry.html" title="wx.TextEntry" alt="" coords="5,237,104,267"/> </map> 
   </p>

|


|appearance| Control Appearance
===============================

|

.. figure:: _static/images/widgets/fullsize/wxmsw/wx.textctrl.png
   :alt: wxMSW
   :figclass: floatleft

   **wxMSW**


.. figure:: _static/images/widgets/fullsize/wxmac/wx.textctrl.png
   :alt: wxMAC
   :figclass: floatright

   **wxMAC**


.. figure:: _static/images/widgets/fullsize/wxgtk/wx.textctrl.png
   :alt: wxGTK
   :figclass: floatcenter

   **wxGTK**


|


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

:ref:`wx.SearchCtrl`

|


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

================================================================================ ================================================================================
:meth:`~wx.TextCtrl.__init__`                                                    Default constructor.
:meth:`~wx.TextCtrl.Create`                                                      Creates the text control for two-step construction.
:meth:`~wx.TextCtrl.DiscardEdits`                                                Resets the internal modified flag as if the current changes had been saved.
:meth:`~wx.TextCtrl.EmulateKeyPress`                                             This function inserts into the control the character which would have been inserted if the given key event had occurred in the text control.
:meth:`~wx.TextCtrl.GetDefaultStyle`                                             Returns the style currently used for the new text.
:meth:`~wx.TextCtrl.GetLineLength`                                               Gets the length of the specified line, not including any trailing newline character(s).
:meth:`~wx.TextCtrl.GetLineText`                                                 Returns the contents of a given line in the text control, not including any trailing newline character(s).
:meth:`~wx.TextCtrl.GetNumberOfLines`                                            Returns the number of lines in the text control buffer.
:meth:`~wx.TextCtrl.GetStyle`                                                    Returns the style at this position in the text control.
:meth:`~wx.TextCtrl.HideNativeCaret`                                             Turn off the widget's native caret on Windows.
:meth:`~wx.TextCtrl.HitTestPos`                                                  Finds the position of the character at the specified point.
:meth:`~wx.TextCtrl.HitTest`                                                     Finds the row and column of the character at the specified point.
:meth:`~wx.TextCtrl.IsModified`                                                  Returns ``True`` if the text has been modified by user.
:meth:`~wx.TextCtrl.IsMultiLine`                                                 Returns ``True`` if this is a multi line edit control and ``False`` otherwise.
:meth:`~wx.TextCtrl.IsSingleLine`                                                Returns ``True`` if this is a single line edit control and ``False`` otherwise.
:meth:`~wx.TextCtrl.LoadFile`                                                    Loads and displays the named file, if it exists.
:meth:`~wx.TextCtrl.MacCheckSpelling`                                            Turn on the native spell checking for the text widget on
:meth:`~wx.TextCtrl.MarkDirty`                                                   Mark text as modified (dirty).
:meth:`~wx.TextCtrl.PositionToCoords`                                            Converts given text position to client coordinates in pixels.
:meth:`~wx.TextCtrl.PositionToXY`                                                Converts given position to a zero-based column, line number pair.
:meth:`~wx.TextCtrl.SaveFile`                                                    Saves the contents of the control in a text file.
:meth:`~wx.TextCtrl.SetDefaultStyle`                                             Changes the default style to use for the new text which is going to be added to the control using :meth:`~TextCtrl.WriteText`   or :meth:`~TextCtrl.AppendText` .
:meth:`~wx.TextCtrl.SetModified`                                                 Marks the control as being modified by the user or not.
:meth:`~wx.TextCtrl.SetStyle`                                                    Changes the style of the given range.
:meth:`~wx.TextCtrl.ShowNativeCaret`                                             Turn on the widget's native caret on Windows.
:meth:`~wx.TextCtrl.ShowPosition`                                                Makes the line containing the given position visible.
:meth:`~wx.TextCtrl.XYToPosition`                                                Converts the given zero based column and line number to a position.
:meth:`~wx.TextCtrl.flush`                                                       ``NOP``, for file-like compatibility.
:meth:`~wx.TextCtrl.write`                                                       Append text to the textctrl, for file-like compatibility.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.TextCtrl.DefaultStyle`                                                See :meth:`~wx.TextCtrl.GetDefaultStyle` and :meth:`~wx.TextCtrl.SetDefaultStyle`
:attr:`~wx.TextCtrl.NumberOfLines`                                               See :meth:`~wx.TextCtrl.GetNumberOfLines`
================================================================================ ================================================================================


|


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


.. class:: wx.TextCtrl(Control, TextEntry)

   **Possible constructors**::

       TextCtrl()
       
       TextCtrl(parent, id=ID_ANY, value=EmptyString, pos=DefaultPosition,
                size=DefaultSize, style=0, validator=DefaultValidator,
                name=TextCtrlNameStr)
       
   
   A text control allows text to be displayed and edited.



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



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self)`
      
      Default constructor.                   
      
      
      
      
      **~~~**

      
      **__init__** `(self, parent, id=ID_ANY, value=EmptyString, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=TextCtrlNameStr)`
      
      Constructor, creating and showing a text control.                  
      
      
      
      
      :param `parent`: Parent window. Should not be ``None``.   
      :type `parent`: wx.Window
      :param `id`: Control identifier. A value of -1 denotes a default value.   
      :type `id`: wx.WindowID
      :param `value`: Default text value.   
      :type `value`: string
      :param `pos`: Text control position.   
      :type `pos`: wx.Point
      :param `size`: Text control size.   
      :type `size`: wx.Size
      :param `style`: Window style. See :ref:`wx.TextCtrl`.   
      :type `style`: long
      :param `validator`: Window validator.   
      :type `validator`: wx.Validator
      :param `name`: Window name.  
      :type `name`: string
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
                        
      
      
      
      .. note:: 
      
         The horizontal scrollbar (wx``wx.HSCROLL`` style flag) will only be created for multi-line text controls. Without a horizontal scrollbar, text lines that don't fit in the control's size will be wrapped (but no newline character is inserted). Single line controls don't have a horizontal scrollbar, the text is automatically scrolled so that the insertion point is always visible.  
      
      
      
      
      
      
      
      .. seealso:: :meth:`Create` , :ref:`wx.Validator`    
      
      
      
      
      
      
      
      **~~~**






   .. method:: Create(self, parent, id=ID_ANY, value=EmptyString, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=TextCtrlNameStr)

      Creates the text control for two-step construction.                  

      This method should be called if the default constructor was used for the control creation. Its parameters have the same meaning as for the non-default constructor.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `value`: 
      :type `value`: string
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long
      :param `validator`: 
      :type `validator`: wx.Validator
      :param `name`: 
      :type `name`: string




      :rtype: `bool`








   .. method:: DiscardEdits(self)

      Resets the internal modified flag as if the current changes had been saved.                   





   .. method:: EmulateKeyPress(self, event)

      This function inserts into the control the character which would have been inserted if the given key event had occurred in the text control.                  

      The `event`  object should be the same as the one passed to  ``EVT_KEY_DOWN``   handler previously by wxWidgets. Please note that this function doesn't currently work correctly for all keys under any platform but MSW. 

                


      :param `event`: 
      :type `event`: wx.KeyEvent




      :rtype: `bool`







      :returns: 

         ``True`` if the event resulted in a change to the control, ``False`` otherwise.   








   .. method:: GetDefaultStyle(self)

      Returns the style currently used for the new text.                  

                

      :rtype: :ref:`wx.TextAttr`







      .. seealso:: :meth:`SetDefaultStyle`     








   .. method:: GetLineLength(self, lineNo)

      Gets the length of the specified line, not including any trailing newline character(s).                  




      :param `lineNo`: Line number (starting from zero).  
      :type `lineNo`: long






      :rtype: `int`



                  



      :returns: 

         The length of the line, or -1 if `lineNo`  was invalid.   








   .. method:: GetLineText(self, lineNo)

      Returns the contents of a given line in the text control, not including any trailing newline character(s).                  




      :param `lineNo`: The line number, starting from zero.  
      :type `lineNo`: long






      :rtype: `string`



                  



      :returns: 

         The contents of the line.   








   .. method:: GetNumberOfLines(self)

      Returns the number of lines in the text control buffer.                  

      The returned number is the number of logical lines, i.e. just the count of the number of newline characters in the control + 1, for wxGTK and OSX/Cocoa ports while it is the number of physical lines, i.e. the count of lines actually shown in the control, in wxMSW and OSX/Carbon. Because of this discrepancy, it is not recommended to use this function. 

                

      :rtype: `int`







      .. note:: 

         Note that even empty text controls have one line (where the insertion point is), so :meth:`GetNumberOfLines`   never returns 0.   








   .. method:: GetStyle(self, position, style)

      Returns the style at this position in the text control.                  

      Not all platforms support this function. 

                


      :param `position`: 
      :type `position`: long
      :param `style`: 
      :type `style`: wx.TextAttr




      :rtype: `bool`







      :returns: 

         ``True`` on success, ``False`` if an error occurred (this may also mean that the styles are not supported under this platform).  







      .. seealso:: :meth:`SetStyle` , :ref:`wx.TextAttr`    








   .. method:: HideNativeCaret(self)

                              Turn off the widget's native caret on Windows.
                              Ignored on other platforms.
                         

      :rtype: `bool`








   .. method:: HitTestPos(self, pt)

      Finds the position of the character at the specified point.                  

      If the return code is not  ``TE_HT_UNKNOWN``   the row and column of the character closest to this position are returned, otherwise the output parameters are not modified. 

      Please note that this function is currently only implemented in Univ, wxMSW and wxGTK ports and always returns  ``TE_HT_UNKNOWN``   in the other ports. 

      




   .. method:: HitTest(self, pt)

      Finds the row and column of the character at the specified point.                  

      If the return code is not  ``TE_HT_UNKNOWN``   the row and column of the character closest to this position are returned, otherwise the output parameters are not modified. 

      Please note that this function is currently only implemented in Univ, wxMSW and wxGTK ports and always returns  ``TE_HT_UNKNOWN``   in the other ports. 

      




   .. method:: IsModified(self)

      Returns ``True`` if the text has been modified by user.                  

      Note that calling :meth:`SetValue`   doesn't make the control modified. 

                

      :rtype: `bool`







      .. seealso:: :meth:`MarkDirty`     








   .. method:: IsMultiLine(self)

      Returns ``True`` if this is a multi line edit control and ``False`` otherwise.                  

                

      :rtype: `bool`







      .. seealso:: :meth:`IsSingleLine`     








   .. method:: IsSingleLine(self)

      Returns ``True`` if this is a single line edit control and ``False`` otherwise.                  

                

      :rtype: `bool`







      .. seealso:: :meth:`IsSingleLine` , :meth:`IsMultiLine`     








   .. method:: LoadFile(self, filename, fileType=TEXT_TYPE_ANY)

      Loads and displays the named file, if it exists.                  




      :param `filename`: The filename of the file to load.   
      :type `filename`: string
      :param `fileType`: The type of file to load. This is currently ignored in :ref:`wx.TextCtrl`.  
      :type `fileType`: int








      :rtype: `bool`



                  



      :returns: 

         ``True`` if successful, ``False`` otherwise.   








   .. method:: MacCheckSpelling(self, check)

                              Turn on the native spell checking for the text widget on
                              OSX.  Ignored on other platforms.
                          





   .. method:: MarkDirty(self)

      Mark text as modified (dirty).                  

                 



      .. seealso:: :meth:`IsModified`     








   .. method:: PositionToCoords(self, pos)

      Converts given text position to client coordinates in pixels.                  

      This function allows to find where is the character at the given position displayed in the text control. 






      :param `pos`: Text position in 0 to :meth:`GetLastPosition`   range (inclusive).   
      :type `pos`: long






      :rtype: :ref:`wx.Point`



                  



      :returns: 

         On success returns a :ref:`wx.Point`  which contains client coordinates for the given position in pixels, otherwise returns :ref:`wx.DefaultPosition`.  







      .. versionadded:: 2.9.3 
    







      .. availability:: Only available for MSW, GTK . Additionally, wxGTK only implements this method for multiline controls and :ref:`wx.DefaultPosition`  is always returned for the single line ones. 







      .. seealso:: :meth:`XYToPosition` , :meth:`PositionToXY`     








   .. method:: PositionToXY(self, pos)

      Converts given position to a zero-based column, line number pair.                  




      :param `pos`: Position.   
      :type `pos`: long










      :rtype: `tuple`



      




   .. method:: SaveFile(self, filename=EmptyString, fileType=TEXT_TYPE_ANY)

      Saves the contents of the control in a text file.                  




      :param `filename`: The name of the file in which to save the text.   
      :type `filename`: string
      :param `fileType`: The type of file to save. This is currently ignored in :ref:`wx.TextCtrl`.  
      :type `fileType`: int








      :rtype: `bool`



                  



      :returns: 

         ``True`` if the operation was successful, ``False`` otherwise.   








   .. method:: SetDefaultStyle(self, style)

      Changes the default style to use for the new text which is going to be added to the control using :meth:`WriteText`   or :meth:`AppendText` .                  

      If either of the font, foreground, or background colour is not set in `style`, the values of the previous default style are used for them. If the previous default style didn't set them neither, the global font or colours of the text control itself are used as fall back. 

      However if the `style`  parameter is the default :ref:`wx.TextAttr`, then the default style is just reset (instead of being combined with the new style which wouldn't change it at all). 




      :param `style`: The style for the new text.  
      :type `style`: wx.TextAttr






      :rtype: `bool`



                  



      :returns: 

         ``True`` on success, ``False`` if an error occurred (this may also mean that the styles are not supported under this platform).  







      .. seealso:: :meth:`GetDefaultStyle`     








   .. method:: SetModified(self, modified)

      Marks the control as being modified by the user or not.                  

                


      :param `modified`: 
      :type `modified`: bool






      .. seealso:: :meth:`MarkDirty` , :meth:`DiscardEdits`     








   .. method:: SetStyle(self, start, end, style)

      Changes the style of the given range.                  

      If any attribute within `style`  is not set, the corresponding attribute from :meth:`GetDefaultStyle`   is used. 




      :param `start`: The start of the range to change.   
      :type `start`: long
      :param `end`: The end of the range to change.   
      :type `end`: long
      :param `style`: The new style for the range.  
      :type `style`: wx.TextAttr










      :rtype: `bool`



                  



      :returns: 

         ``True`` on success, ``False`` if an error occurred (this may also mean that the styles are not supported under this platform).  







      .. seealso:: :meth:`GetStyle` , :ref:`wx.TextAttr`    








   .. method:: ShowNativeCaret(self, show=True)

                              Turn on the widget's native caret on Windows.
                              Ignored on other platforms.
                         

      :rtype: `bool`








   .. method:: ShowPosition(self, pos)

      Makes the line containing the given position visible.                  




      :param `pos`: The position that should be visible.   
      :type `pos`: long




                  





   .. method:: XYToPosition(self, x, y)

      Converts the given zero based column and line number to a position.                  




      :param `x`: The column number.   
      :type `x`: long
      :param `y`: The line number.  
      :type `y`: long








      :rtype: `long`



                  



      :returns: 

         The position value, or -1 if x or y was invalid.   








   .. method:: flush(self)

      ``NOP``, for file-like compatibility.  





   .. method:: write(self, text)

      Append text to the textctrl, for file-like compatibility.  





   .. attribute:: DefaultStyle

      See :meth:`~wx.TextCtrl.GetDefaultStyle` and :meth:`~wx.TextCtrl.SetDefaultStyle`


   .. attribute:: NumberOfLines

      See :meth:`~wx.TextCtrl.GetNumberOfLines`