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
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
|
<span id="curses-terminal-handling-for-character-cell-displays"></span><h1>curses — Terminal handling for character-cell displays</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/curses">Lib/curses</a></p> <p>The <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><code>curses</code></a> module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling.</p> <p>While curses is most widely used in the Unix environment, versions are available for Windows, DOS, and possibly other systems as well. This extension module is designed to match the API of ncurses, an open-source curses library hosted on Linux and the BSD variants of Unix.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Whenever the documentation mentions a <em>character</em> it can be specified as an integer, a one-character Unicode string or a one-byte byte string.</p> <p>Whenever the documentation mentions a <em>character string</em> it can be specified as a Unicode string or a byte string.</p> </div> <div class="admonition seealso"> <p class="admonition-title">See also</p> <dl class="simple"> <dt>
<code>Module</code> <a class="reference internal" href="curses.ascii#module-curses.ascii" title="curses.ascii: Constants and set-membership functions for ASCII characters."><code>curses.ascii</code></a>
</dt>
<dd>
<p>Utilities for working with ASCII characters, regardless of your locale settings.</p> </dd> <dt>
<code>Module</code> <a class="reference internal" href="curses.panel#module-curses.panel" title="curses.panel: A panel stack extension that adds depth to curses windows."><code>curses.panel</code></a>
</dt>
<dd>
<p>A panel stack extension that adds depth to curses windows.</p> </dd> <dt>
<code>Module</code> <a class="reference internal" href="#module-curses.textpad" title="curses.textpad: Emacs-like input editing in a curses window."><code>curses.textpad</code></a>
</dt>
<dd>
<p>Editable text widget for curses supporting <strong class="program">Emacs</strong>-like bindings.</p> </dd> <dt><a class="reference internal" href="../howto/curses#curses-howto"><span class="std std-ref">Curses Programming with Python</span></a></dt>
<dd>
<p>Tutorial material on using curses with Python, by Andrew Kuchling and Eric Raymond.</p> </dd> </dl> </div> <section id="functions"> <span id="curses-functions"></span><h2>Functions</h2> <p>The module <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><code>curses</code></a> defines the following exception:</p> <dl class="py exception"> <dt class="sig sig-object py" id="curses.error">
<code>exception curses.error</code> </dt> <dd>
<p>Exception raised when a curses library function returns an error.</p> </dd>
</dl> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Whenever <em>x</em> or <em>y</em> arguments to a function or a method are optional, they default to the current cursor location. Whenever <em>attr</em> is optional, it defaults to <a class="reference internal" href="#curses.A_NORMAL" title="curses.A_NORMAL"><code>A_NORMAL</code></a>.</p> </div> <p>The module <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><code>curses</code></a> defines the following functions:</p> <dl class="py function"> <dt class="sig sig-object py" id="curses.baudrate">
<code>curses.baudrate()</code> </dt> <dd>
<p>Return the output speed of the terminal in bits per second. On software terminal emulators it will have a fixed high value. Included for historical reasons; in former times, it was used to write output loops for time delays and occasionally to change interfaces depending on the line speed.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.beep">
<code>curses.beep()</code> </dt> <dd>
<p>Emit a short attention sound.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.can_change_color">
<code>curses.can_change_color()</code> </dt> <dd>
<p>Return <code>True</code> or <code>False</code>, depending on whether the programmer can change the colors displayed by the terminal.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.cbreak">
<code>curses.cbreak()</code> </dt> <dd>
<p>Enter cbreak mode. In cbreak mode (sometimes called “rare” mode) normal tty line buffering is turned off and characters are available to be read one by one. However, unlike raw mode, special characters (interrupt, quit, suspend, and flow control) retain their effects on the tty driver and calling program. Calling first <a class="reference internal" href="#curses.raw" title="curses.raw"><code>raw()</code></a> then <a class="reference internal" href="#curses.cbreak" title="curses.cbreak"><code>cbreak()</code></a> leaves the terminal in cbreak mode.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.color_content">
<code>curses.color_content(color_number)</code> </dt> <dd>
<p>Return the intensity of the red, green, and blue (RGB) components in the color <em>color_number</em>, which must be between <code>0</code> and <code>COLORS - 1</code>. Return a 3-tuple, containing the R,G,B values for the given color, which will be between <code>0</code> (no component) and <code>1000</code> (maximum amount of component).</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.color_pair">
<code>curses.color_pair(pair_number)</code> </dt> <dd>
<p>Return the attribute value for displaying text in the specified color pair. Only the first 256 color pairs are supported. This attribute value can be combined with <a class="reference internal" href="#curses.A_STANDOUT" title="curses.A_STANDOUT"><code>A_STANDOUT</code></a>, <a class="reference internal" href="#curses.A_REVERSE" title="curses.A_REVERSE"><code>A_REVERSE</code></a>, and the other <code>A_*</code> attributes. <a class="reference internal" href="#curses.pair_number" title="curses.pair_number"><code>pair_number()</code></a> is the counterpart to this function.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.curs_set">
<code>curses.curs_set(visibility)</code> </dt> <dd>
<p>Set the cursor state. <em>visibility</em> can be set to <code>0</code>, <code>1</code>, or <code>2</code>, for invisible, normal, or very visible. If the terminal supports the visibility requested, return the previous cursor state; otherwise raise an exception. On many terminals, the “visible” mode is an underline cursor and the “very visible” mode is a block cursor.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.def_prog_mode">
<code>curses.def_prog_mode()</code> </dt> <dd>
<p>Save the current terminal mode as the “program” mode, the mode when the running program is using curses. (Its counterpart is the “shell” mode, for when the program is not in curses.) Subsequent calls to <a class="reference internal" href="#curses.reset_prog_mode" title="curses.reset_prog_mode"><code>reset_prog_mode()</code></a> will restore this mode.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.def_shell_mode">
<code>curses.def_shell_mode()</code> </dt> <dd>
<p>Save the current terminal mode as the “shell” mode, the mode when the running program is not using curses. (Its counterpart is the “program” mode, when the program is using curses capabilities.) Subsequent calls to <a class="reference internal" href="#curses.reset_shell_mode" title="curses.reset_shell_mode"><code>reset_shell_mode()</code></a> will restore this mode.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.delay_output">
<code>curses.delay_output(ms)</code> </dt> <dd>
<p>Insert an <em>ms</em> millisecond pause in output.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.doupdate">
<code>curses.doupdate()</code> </dt> <dd>
<p>Update the physical screen. The curses library keeps two data structures, one representing the current physical screen contents and a virtual screen representing the desired next state. The <a class="reference internal" href="#curses.doupdate" title="curses.doupdate"><code>doupdate()</code></a> ground updates the physical screen to match the virtual screen.</p> <p>The virtual screen may be updated by a <a class="reference internal" href="#curses.window.noutrefresh" title="curses.window.noutrefresh"><code>noutrefresh()</code></a> call after write operations such as <a class="reference internal" href="#curses.window.addstr" title="curses.window.addstr"><code>addstr()</code></a> have been performed on a window. The normal <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a> call is simply <code>noutrefresh()</code> followed by <code>doupdate()</code>; if you have to update multiple windows, you can speed performance and perhaps reduce screen flicker by issuing <code>noutrefresh()</code> calls on all windows, followed by a single <code>doupdate()</code>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.echo">
<code>curses.echo()</code> </dt> <dd>
<p>Enter echo mode. In echo mode, each character input is echoed to the screen as it is entered.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.endwin">
<code>curses.endwin()</code> </dt> <dd>
<p>De-initialize the library, and return terminal to normal status.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.erasechar">
<code>curses.erasechar()</code> </dt> <dd>
<p>Return the user’s current erase character as a one-byte bytes object. Under Unix operating systems this is a property of the controlling tty of the curses program, and is not set by the curses library itself.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.filter">
<code>curses.filter()</code> </dt> <dd>
<p>The <a class="reference internal" href="#curses.filter" title="curses.filter"><code>filter()</code></a> routine, if used, must be called before <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a> is called. The effect is that, during those calls, <span class="target" id="index-0"></span><code>LINES</code> is set to <code>1</code>; the capabilities <code>clear</code>, <code>cup</code>, <code>cud</code>, <code>cud1</code>, <code>cuu1</code>, <code>cuu</code>, <code>vpa</code> are disabled; and the <code>home</code> string is set to the value of <code>cr</code>. The effect is that the cursor is confined to the current line, and so are screen updates. This may be used for enabling character-at-a-time line editing without touching the rest of the screen.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.flash">
<code>curses.flash()</code> </dt> <dd>
<p>Flash the screen. That is, change it to reverse-video and then change it back in a short interval. Some people prefer such as ‘visible bell’ to the audible attention signal produced by <a class="reference internal" href="#curses.beep" title="curses.beep"><code>beep()</code></a>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.flushinp">
<code>curses.flushinp()</code> </dt> <dd>
<p>Flush all input buffers. This throws away any typeahead that has been typed by the user and has not yet been processed by the program.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.getmouse">
<code>curses.getmouse()</code> </dt> <dd>
<p>After <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><code>getch()</code></a> returns <a class="reference internal" href="#curses.KEY_MOUSE" title="curses.KEY_MOUSE"><code>KEY_MOUSE</code></a> to signal a mouse event, this method should be called to retrieve the queued mouse event, represented as a 5-tuple <code>(id, x, y, z, bstate)</code>. <em>id</em> is an ID value used to distinguish multiple devices, and <em>x</em>, <em>y</em>, <em>z</em> are the event’s coordinates. (<em>z</em> is currently unused.) <em>bstate</em> is an integer value whose bits will be set to indicate the type of event, and will be the bitwise OR of one or more of the following constants, where <em>n</em> is the button number from 1 to 5: <a class="reference internal" href="#curses.BUTTONn_PRESSED" title="curses.BUTTONn_PRESSED"><code>BUTTONn_PRESSED</code></a>, <a class="reference internal" href="#curses.BUTTONn_RELEASED" title="curses.BUTTONn_RELEASED"><code>BUTTONn_RELEASED</code></a>, <a class="reference internal" href="#curses.BUTTONn_CLICKED" title="curses.BUTTONn_CLICKED"><code>BUTTONn_CLICKED</code></a>, <a class="reference internal" href="#curses.BUTTONn_DOUBLE_CLICKED" title="curses.BUTTONn_DOUBLE_CLICKED"><code>BUTTONn_DOUBLE_CLICKED</code></a>, <a class="reference internal" href="#curses.BUTTONn_TRIPLE_CLICKED" title="curses.BUTTONn_TRIPLE_CLICKED"><code>BUTTONn_TRIPLE_CLICKED</code></a>, <a class="reference internal" href="#curses.BUTTON_SHIFT" title="curses.BUTTON_SHIFT"><code>BUTTON_SHIFT</code></a>, <a class="reference internal" href="#curses.BUTTON_CTRL" title="curses.BUTTON_CTRL"><code>BUTTON_CTRL</code></a>, <a class="reference internal" href="#curses.BUTTON_ALT" title="curses.BUTTON_ALT"><code>BUTTON_ALT</code></a>.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.10: </span>The <code>BUTTON5_*</code> constants are now exposed if they are provided by the underlying curses library.</p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.getsyx">
<code>curses.getsyx()</code> </dt> <dd>
<p>Return the current coordinates of the virtual screen cursor as a tuple <code>(y, x)</code>. If <a class="reference internal" href="#curses.window.leaveok" title="curses.window.leaveok"><code>leaveok</code></a> is currently <code>True</code>, then return <code>(-1, -1)</code>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.getwin">
<code>curses.getwin(file)</code> </dt> <dd>
<p>Read window related data stored in the file by an earlier <a class="reference internal" href="#curses.window.putwin" title="curses.window.putwin"><code>window.putwin()</code></a> call. The routine then creates and initializes a new window using that data, returning the new window object.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.has_colors">
<code>curses.has_colors()</code> </dt> <dd>
<p>Return <code>True</code> if the terminal can display colors; otherwise, return <code>False</code>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.has_extended_color_support">
<code>curses.has_extended_color_support()</code> </dt> <dd>
<p>Return <code>True</code> if the module supports extended colors; otherwise, return <code>False</code>. Extended color support allows more than 256 color pairs for terminals that support more than 16 colors (e.g. xterm-256color).</p> <p>Extended color support requires ncurses version 6.1 or later.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.10.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.has_ic">
<code>curses.has_ic()</code> </dt> <dd>
<p>Return <code>True</code> if the terminal has insert- and delete-character capabilities. This function is included for historical reasons only, as all modern software terminal emulators have such capabilities.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.has_il">
<code>curses.has_il()</code> </dt> <dd>
<p>Return <code>True</code> if the terminal has insert- and delete-line capabilities, or can simulate them using scrolling regions. This function is included for historical reasons only, as all modern software terminal emulators have such capabilities.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.has_key">
<code>curses.has_key(ch)</code> </dt> <dd>
<p>Take a key value <em>ch</em>, and return <code>True</code> if the current terminal type recognizes a key with that value.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.halfdelay">
<code>curses.halfdelay(tenths)</code> </dt> <dd>
<p>Used for half-delay mode, which is similar to cbreak mode in that characters typed by the user are immediately available to the program. However, after blocking for <em>tenths</em> tenths of seconds, raise an exception if nothing has been typed. The value of <em>tenths</em> must be a number between <code>1</code> and <code>255</code>. Use <a class="reference internal" href="#curses.nocbreak" title="curses.nocbreak"><code>nocbreak()</code></a> to leave half-delay mode.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.init_color">
<code>curses.init_color(color_number, r, g, b)</code> </dt> <dd>
<p>Change the definition of a color, taking the number of the color to be changed followed by three RGB values (for the amounts of red, green, and blue components). The value of <em>color_number</em> must be between <code>0</code> and <code>COLORS - 1</code>. Each of <em>r</em>, <em>g</em>, <em>b</em>, must be a value between <code>0</code> and <code>1000</code>. When <a class="reference internal" href="#curses.init_color" title="curses.init_color"><code>init_color()</code></a> is used, all occurrences of that color on the screen immediately change to the new definition. This function is a no-op on most terminals; it is active only if <a class="reference internal" href="#curses.can_change_color" title="curses.can_change_color"><code>can_change_color()</code></a> returns <code>True</code>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.init_pair">
<code>curses.init_pair(pair_number, fg, bg)</code> </dt> <dd>
<p>Change the definition of a color-pair. It takes three arguments: the number of the color-pair to be changed, the foreground color number, and the background color number. The value of <em>pair_number</em> must be between <code>1</code> and <code>COLOR_PAIRS - 1</code> (the <code>0</code> color pair is wired to white on black and cannot be changed). The value of <em>fg</em> and <em>bg</em> arguments must be between <code>0</code> and <code>COLORS - 1</code>, or, after calling <a class="reference internal" href="#curses.use_default_colors" title="curses.use_default_colors"><code>use_default_colors()</code></a>, <code>-1</code>. If the color-pair was previously initialized, the screen is refreshed and all occurrences of that color-pair are changed to the new definition.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.initscr">
<code>curses.initscr()</code> </dt> <dd>
<p>Initialize the library. Return a <a class="reference internal" href="#curses-window-objects"><span class="std std-ref">window</span></a> object which represents the whole screen.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>If there is an error opening the terminal, the underlying curses library may cause the interpreter to exit.</p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.is_term_resized">
<code>curses.is_term_resized(nlines, ncols)</code> </dt> <dd>
<p>Return <code>True</code> if <a class="reference internal" href="#curses.resize_term" title="curses.resize_term"><code>resize_term()</code></a> would modify the window structure, <code>False</code> otherwise.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.isendwin">
<code>curses.isendwin()</code> </dt> <dd>
<p>Return <code>True</code> if <a class="reference internal" href="#curses.endwin" title="curses.endwin"><code>endwin()</code></a> has been called (that is, the curses library has been deinitialized).</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.keyname">
<code>curses.keyname(k)</code> </dt> <dd>
<p>Return the name of the key numbered <em>k</em> as a bytes object. The name of a key generating printable ASCII character is the key’s character. The name of a control-key combination is a two-byte bytes object consisting of a caret (<code>b'^'</code>) followed by the corresponding printable ASCII character. The name of an alt-key combination (128–255) is a bytes object consisting of the prefix <code>b'M-'</code> followed by the name of the corresponding ASCII character.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.killchar">
<code>curses.killchar()</code> </dt> <dd>
<p>Return the user’s current line kill character as a one-byte bytes object. Under Unix operating systems this is a property of the controlling tty of the curses program, and is not set by the curses library itself.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.longname">
<code>curses.longname()</code> </dt> <dd>
<p>Return a bytes object containing the terminfo long name field describing the current terminal. The maximum length of a verbose description is 128 characters. It is defined only after the call to <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.meta">
<code>curses.meta(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, allow 8-bit characters to be input. If <em>flag</em> is <code>False</code>, allow only 7-bit chars.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.mouseinterval">
<code>curses.mouseinterval(interval)</code> </dt> <dd>
<p>Set the maximum time in milliseconds that can elapse between press and release events in order for them to be recognized as a click, and return the previous interval value. The default value is 200 milliseconds, or one fifth of a second.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.mousemask">
<code>curses.mousemask(mousemask)</code> </dt> <dd>
<p>Set the mouse events to be reported, and return a tuple <code>(availmask,
oldmask)</code>. <em>availmask</em> indicates which of the specified mouse events can be reported; on complete failure it returns <code>0</code>. <em>oldmask</em> is the previous value of the given window’s mouse event mask. If this function is never called, no mouse events are ever reported.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.napms">
<code>curses.napms(ms)</code> </dt> <dd>
<p>Sleep for <em>ms</em> milliseconds.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.newpad">
<code>curses.newpad(nlines, ncols)</code> </dt> <dd>
<p>Create and return a pointer to a new pad data structure with the given number of lines and columns. Return a pad as a window object.</p> <p>A pad is like a window, except that it is not restricted by the screen size, and is not necessarily associated with a particular part of the screen. Pads can be used when a large window is needed, and only a part of the window will be on the screen at one time. Automatic refreshes of pads (such as from scrolling or echoing of input) do not occur. The <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a> and <a class="reference internal" href="#curses.window.noutrefresh" title="curses.window.noutrefresh"><code>noutrefresh()</code></a> methods of a pad require 6 arguments to specify the part of the pad to be displayed and the location on the screen to be used for the display. The arguments are <em>pminrow</em>, <em>pmincol</em>, <em>sminrow</em>, <em>smincol</em>, <em>smaxrow</em>, <em>smaxcol</em>; the <em>p</em> arguments refer to the upper left corner of the pad region to be displayed and the <em>s</em> arguments define a clipping box on the screen within which the pad region is to be displayed.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.newwin">
<code>curses.newwin(nlines, ncols)</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">curses.</span><span class="sig-name descname">newwin</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">nlines</span></em>, <em class="sig-param"><span class="n">ncols</span></em>, <em class="sig-param"><span class="n">begin_y</span></em>, <em class="sig-param"><span class="n">begin_x</span></em><span class="sig-paren">)</span>
</dt> <dd>
<p>Return a new <a class="reference internal" href="#curses-window-objects"><span class="std std-ref">window</span></a>, whose left-upper corner is at <code>(begin_y, begin_x)</code>, and whose height/width is <em>nlines</em>/<em>ncols</em>.</p> <p>By default, the window will extend from the specified position to the lower right corner of the screen.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.nl">
<code>curses.nl()</code> </dt> <dd>
<p>Enter newline mode. This mode translates the return key into newline on input, and translates newline into return and line-feed on output. Newline mode is initially on.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.nocbreak">
<code>curses.nocbreak()</code> </dt> <dd>
<p>Leave cbreak mode. Return to normal “cooked” mode with line buffering.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.noecho">
<code>curses.noecho()</code> </dt> <dd>
<p>Leave echo mode. Echoing of input characters is turned off.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.nonl">
<code>curses.nonl()</code> </dt> <dd>
<p>Leave newline mode. Disable translation of return into newline on input, and disable low-level translation of newline into newline/return on output (but this does not change the behavior of <code>addch('\n')</code>, which always does the equivalent of return and line feed on the virtual screen). With translation off, curses can sometimes speed up vertical motion a little; also, it will be able to detect the return key on input.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.noqiflush">
<code>curses.noqiflush()</code> </dt> <dd>
<p>When the <code>noqiflush()</code> routine is used, normal flush of input and output queues associated with the <code>INTR</code>, <code>QUIT</code> and <code>SUSP</code> characters will not be done. You may want to call <code>noqiflush()</code> in a signal handler if you want output to continue as though the interrupt had not occurred, after the handler exits.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.noraw">
<code>curses.noraw()</code> </dt> <dd>
<p>Leave raw mode. Return to normal “cooked” mode with line buffering.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.pair_content">
<code>curses.pair_content(pair_number)</code> </dt> <dd>
<p>Return a tuple <code>(fg, bg)</code> containing the colors for the requested color pair. The value of <em>pair_number</em> must be between <code>0</code> and <code>COLOR_PAIRS - 1</code>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.pair_number">
<code>curses.pair_number(attr)</code> </dt> <dd>
<p>Return the number of the color-pair set by the attribute value <em>attr</em>. <a class="reference internal" href="#curses.color_pair" title="curses.color_pair"><code>color_pair()</code></a> is the counterpart to this function.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.putp">
<code>curses.putp(str)</code> </dt> <dd>
<p>Equivalent to <code>tputs(str, 1, putchar)</code>; emit the value of a specified terminfo capability for the current terminal. Note that the output of <a class="reference internal" href="#curses.putp" title="curses.putp"><code>putp()</code></a> always goes to standard output.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.qiflush">
<code>curses.qiflush([flag])</code> </dt> <dd>
<p>If <em>flag</em> is <code>False</code>, the effect is the same as calling <a class="reference internal" href="#curses.noqiflush" title="curses.noqiflush"><code>noqiflush()</code></a>. If <em>flag</em> is <code>True</code>, or no argument is provided, the queues will be flushed when these control characters are read.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.raw">
<code>curses.raw()</code> </dt> <dd>
<p>Enter raw mode. In raw mode, normal line buffering and processing of interrupt, quit, suspend, and flow control keys are turned off; characters are presented to curses input functions one by one.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.reset_prog_mode">
<code>curses.reset_prog_mode()</code> </dt> <dd>
<p>Restore the terminal to “program” mode, as previously saved by <a class="reference internal" href="#curses.def_prog_mode" title="curses.def_prog_mode"><code>def_prog_mode()</code></a>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.reset_shell_mode">
<code>curses.reset_shell_mode()</code> </dt> <dd>
<p>Restore the terminal to “shell” mode, as previously saved by <a class="reference internal" href="#curses.def_shell_mode" title="curses.def_shell_mode"><code>def_shell_mode()</code></a>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.resetty">
<code>curses.resetty()</code> </dt> <dd>
<p>Restore the state of the terminal modes to what it was at the last call to <a class="reference internal" href="#curses.savetty" title="curses.savetty"><code>savetty()</code></a>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.resize_term">
<code>curses.resize_term(nlines, ncols)</code> </dt> <dd>
<p>Backend function used by <a class="reference internal" href="#curses.resizeterm" title="curses.resizeterm"><code>resizeterm()</code></a>, performing most of the work; when resizing the windows, <a class="reference internal" href="#curses.resize_term" title="curses.resize_term"><code>resize_term()</code></a> blank-fills the areas that are extended. The calling application should fill in these areas with appropriate data. The <code>resize_term()</code> function attempts to resize all windows. However, due to the calling convention of pads, it is not possible to resize these without additional interaction with the application.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.resizeterm">
<code>curses.resizeterm(nlines, ncols)</code> </dt> <dd>
<p>Resize the standard and current windows to the specified dimensions, and adjusts other bookkeeping data used by the curses library that record the window dimensions (in particular the SIGWINCH handler).</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.savetty">
<code>curses.savetty()</code> </dt> <dd>
<p>Save the current state of the terminal modes in a buffer, usable by <a class="reference internal" href="#curses.resetty" title="curses.resetty"><code>resetty()</code></a>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.get_escdelay">
<code>curses.get_escdelay()</code> </dt> <dd>
<p>Retrieves the value set by <a class="reference internal" href="#curses.set_escdelay" title="curses.set_escdelay"><code>set_escdelay()</code></a>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.9.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.set_escdelay">
<code>curses.set_escdelay(ms)</code> </dt> <dd>
<p>Sets the number of milliseconds to wait after reading an escape character, to distinguish between an individual escape character entered on the keyboard from escape sequences sent by cursor and function keys.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.9.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.get_tabsize">
<code>curses.get_tabsize()</code> </dt> <dd>
<p>Retrieves the value set by <a class="reference internal" href="#curses.set_tabsize" title="curses.set_tabsize"><code>set_tabsize()</code></a>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.9.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.set_tabsize">
<code>curses.set_tabsize(size)</code> </dt> <dd>
<p>Sets the number of columns used by the curses library when converting a tab character to spaces as it adds the tab to a window.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.9.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.setsyx">
<code>curses.setsyx(y, x)</code> </dt> <dd>
<p>Set the virtual screen cursor to <em>y</em>, <em>x</em>. If <em>y</em> and <em>x</em> are both <code>-1</code>, then <a class="reference internal" href="#curses.window.leaveok" title="curses.window.leaveok"><code>leaveok</code></a> is set <code>True</code>.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.setupterm">
<code>curses.setupterm(term=None, fd=- 1)</code> </dt> <dd>
<p>Initialize the terminal. <em>term</em> is a string giving the terminal name, or <code>None</code>; if omitted or <code>None</code>, the value of the <span class="target" id="index-1"></span><code>TERM</code> environment variable will be used. <em>fd</em> is the file descriptor to which any initialization sequences will be sent; if not supplied or <code>-1</code>, the file descriptor for <code>sys.stdout</code> will be used.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.start_color">
<code>curses.start_color()</code> </dt> <dd>
<p>Must be called if the programmer wants to use colors, and before any other color manipulation routine is called. It is good practice to call this routine right after <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a>.</p> <p><a class="reference internal" href="#curses.start_color" title="curses.start_color"><code>start_color()</code></a> initializes eight basic colors (black, red, green, yellow, blue, magenta, cyan, and white), and two global variables in the <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><code>curses</code></a> module, <a class="reference internal" href="#curses.COLORS" title="curses.COLORS"><code>COLORS</code></a> and <a class="reference internal" href="#curses.COLOR_PAIRS" title="curses.COLOR_PAIRS"><code>COLOR_PAIRS</code></a>, containing the maximum number of colors and color-pairs the terminal can support. It also restores the colors on the terminal to the values they had when the terminal was just turned on.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.termattrs">
<code>curses.termattrs()</code> </dt> <dd>
<p>Return a logical OR of all video attributes supported by the terminal. This information is useful when a curses program needs complete control over the appearance of the screen.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.termname">
<code>curses.termname()</code> </dt> <dd>
<p>Return the value of the environment variable <span class="target" id="index-2"></span><code>TERM</code>, as a bytes object, truncated to 14 characters.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.tigetflag">
<code>curses.tigetflag(capname)</code> </dt> <dd>
<p>Return the value of the Boolean capability corresponding to the terminfo capability name <em>capname</em> as an integer. Return the value <code>-1</code> if <em>capname</em> is not a Boolean capability, or <code>0</code> if it is canceled or absent from the terminal description.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.tigetnum">
<code>curses.tigetnum(capname)</code> </dt> <dd>
<p>Return the value of the numeric capability corresponding to the terminfo capability name <em>capname</em> as an integer. Return the value <code>-2</code> if <em>capname</em> is not a numeric capability, or <code>-1</code> if it is canceled or absent from the terminal description.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.tigetstr">
<code>curses.tigetstr(capname)</code> </dt> <dd>
<p>Return the value of the string capability corresponding to the terminfo capability name <em>capname</em> as a bytes object. Return <code>None</code> if <em>capname</em> is not a terminfo “string capability”, or is canceled or absent from the terminal description.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.tparm">
<code>curses.tparm(str[, ...])</code> </dt> <dd>
<p>Instantiate the bytes object <em>str</em> with the supplied parameters, where <em>str</em> should be a parameterized string obtained from the terminfo database. E.g. <code>tparm(tigetstr("cup"), 5, 3)</code> could result in <code>b'\033[6;4H'</code>, the exact result depending on terminal type.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.typeahead">
<code>curses.typeahead(fd)</code> </dt> <dd>
<p>Specify that the file descriptor <em>fd</em> be used for typeahead checking. If <em>fd</em> is <code>-1</code>, then no typeahead checking is done.</p> <p>The curses library does “line-breakout optimization” by looking for typeahead periodically while updating the screen. If input is found, and it is coming from a tty, the current update is postponed until refresh or doupdate is called again, allowing faster response to commands typed in advance. This function allows specifying a different file descriptor for typeahead checking.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.unctrl">
<code>curses.unctrl(ch)</code> </dt> <dd>
<p>Return a bytes object which is a printable representation of the character <em>ch</em>. Control characters are represented as a caret followed by the character, for example as <code>b'^C'</code>. Printing characters are left as they are.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.ungetch">
<code>curses.ungetch(ch)</code> </dt> <dd>
<p>Push <em>ch</em> so the next <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><code>getch()</code></a> will return it.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Only one <em>ch</em> can be pushed before <code>getch()</code> is called.</p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.update_lines_cols">
<code>curses.update_lines_cols()</code> </dt> <dd>
<p>Update the <a class="reference internal" href="#curses.LINES" title="curses.LINES"><code>LINES</code></a> and <a class="reference internal" href="#curses.COLS" title="curses.COLS"><code>COLS</code></a> module variables. Useful for detecting manual screen resize.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.5.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.unget_wch">
<code>curses.unget_wch(ch)</code> </dt> <dd>
<p>Push <em>ch</em> so the next <a class="reference internal" href="#curses.window.get_wch" title="curses.window.get_wch"><code>get_wch()</code></a> will return it.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Only one <em>ch</em> can be pushed before <code>get_wch()</code> is called.</p> </div> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.3.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.ungetmouse">
<code>curses.ungetmouse(id, x, y, z, bstate)</code> </dt> <dd>
<p>Push a <a class="reference internal" href="#curses.KEY_MOUSE" title="curses.KEY_MOUSE"><code>KEY_MOUSE</code></a> event onto the input queue, associating the given state data with it.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.use_env">
<code>curses.use_env(flag)</code> </dt> <dd>
<p>If used, this function should be called before <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a> or newterm are called. When <em>flag</em> is <code>False</code>, the values of lines and columns specified in the terminfo database will be used, even if environment variables <span class="target" id="index-3"></span><code>LINES</code> and <span class="target" id="index-4"></span><code>COLUMNS</code> (used by default) are set, or if curses is running in a window (in which case default behavior would be to use the window size if <span class="target" id="index-5"></span><code>LINES</code> and <span class="target" id="index-6"></span><code>COLUMNS</code> are not set).</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.use_default_colors">
<code>curses.use_default_colors()</code> </dt> <dd>
<p>Allow use of default values for colors on terminals supporting this feature. Use this to support transparency in your application. The default color is assigned to the color number <code>-1</code>. After calling this function, <code>init_pair(x,
curses.COLOR_RED, -1)</code> initializes, for instance, color pair <em>x</em> to a red foreground color on the default background.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="curses.wrapper">
<code>curses.wrapper(func, /, *args, **kwargs)</code> </dt> <dd>
<p>Initialize curses and call another callable object, <em>func</em>, which should be the rest of your curses-using application. If the application raises an exception, this function will restore the terminal to a sane state before re-raising the exception and generating a traceback. The callable object <em>func</em> is then passed the main window ‘stdscr’ as its first argument, followed by any other arguments passed to <code>wrapper()</code>. Before calling <em>func</em>, <code>wrapper()</code> turns on cbreak mode, turns off echo, enables the terminal keypad, and initializes colors if the terminal has color support. On exit (whether normally or by exception) it restores cooked mode, turns on echo, and disables the terminal keypad.</p> </dd>
</dl> </section> <section id="window-objects"> <span id="curses-window-objects"></span><h2>Window Objects</h2> <p>Window objects, as returned by <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a> and <a class="reference internal" href="#curses.newwin" title="curses.newwin"><code>newwin()</code></a> above, have the following methods and attributes:</p> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.addch">
<code>window.addch(ch[, attr])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">addch</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">ch</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">attr</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Paint character <em>ch</em> at <code>(y, x)</code> with attributes <em>attr</em>, overwriting any character previously painted at that location. By default, the character position and attributes are the current settings for the window object.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Writing outside the window, subwindow, or pad raises a <a class="reference internal" href="#curses.error" title="curses.error"><code>curses.error</code></a>. Attempting to write to the lower right corner of a window, subwindow, or pad will cause an exception to be raised after the character is printed.</p> </div> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.addnstr">
<code>window.addnstr(str, n[, attr])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">addnstr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">str</span></em>, <em class="sig-param"><span class="n">n</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">attr</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Paint at most <em>n</em> characters of the character string <em>str</em> at <code>(y, x)</code> with attributes <em>attr</em>, overwriting anything previously on the display.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.addstr">
<code>window.addstr(str[, attr])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">addstr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">str</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">attr</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Paint the character string <em>str</em> at <code>(y, x)</code> with attributes <em>attr</em>, overwriting anything previously on the display.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <ul class="simple"> <li>Writing outside the window, subwindow, or pad raises <a class="reference internal" href="#curses.error" title="curses.error"><code>curses.error</code></a>. Attempting to write to the lower right corner of a window, subwindow, or pad will cause an exception to be raised after the string is printed.</li> <li>A <a class="reference external" href="https://bugs.python.org/issue35924">bug in ncurses</a>, the backend for this Python module, can cause SegFaults when resizing windows. This is fixed in ncurses-6.1-20190511. If you are stuck with an earlier ncurses, you can avoid triggering this if you do not call <a class="reference internal" href="#curses.window.addstr" title="curses.window.addstr"><code>addstr()</code></a> with a <em>str</em> that has embedded newlines. Instead, call <a class="reference internal" href="#curses.window.addstr" title="curses.window.addstr"><code>addstr()</code></a> separately for each line.</li> </ul> </div> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.attroff">
<code>window.attroff(attr)</code> </dt> <dd>
<p>Remove attribute <em>attr</em> from the “background” set applied to all writes to the current window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.attron">
<code>window.attron(attr)</code> </dt> <dd>
<p>Add attribute <em>attr</em> from the “background” set applied to all writes to the current window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.attrset">
<code>window.attrset(attr)</code> </dt> <dd>
<p>Set the “background” set of attributes to <em>attr</em>. This set is initially <code>0</code> (no attributes).</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.bkgd">
<code>window.bkgd(ch[, attr])</code> </dt> <dd>
<p>Set the background property of the window to the character <em>ch</em>, with attributes <em>attr</em>. The change is then applied to every character position in that window:</p> <ul class="simple"> <li>The attribute of every character in the window is changed to the new background attribute.</li> <li>Wherever the former background character appears, it is changed to the new background character.</li> </ul> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.bkgdset">
<code>window.bkgdset(ch[, attr])</code> </dt> <dd>
<p>Set the window’s background. A window’s background consists of a character and any combination of attributes. The attribute part of the background is combined (OR’ed) with all non-blank characters that are written into the window. Both the character and attribute parts of the background are combined with the blank characters. The background becomes a property of the character and moves with the character through any scrolling and insert/delete line/character operations.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.border">
<code>window.border([ls[, rs[, ts[, bs[, tl[, tr[, bl[, br]]]]]]]])</code> </dt> <dd>
<p>Draw a border around the edges of the window. Each parameter specifies the character to use for a specific part of the border; see the table below for more details.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>A <code>0</code> value for any parameter will cause the default character to be used for that parameter. Keyword parameters can <em>not</em> be used. The defaults are listed in this table:</p> </div> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>Parameter</p></th> <th class="head"><p>Description</p></th> <th class="head"><p>Default value</p></th> </tr> </thead> <tr>
<td><p><em>ls</em></p></td> <td><p>Left side</p></td> <td><p><a class="reference internal" href="#curses.ACS_VLINE" title="curses.ACS_VLINE"><code>ACS_VLINE</code></a></p></td> </tr> <tr>
<td><p><em>rs</em></p></td> <td><p>Right side</p></td> <td><p><a class="reference internal" href="#curses.ACS_VLINE" title="curses.ACS_VLINE"><code>ACS_VLINE</code></a></p></td> </tr> <tr>
<td><p><em>ts</em></p></td> <td><p>Top</p></td> <td><p><a class="reference internal" href="#curses.ACS_HLINE" title="curses.ACS_HLINE"><code>ACS_HLINE</code></a></p></td> </tr> <tr>
<td><p><em>bs</em></p></td> <td><p>Bottom</p></td> <td><p><a class="reference internal" href="#curses.ACS_HLINE" title="curses.ACS_HLINE"><code>ACS_HLINE</code></a></p></td> </tr> <tr>
<td><p><em>tl</em></p></td> <td><p>Upper-left corner</p></td> <td><p><a class="reference internal" href="#curses.ACS_ULCORNER" title="curses.ACS_ULCORNER"><code>ACS_ULCORNER</code></a></p></td> </tr> <tr>
<td><p><em>tr</em></p></td> <td><p>Upper-right corner</p></td> <td><p><a class="reference internal" href="#curses.ACS_URCORNER" title="curses.ACS_URCORNER"><code>ACS_URCORNER</code></a></p></td> </tr> <tr>
<td><p><em>bl</em></p></td> <td><p>Bottom-left corner</p></td> <td><p><a class="reference internal" href="#curses.ACS_LLCORNER" title="curses.ACS_LLCORNER"><code>ACS_LLCORNER</code></a></p></td> </tr> <tr>
<td><p><em>br</em></p></td> <td><p>Bottom-right corner</p></td> <td><p><a class="reference internal" href="#curses.ACS_LRCORNER" title="curses.ACS_LRCORNER"><code>ACS_LRCORNER</code></a></p></td> </tr> </table> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.box">
<code>window.box([vertch, horch])</code> </dt> <dd>
<p>Similar to <a class="reference internal" href="#curses.window.border" title="curses.window.border"><code>border()</code></a>, but both <em>ls</em> and <em>rs</em> are <em>vertch</em> and both <em>ts</em> and <em>bs</em> are <em>horch</em>. The default corner characters are always used by this function.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.chgat">
<code>window.chgat(attr)</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">chgat</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">num</span></em>, <em class="sig-param"><span class="n">attr</span></em><span class="sig-paren">)</span>
</dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">chgat</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">attr</span></em><span class="sig-paren">)</span>
</dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">chgat</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">num</span></em>, <em class="sig-param"><span class="n">attr</span></em><span class="sig-paren">)</span>
</dt> <dd>
<p>Set the attributes of <em>num</em> characters at the current cursor position, or at position <code>(y, x)</code> if supplied. If <em>num</em> is not given or is <code>-1</code>, the attribute will be set on all the characters to the end of the line. This function moves cursor to position <code>(y, x)</code> if supplied. The changed line will be touched using the <a class="reference internal" href="#curses.window.touchline" title="curses.window.touchline"><code>touchline()</code></a> method so that the contents will be redisplayed by the next window refresh.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.clear">
<code>window.clear()</code> </dt> <dd>
<p>Like <a class="reference internal" href="#curses.window.erase" title="curses.window.erase"><code>erase()</code></a>, but also cause the whole window to be repainted upon next call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.clearok">
<code>window.clearok(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, the next call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a> will clear the window completely.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.clrtobot">
<code>window.clrtobot()</code> </dt> <dd>
<p>Erase from cursor to the end of the window: all lines below the cursor are deleted, and then the equivalent of <a class="reference internal" href="#curses.window.clrtoeol" title="curses.window.clrtoeol"><code>clrtoeol()</code></a> is performed.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.clrtoeol">
<code>window.clrtoeol()</code> </dt> <dd>
<p>Erase from cursor to the end of the line.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.cursyncup">
<code>window.cursyncup()</code> </dt> <dd>
<p>Update the current cursor position of all the ancestors of the window to reflect the current cursor position of the window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.delch">
<code>window.delch([y, x])</code> </dt> <dd>
<p>Delete any character at <code>(y, x)</code>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.deleteln">
<code>window.deleteln()</code> </dt> <dd>
<p>Delete the line under the cursor. All following lines are moved up by one line.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.derwin">
<code>window.derwin(begin_y, begin_x)</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">derwin</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">nlines</span></em>, <em class="sig-param"><span class="n">ncols</span></em>, <em class="sig-param"><span class="n">begin_y</span></em>, <em class="sig-param"><span class="n">begin_x</span></em><span class="sig-paren">)</span>
</dt> <dd>
<p>An abbreviation for “derive window”, <a class="reference internal" href="#curses.window.derwin" title="curses.window.derwin"><code>derwin()</code></a> is the same as calling <a class="reference internal" href="#curses.window.subwin" title="curses.window.subwin"><code>subwin()</code></a>, except that <em>begin_y</em> and <em>begin_x</em> are relative to the origin of the window, rather than relative to the entire screen. Return a window object for the derived window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.echochar">
<code>window.echochar(ch[, attr])</code> </dt> <dd>
<p>Add character <em>ch</em> with attribute <em>attr</em>, and immediately call <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a> on the window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.enclose">
<code>window.enclose(y, x)</code> </dt> <dd>
<p>Test whether the given pair of screen-relative character-cell coordinates are enclosed by the given window, returning <code>True</code> or <code>False</code>. It is useful for determining what subset of the screen windows enclose the location of a mouse event.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.10: </span>Previously it returned <code>1</code> or <code>0</code> instead of <code>True</code> or <code>False</code>.</p> </div> </dd>
</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="curses.window.encoding">
<code>window.encoding</code> </dt> <dd>
<p>Encoding used to encode method arguments (Unicode strings and characters). The encoding attribute is inherited from the parent window when a subwindow is created, for example with <a class="reference internal" href="#curses.window.subwin" title="curses.window.subwin"><code>window.subwin()</code></a>. By default, current locale encoding is used (see <a class="reference internal" href="locale#locale.getencoding" title="locale.getencoding"><code>locale.getencoding()</code></a>).</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.3.</span></p> </div> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.erase">
<code>window.erase()</code> </dt> <dd>
<p>Clear the window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getbegyx">
<code>window.getbegyx()</code> </dt> <dd>
<p>Return a tuple <code>(y, x)</code> of co-ordinates of upper-left corner.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getbkgd">
<code>window.getbkgd()</code> </dt> <dd>
<p>Return the given window’s current background character/attribute pair.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getch">
<code>window.getch([y, x])</code> </dt> <dd>
<p>Get a character. Note that the integer returned does <em>not</em> have to be in ASCII range: function keys, keypad keys and so on are represented by numbers higher than 255. In no-delay mode, return <code>-1</code> if there is no input, otherwise wait until a key is pressed.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.get_wch">
<code>window.get_wch([y, x])</code> </dt> <dd>
<p>Get a wide character. Return a character for most keys, or an integer for function keys, keypad keys, and other special keys. In no-delay mode, raise an exception if there is no input.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.3.</span></p> </div> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getkey">
<code>window.getkey([y, x])</code> </dt> <dd>
<p>Get a character, returning a string instead of an integer, as <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><code>getch()</code></a> does. Function keys, keypad keys and other special keys return a multibyte string containing the key name. In no-delay mode, raise an exception if there is no input.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getmaxyx">
<code>window.getmaxyx()</code> </dt> <dd>
<p>Return a tuple <code>(y, x)</code> of the height and width of the window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getparyx">
<code>window.getparyx()</code> </dt> <dd>
<p>Return the beginning coordinates of this window relative to its parent window as a tuple <code>(y, x)</code>. Return <code>(-1, -1)</code> if this window has no parent.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getstr">
<code>window.getstr()</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">getstr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">n</span></em><span class="sig-paren">)</span>
</dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">getstr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em><span class="sig-paren">)</span>
</dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">getstr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">n</span></em><span class="sig-paren">)</span>
</dt> <dd>
<p>Read a bytes object from the user, with primitive line editing capacity.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.getyx">
<code>window.getyx()</code> </dt> <dd>
<p>Return a tuple <code>(y, x)</code> of current cursor position relative to the window’s upper-left corner.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.hline">
<code>window.hline(ch, n)</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">hline</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">ch</span></em>, <em class="sig-param"><span class="n">n</span></em><span class="sig-paren">)</span>
</dt> <dd>
<p>Display a horizontal line starting at <code>(y, x)</code> with length <em>n</em> consisting of the character <em>ch</em>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.idcok">
<code>window.idcok(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>False</code>, curses no longer considers using the hardware insert/delete character feature of the terminal; if <em>flag</em> is <code>True</code>, use of character insertion and deletion is enabled. When curses is first initialized, use of character insert/delete is enabled by default.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.idlok">
<code>window.idlok(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><code>curses</code></a> will try and use hardware line editing facilities. Otherwise, line insertion/deletion are disabled.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.immedok">
<code>window.immedok(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, any change in the window image automatically causes the window to be refreshed; you no longer have to call <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a> yourself. However, it may degrade performance considerably, due to repeated calls to wrefresh. This option is disabled by default.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.inch">
<code>window.inch([y, x])</code> </dt> <dd>
<p>Return the character at the given position in the window. The bottom 8 bits are the character proper, and upper bits are the attributes.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.insch">
<code>window.insch(ch[, attr])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">insch</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">ch</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">attr</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Paint character <em>ch</em> at <code>(y, x)</code> with attributes <em>attr</em>, moving the line from position <em>x</em> right by one character.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.insdelln">
<code>window.insdelln(nlines)</code> </dt> <dd>
<p>Insert <em>nlines</em> lines into the specified window above the current line. The <em>nlines</em> bottom lines are lost. For negative <em>nlines</em>, delete <em>nlines</em> lines starting with the one under the cursor, and move the remaining lines up. The bottom <em>nlines</em> lines are cleared. The current cursor position remains the same.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.insertln">
<code>window.insertln()</code> </dt> <dd>
<p>Insert a blank line under the cursor. All following lines are moved down by one line.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.insnstr">
<code>window.insnstr(str, n[, attr])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">insnstr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">str</span></em>, <em class="sig-param"><span class="n">n</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">attr</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Insert a character string (as many characters as will fit on the line) before the character under the cursor, up to <em>n</em> characters. If <em>n</em> is zero or negative, the entire string is inserted. All characters to the right of the cursor are shifted right, with the rightmost characters on the line being lost. The cursor position does not change (after moving to <em>y</em>, <em>x</em>, if specified).</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.insstr">
<code>window.insstr(str[, attr])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">insstr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">str</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">attr</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Insert a character string (as many characters as will fit on the line) before the character under the cursor. All characters to the right of the cursor are shifted right, with the rightmost characters on the line being lost. The cursor position does not change (after moving to <em>y</em>, <em>x</em>, if specified).</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.instr">
<code>window.instr([n])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">instr</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">n</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Return a bytes object of characters, extracted from the window starting at the current cursor position, or at <em>y</em>, <em>x</em> if specified. Attributes are stripped from the characters. If <em>n</em> is specified, <a class="reference internal" href="#curses.window.instr" title="curses.window.instr"><code>instr()</code></a> returns a string at most <em>n</em> characters long (exclusive of the trailing NUL).</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.is_linetouched">
<code>window.is_linetouched(line)</code> </dt> <dd>
<p>Return <code>True</code> if the specified line was modified since the last call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a>; otherwise return <code>False</code>. Raise a <a class="reference internal" href="#curses.error" title="curses.error"><code>curses.error</code></a> exception if <em>line</em> is not valid for the given window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.is_wintouched">
<code>window.is_wintouched()</code> </dt> <dd>
<p>Return <code>True</code> if the specified window was modified since the last call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a>; otherwise return <code>False</code>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.keypad">
<code>window.keypad(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, escape sequences generated by some keys (keypad, function keys) will be interpreted by <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><code>curses</code></a>. If <em>flag</em> is <code>False</code>, escape sequences will be left as is in the input stream.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.leaveok">
<code>window.leaveok(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, cursor is left where it is on update, instead of being at “cursor position.” This reduces cursor movement where possible. If possible the cursor will be made invisible.</p> <p>If <em>flag</em> is <code>False</code>, cursor will always be at “cursor position” after an update.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.move">
<code>window.move(new_y, new_x)</code> </dt> <dd>
<p>Move cursor to <code>(new_y, new_x)</code>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.mvderwin">
<code>window.mvderwin(y, x)</code> </dt> <dd>
<p>Move the window inside its parent window. The screen-relative parameters of the window are not changed. This routine is used to display different parts of the parent window at the same physical position on the screen.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.mvwin">
<code>window.mvwin(new_y, new_x)</code> </dt> <dd>
<p>Move the window so its upper-left corner is at <code>(new_y, new_x)</code>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.nodelay">
<code>window.nodelay(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><code>getch()</code></a> will be non-blocking.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.notimeout">
<code>window.notimeout(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, escape sequences will not be timed out.</p> <p>If <em>flag</em> is <code>False</code>, after a few milliseconds, an escape sequence will not be interpreted, and will be left in the input stream as is.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.noutrefresh">
<code>window.noutrefresh()</code> </dt> <dd>
<p>Mark for refresh but wait. This function updates the data structure representing the desired state of the window, but does not force an update of the physical screen. To accomplish that, call <a class="reference internal" href="#curses.doupdate" title="curses.doupdate"><code>doupdate()</code></a>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.overlay">
<code>window.overlay(destwin[, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])</code> </dt> <dd>
<p>Overlay the window on top of <em>destwin</em>. The windows need not be the same size, only the overlapping region is copied. This copy is non-destructive, which means that the current background character does not overwrite the old contents of <em>destwin</em>.</p> <p>To get fine-grained control over the copied region, the second form of <a class="reference internal" href="#curses.window.overlay" title="curses.window.overlay"><code>overlay()</code></a> can be used. <em>sminrow</em> and <em>smincol</em> are the upper-left coordinates of the source window, and the other variables mark a rectangle in the destination window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.overwrite">
<code>window.overwrite(destwin[, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])</code> </dt> <dd>
<p>Overwrite the window on top of <em>destwin</em>. The windows need not be the same size, in which case only the overlapping region is copied. This copy is destructive, which means that the current background character overwrites the old contents of <em>destwin</em>.</p> <p>To get fine-grained control over the copied region, the second form of <a class="reference internal" href="#curses.window.overwrite" title="curses.window.overwrite"><code>overwrite()</code></a> can be used. <em>sminrow</em> and <em>smincol</em> are the upper-left coordinates of the source window, the other variables mark a rectangle in the destination window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.putwin">
<code>window.putwin(file)</code> </dt> <dd>
<p>Write all data associated with the window into the provided file object. This information can be later retrieved using the <a class="reference internal" href="#curses.getwin" title="curses.getwin"><code>getwin()</code></a> function.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.redrawln">
<code>window.redrawln(beg, num)</code> </dt> <dd>
<p>Indicate that the <em>num</em> screen lines, starting at line <em>beg</em>, are corrupted and should be completely redrawn on the next <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a> call.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.redrawwin">
<code>window.redrawwin()</code> </dt> <dd>
<p>Touch the entire window, causing it to be completely redrawn on the next <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a> call.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.refresh">
<code>window.refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])</code> </dt> <dd>
<p>Update the display immediately (sync actual screen with previous drawing/deleting methods).</p> <p>The 6 optional arguments can only be specified when the window is a pad created with <a class="reference internal" href="#curses.newpad" title="curses.newpad"><code>newpad()</code></a>. The additional parameters are needed to indicate what part of the pad and screen are involved. <em>pminrow</em> and <em>pmincol</em> specify the upper left-hand corner of the rectangle to be displayed in the pad. <em>sminrow</em>, <em>smincol</em>, <em>smaxrow</em>, and <em>smaxcol</em> specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the rectangle to be displayed in the pad is calculated from the screen coordinates, since the rectangles must be the same size. Both rectangles must be entirely contained within their respective structures. Negative values of <em>pminrow</em>, <em>pmincol</em>, <em>sminrow</em>, or <em>smincol</em> are treated as if they were zero.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.resize">
<code>window.resize(nlines, ncols)</code> </dt> <dd>
<p>Reallocate storage for a curses window to adjust its dimensions to the specified values. If either dimension is larger than the current values, the window’s data is filled with blanks that have the current background rendition (as set by <a class="reference internal" href="#curses.window.bkgdset" title="curses.window.bkgdset"><code>bkgdset()</code></a>) merged into them.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.scroll">
<code>window.scroll([lines=1])</code> </dt> <dd>
<p>Scroll the screen or scrolling region upward by <em>lines</em> lines.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.scrollok">
<code>window.scrollok(flag)</code> </dt> <dd>
<p>Control what happens when the cursor of a window is moved off the edge of the window or scrolling region, either as a result of a newline action on the bottom line, or typing the last character of the last line. If <em>flag</em> is <code>False</code>, the cursor is left on the bottom line. If <em>flag</em> is <code>True</code>, the window is scrolled up one line. Note that in order to get the physical scrolling effect on the terminal, it is also necessary to call <a class="reference internal" href="#curses.window.idlok" title="curses.window.idlok"><code>idlok()</code></a>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.setscrreg">
<code>window.setscrreg(top, bottom)</code> </dt> <dd>
<p>Set the scrolling region from line <em>top</em> to line <em>bottom</em>. All scrolling actions will take place in this region.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.standend">
<code>window.standend()</code> </dt> <dd>
<p>Turn off the standout attribute. On some terminals this has the side effect of turning off all attributes.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.standout">
<code>window.standout()</code> </dt> <dd>
<p>Turn on attribute <em>A_STANDOUT</em>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.subpad">
<code>window.subpad(begin_y, begin_x)</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">subpad</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">nlines</span></em>, <em class="sig-param"><span class="n">ncols</span></em>, <em class="sig-param"><span class="n">begin_y</span></em>, <em class="sig-param"><span class="n">begin_x</span></em><span class="sig-paren">)</span>
</dt> <dd>
<p>Return a sub-window, whose upper-left corner is at <code>(begin_y, begin_x)</code>, and whose width/height is <em>ncols</em>/<em>nlines</em>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.subwin">
<code>window.subwin(begin_y, begin_x)</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">subwin</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">nlines</span></em>, <em class="sig-param"><span class="n">ncols</span></em>, <em class="sig-param"><span class="n">begin_y</span></em>, <em class="sig-param"><span class="n">begin_x</span></em><span class="sig-paren">)</span>
</dt> <dd>
<p>Return a sub-window, whose upper-left corner is at <code>(begin_y, begin_x)</code>, and whose width/height is <em>ncols</em>/<em>nlines</em>.</p> <p>By default, the sub-window will extend from the specified position to the lower right corner of the window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.syncdown">
<code>window.syncdown()</code> </dt> <dd>
<p>Touch each location in the window that has been touched in any of its ancestor windows. This routine is called by <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a>, so it should almost never be necessary to call it manually.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.syncok">
<code>window.syncok(flag)</code> </dt> <dd>
<p>If <em>flag</em> is <code>True</code>, then <a class="reference internal" href="#curses.window.syncup" title="curses.window.syncup"><code>syncup()</code></a> is called automatically whenever there is a change in the window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.syncup">
<code>window.syncup()</code> </dt> <dd>
<p>Touch all locations in ancestors of the window that have been changed in the window.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.timeout">
<code>window.timeout(delay)</code> </dt> <dd>
<p>Set blocking or non-blocking read behavior for the window. If <em>delay</em> is negative, blocking read is used (which will wait indefinitely for input). If <em>delay</em> is zero, then non-blocking read is used, and <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><code>getch()</code></a> will return <code>-1</code> if no input is waiting. If <em>delay</em> is positive, then <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><code>getch()</code></a> will block for <em>delay</em> milliseconds, and return <code>-1</code> if there is still no input at the end of that time.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.touchline">
<code>window.touchline(start, count[, changed])</code> </dt> <dd>
<p>Pretend <em>count</em> lines have been changed, starting with line <em>start</em>. If <em>changed</em> is supplied, it specifies whether the affected lines are marked as having been changed (<em>changed</em><code>=True</code>) or unchanged (<em>changed</em><code>=False</code>).</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.touchwin">
<code>window.touchwin()</code> </dt> <dd>
<p>Pretend the whole window has been changed, for purposes of drawing optimizations.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.untouchwin">
<code>window.untouchwin()</code> </dt> <dd>
<p>Mark all lines in the window as unchanged since the last call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><code>refresh()</code></a>.</p> </dd>
</dl> <dl class="py method"> <dt class="sig sig-object py" id="curses.window.vline">
<code>window.vline(ch, n[, attr])</code> </dt> <dt class="sig sig-object py"> <span class="sig-prename descclassname">window.</span><span class="sig-name descname">vline</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">ch</span></em>, <em class="sig-param"><span class="n">n</span></em><span class="optional">[</span>, <em class="sig-param"><span class="n">attr</span></em><span class="optional">]</span><span class="sig-paren">)</span>
</dt> <dd>
<p>Display a vertical line starting at <code>(y, x)</code> with length <em>n</em> consisting of the character <em>ch</em> with attributes <em>attr</em>.</p> </dd>
</dl> </section> <section id="constants"> <h2>Constants</h2> <p>The <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><code>curses</code></a> module defines the following data members:</p> <dl class="py data"> <dt class="sig sig-object py" id="curses.ERR">
<code>curses.ERR</code> </dt> <dd>
<p>Some curses routines that return an integer, such as <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><code>getch()</code></a>, return <a class="reference internal" href="#curses.ERR" title="curses.ERR"><code>ERR</code></a> upon failure.</p> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.OK">
<code>curses.OK</code> </dt> <dd>
<p>Some curses routines that return an integer, such as <a class="reference internal" href="#curses.napms" title="curses.napms"><code>napms()</code></a>, return <a class="reference internal" href="#curses.OK" title="curses.OK"><code>OK</code></a> upon success.</p> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.version">
<code>curses.version</code> </dt> <dd></dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.__version__">
<code>curses.__version__</code> </dt> <dd>
<p>A bytes object representing the current version of the module.</p> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.ncurses_version">
<code>curses.ncurses_version</code> </dt> <dd>
<p>A named tuple containing the three components of the ncurses library version: <em>major</em>, <em>minor</em>, and <em>patch</em>. All values are integers. The components can also be accessed by name, so <code>curses.ncurses_version[0]</code> is equivalent to <code>curses.ncurses_version.major</code> and so on.</p> <p>Availability: if the ncurses library is used.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.8.</span></p> </div> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.COLORS">
<code>curses.COLORS</code> </dt> <dd>
<p>The maximum number of colors the terminal can support. It is defined only after the call to <a class="reference internal" href="#curses.start_color" title="curses.start_color"><code>start_color()</code></a>.</p> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_PAIRS">
<code>curses.COLOR_PAIRS</code> </dt> <dd>
<p>The maximum number of color pairs the terminal can support. It is defined only after the call to <a class="reference internal" href="#curses.start_color" title="curses.start_color"><code>start_color()</code></a>.</p> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.COLS">
<code>curses.COLS</code> </dt> <dd>
<p>The width of the screen, i.e., the number of columns. It is defined only after the call to <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a>. Updated by <a class="reference internal" href="#curses.update_lines_cols" title="curses.update_lines_cols"><code>update_lines_cols()</code></a>, <a class="reference internal" href="#curses.resizeterm" title="curses.resizeterm"><code>resizeterm()</code></a> and <a class="reference internal" href="#curses.resize_term" title="curses.resize_term"><code>resize_term()</code></a>.</p> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="curses.LINES">
<code>curses.LINES</code> </dt> <dd>
<p>The height of the screen, i.e., the number of lines. It is defined only after the call to <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a>. Updated by <a class="reference internal" href="#curses.update_lines_cols" title="curses.update_lines_cols"><code>update_lines_cols()</code></a>, <a class="reference internal" href="#curses.resizeterm" title="curses.resizeterm"><code>resizeterm()</code></a> and <a class="reference internal" href="#curses.resize_term" title="curses.resize_term"><code>resize_term()</code></a>.</p> </dd>
</dl> <p>Some constants are available to specify character cell attributes. The exact constants available are system dependent.</p> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>Attribute</p></th> <th class="head"><p>Meaning</p></th> </tr> </thead> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_ALTCHARSET">
<code>curses.A_ALTCHARSET</code> </dt> <dd></dd>
</dl> </td> <td><p>Alternate character set mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_BLINK">
<code>curses.A_BLINK</code> </dt> <dd></dd>
</dl> </td> <td><p>Blink mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_BOLD">
<code>curses.A_BOLD</code> </dt> <dd></dd>
</dl> </td> <td><p>Bold mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_DIM">
<code>curses.A_DIM</code> </dt> <dd></dd>
</dl> </td> <td><p>Dim mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_INVIS">
<code>curses.A_INVIS</code> </dt> <dd></dd>
</dl> </td> <td><p>Invisible or blank mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_ITALIC">
<code>curses.A_ITALIC</code> </dt> <dd></dd>
</dl> </td> <td><p>Italic mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_NORMAL">
<code>curses.A_NORMAL</code> </dt> <dd></dd>
</dl> </td> <td><p>Normal attribute</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_PROTECT">
<code>curses.A_PROTECT</code> </dt> <dd></dd>
</dl> </td> <td><p>Protected mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_REVERSE">
<code>curses.A_REVERSE</code> </dt> <dd></dd>
</dl> </td> <td><p>Reverse background and foreground colors</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_STANDOUT">
<code>curses.A_STANDOUT</code> </dt> <dd></dd>
</dl> </td> <td><p>Standout mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_UNDERLINE">
<code>curses.A_UNDERLINE</code> </dt> <dd></dd>
</dl> </td> <td><p>Underline mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_HORIZONTAL">
<code>curses.A_HORIZONTAL</code> </dt> <dd></dd>
</dl> </td> <td><p>Horizontal highlight</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_LEFT">
<code>curses.A_LEFT</code> </dt> <dd></dd>
</dl> </td> <td><p>Left highlight</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_LOW">
<code>curses.A_LOW</code> </dt> <dd></dd>
</dl> </td> <td><p>Low highlight</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_RIGHT">
<code>curses.A_RIGHT</code> </dt> <dd></dd>
</dl> </td> <td><p>Right highlight</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_TOP">
<code>curses.A_TOP</code> </dt> <dd></dd>
</dl> </td> <td><p>Top highlight</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_VERTICAL">
<code>curses.A_VERTICAL</code> </dt> <dd></dd>
</dl> </td> <td><p>Vertical highlight</p></td> </tr> </table> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7: </span><code>A_ITALIC</code> was added.</p> </div> <p>Several constants are available to extract corresponding attributes returned by some methods.</p> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>Bit-mask</p></th> <th class="head"><p>Meaning</p></th> </tr> </thead> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_ATTRIBUTES">
<code>curses.A_ATTRIBUTES</code> </dt> <dd></dd>
</dl> </td> <td><p>Bit-mask to extract attributes</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_CHARTEXT">
<code>curses.A_CHARTEXT</code> </dt> <dd></dd>
</dl> </td> <td><p>Bit-mask to extract a character</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.A_COLOR">
<code>curses.A_COLOR</code> </dt> <dd></dd>
</dl> </td> <td><p>Bit-mask to extract color-pair field information</p></td> </tr> </table> <p>Keys are referred to by integer constants with names starting with <code>KEY_</code>. The exact keycaps available are system dependent.</p> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>Key constant</p></th> <th class="head"><p>Key</p></th> </tr> </thead> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_MIN">
<code>curses.KEY_MIN</code> </dt> <dd></dd>
</dl> </td> <td><p>Minimum key value</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_BREAK">
<code>curses.KEY_BREAK</code> </dt> <dd></dd>
</dl> </td> <td><p>Break key (unreliable)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_DOWN">
<code>curses.KEY_DOWN</code> </dt> <dd></dd>
</dl> </td> <td><p>Down-arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_UP">
<code>curses.KEY_UP</code> </dt> <dd></dd>
</dl> </td> <td><p>Up-arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_LEFT">
<code>curses.KEY_LEFT</code> </dt> <dd></dd>
</dl> </td> <td><p>Left-arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_RIGHT">
<code>curses.KEY_RIGHT</code> </dt> <dd></dd>
</dl> </td> <td><p>Right-arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_HOME">
<code>curses.KEY_HOME</code> </dt> <dd></dd>
</dl> </td> <td><p>Home key (upward+left arrow)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_BACKSPACE">
<code>curses.KEY_BACKSPACE</code> </dt> <dd></dd>
</dl> </td> <td><p>Backspace (unreliable)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_F0">
<code>curses.KEY_F0</code> </dt> <dd></dd>
</dl> </td> <td><p>Function keys. Up to 64 function keys are supported.</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_Fn">
<code>curses.KEY_Fn</code> </dt> <dd></dd>
</dl> </td> <td><p>Value of function key <em>n</em></p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_DL">
<code>curses.KEY_DL</code> </dt> <dd></dd>
</dl> </td> <td><p>Delete line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_IL">
<code>curses.KEY_IL</code> </dt> <dd></dd>
</dl> </td> <td><p>Insert line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_DC">
<code>curses.KEY_DC</code> </dt> <dd></dd>
</dl> </td> <td><p>Delete character</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_IC">
<code>curses.KEY_IC</code> </dt> <dd></dd>
</dl> </td> <td><p>Insert char or enter insert mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_EIC">
<code>curses.KEY_EIC</code> </dt> <dd></dd>
</dl> </td> <td><p>Exit insert char mode</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_CLEAR">
<code>curses.KEY_CLEAR</code> </dt> <dd></dd>
</dl> </td> <td><p>Clear screen</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_EOS">
<code>curses.KEY_EOS</code> </dt> <dd></dd>
</dl> </td> <td><p>Clear to end of screen</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_EOL">
<code>curses.KEY_EOL</code> </dt> <dd></dd>
</dl> </td> <td><p>Clear to end of line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SF">
<code>curses.KEY_SF</code> </dt> <dd></dd>
</dl> </td> <td><p>Scroll 1 line forward</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SR">
<code>curses.KEY_SR</code> </dt> <dd></dd>
</dl> </td> <td><p>Scroll 1 line backward (reverse)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_NPAGE">
<code>curses.KEY_NPAGE</code> </dt> <dd></dd>
</dl> </td> <td><p>Next page</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_PPAGE">
<code>curses.KEY_PPAGE</code> </dt> <dd></dd>
</dl> </td> <td><p>Previous page</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_STAB">
<code>curses.KEY_STAB</code> </dt> <dd></dd>
</dl> </td> <td><p>Set tab</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_CTAB">
<code>curses.KEY_CTAB</code> </dt> <dd></dd>
</dl> </td> <td><p>Clear tab</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_CATAB">
<code>curses.KEY_CATAB</code> </dt> <dd></dd>
</dl> </td> <td><p>Clear all tabs</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_ENTER">
<code>curses.KEY_ENTER</code> </dt> <dd></dd>
</dl> </td> <td><p>Enter or send (unreliable)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SRESET">
<code>curses.KEY_SRESET</code> </dt> <dd></dd>
</dl> </td> <td><p>Soft (partial) reset (unreliable)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_RESET">
<code>curses.KEY_RESET</code> </dt> <dd></dd>
</dl> </td> <td><p>Reset or hard reset (unreliable)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_PRINT">
<code>curses.KEY_PRINT</code> </dt> <dd></dd>
</dl> </td> <td><p>Print</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_LL">
<code>curses.KEY_LL</code> </dt> <dd></dd>
</dl> </td> <td><p>Home down or bottom (lower left)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_A1">
<code>curses.KEY_A1</code> </dt> <dd></dd>
</dl> </td> <td><p>Upper left of keypad</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_A3">
<code>curses.KEY_A3</code> </dt> <dd></dd>
</dl> </td> <td><p>Upper right of keypad</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_B2">
<code>curses.KEY_B2</code> </dt> <dd></dd>
</dl> </td> <td><p>Center of keypad</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_C1">
<code>curses.KEY_C1</code> </dt> <dd></dd>
</dl> </td> <td><p>Lower left of keypad</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_C3">
<code>curses.KEY_C3</code> </dt> <dd></dd>
</dl> </td> <td><p>Lower right of keypad</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_BTAB">
<code>curses.KEY_BTAB</code> </dt> <dd></dd>
</dl> </td> <td><p>Back tab</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_BEG">
<code>curses.KEY_BEG</code> </dt> <dd></dd>
</dl> </td> <td><p>Beg (beginning)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_CANCEL">
<code>curses.KEY_CANCEL</code> </dt> <dd></dd>
</dl> </td> <td><p>Cancel</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_CLOSE">
<code>curses.KEY_CLOSE</code> </dt> <dd></dd>
</dl> </td> <td><p>Close</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_COMMAND">
<code>curses.KEY_COMMAND</code> </dt> <dd></dd>
</dl> </td> <td><p>Cmd (command)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_COPY">
<code>curses.KEY_COPY</code> </dt> <dd></dd>
</dl> </td> <td><p>Copy</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_CREATE">
<code>curses.KEY_CREATE</code> </dt> <dd></dd>
</dl> </td> <td><p>Create</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_END">
<code>curses.KEY_END</code> </dt> <dd></dd>
</dl> </td> <td><p>End</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_EXIT">
<code>curses.KEY_EXIT</code> </dt> <dd></dd>
</dl> </td> <td><p>Exit</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_FIND">
<code>curses.KEY_FIND</code> </dt> <dd></dd>
</dl> </td> <td><p>Find</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_HELP">
<code>curses.KEY_HELP</code> </dt> <dd></dd>
</dl> </td> <td><p>Help</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_MARK">
<code>curses.KEY_MARK</code> </dt> <dd></dd>
</dl> </td> <td><p>Mark</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_MESSAGE">
<code>curses.KEY_MESSAGE</code> </dt> <dd></dd>
</dl> </td> <td><p>Message</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_MOVE">
<code>curses.KEY_MOVE</code> </dt> <dd></dd>
</dl> </td> <td><p>Move</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_NEXT">
<code>curses.KEY_NEXT</code> </dt> <dd></dd>
</dl> </td> <td><p>Next</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_OPEN">
<code>curses.KEY_OPEN</code> </dt> <dd></dd>
</dl> </td> <td><p>Open</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_OPTIONS">
<code>curses.KEY_OPTIONS</code> </dt> <dd></dd>
</dl> </td> <td><p>Options</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_PREVIOUS">
<code>curses.KEY_PREVIOUS</code> </dt> <dd></dd>
</dl> </td> <td><p>Prev (previous)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_REDO">
<code>curses.KEY_REDO</code> </dt> <dd></dd>
</dl> </td> <td><p>Redo</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_REFERENCE">
<code>curses.KEY_REFERENCE</code> </dt> <dd></dd>
</dl> </td> <td><p>Ref (reference)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_REFRESH">
<code>curses.KEY_REFRESH</code> </dt> <dd></dd>
</dl> </td> <td><p>Refresh</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_REPLACE">
<code>curses.KEY_REPLACE</code> </dt> <dd></dd>
</dl> </td> <td><p>Replace</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_RESTART">
<code>curses.KEY_RESTART</code> </dt> <dd></dd>
</dl> </td> <td><p>Restart</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_RESUME">
<code>curses.KEY_RESUME</code> </dt> <dd></dd>
</dl> </td> <td><p>Resume</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SAVE">
<code>curses.KEY_SAVE</code> </dt> <dd></dd>
</dl> </td> <td><p>Save</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SBEG">
<code>curses.KEY_SBEG</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Beg (beginning)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SCANCEL">
<code>curses.KEY_SCANCEL</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Cancel</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SCOMMAND">
<code>curses.KEY_SCOMMAND</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Command</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SCOPY">
<code>curses.KEY_SCOPY</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Copy</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SCREATE">
<code>curses.KEY_SCREATE</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Create</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SDC">
<code>curses.KEY_SDC</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Delete char</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SDL">
<code>curses.KEY_SDL</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Delete line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SELECT">
<code>curses.KEY_SELECT</code> </dt> <dd></dd>
</dl> </td> <td><p>Select</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SEND">
<code>curses.KEY_SEND</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted End</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SEOL">
<code>curses.KEY_SEOL</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Clear line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SEXIT">
<code>curses.KEY_SEXIT</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Exit</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SFIND">
<code>curses.KEY_SFIND</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Find</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SHELP">
<code>curses.KEY_SHELP</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Help</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SHOME">
<code>curses.KEY_SHOME</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Home</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SIC">
<code>curses.KEY_SIC</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Input</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SLEFT">
<code>curses.KEY_SLEFT</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Left arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SMESSAGE">
<code>curses.KEY_SMESSAGE</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Message</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SMOVE">
<code>curses.KEY_SMOVE</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Move</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SNEXT">
<code>curses.KEY_SNEXT</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Next</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SOPTIONS">
<code>curses.KEY_SOPTIONS</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Options</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SPREVIOUS">
<code>curses.KEY_SPREVIOUS</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Prev</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SPRINT">
<code>curses.KEY_SPRINT</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Print</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SREDO">
<code>curses.KEY_SREDO</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Redo</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SREPLACE">
<code>curses.KEY_SREPLACE</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Replace</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SRIGHT">
<code>curses.KEY_SRIGHT</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Right arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SRSUME">
<code>curses.KEY_SRSUME</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Resume</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SSAVE">
<code>curses.KEY_SSAVE</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Save</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SSUSPEND">
<code>curses.KEY_SSUSPEND</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Suspend</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SUNDO">
<code>curses.KEY_SUNDO</code> </dt> <dd></dd>
</dl> </td> <td><p>Shifted Undo</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_SUSPEND">
<code>curses.KEY_SUSPEND</code> </dt> <dd></dd>
</dl> </td> <td><p>Suspend</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_UNDO">
<code>curses.KEY_UNDO</code> </dt> <dd></dd>
</dl> </td> <td><p>Undo</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_MOUSE">
<code>curses.KEY_MOUSE</code> </dt> <dd></dd>
</dl> </td> <td><p>Mouse event has occurred</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_RESIZE">
<code>curses.KEY_RESIZE</code> </dt> <dd></dd>
</dl> </td> <td><p>Terminal resize event</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.KEY_MAX">
<code>curses.KEY_MAX</code> </dt> <dd></dd>
</dl> </td> <td><p>Maximum key value</p></td> </tr> </table> <p>On VT100s and their software emulations, such as X terminal emulators, there are normally at least four function keys (<a class="reference internal" href="#curses.KEY_Fn" title="curses.KEY_Fn"><code>KEY_F1</code></a>, <a class="reference internal" href="#curses.KEY_Fn" title="curses.KEY_Fn"><code>KEY_F2</code></a>, <a class="reference internal" href="#curses.KEY_Fn" title="curses.KEY_Fn"><code>KEY_F3</code></a>, <a class="reference internal" href="#curses.KEY_Fn" title="curses.KEY_Fn"><code>KEY_F4</code></a>) available, and the arrow keys mapped to <a class="reference internal" href="#curses.KEY_UP" title="curses.KEY_UP"><code>KEY_UP</code></a>, <a class="reference internal" href="#curses.KEY_DOWN" title="curses.KEY_DOWN"><code>KEY_DOWN</code></a>, <a class="reference internal" href="#curses.KEY_LEFT" title="curses.KEY_LEFT"><code>KEY_LEFT</code></a> and <a class="reference internal" href="#curses.KEY_RIGHT" title="curses.KEY_RIGHT"><code>KEY_RIGHT</code></a> in the obvious way. If your machine has a PC keyboard, it is safe to expect arrow keys and twelve function keys (older PC keyboards may have only ten function keys); also, the following keypad mappings are standard:</p> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>Keycap</p></th> <th class="head"><p>Constant</p></th> </tr> </thead> <tr>
<td><p><kbd class="kbd docutils literal notranslate">Insert</kbd></p></td> <td><p>KEY_IC</p></td> </tr> <tr>
<td><p><kbd class="kbd docutils literal notranslate">Delete</kbd></p></td> <td><p>KEY_DC</p></td> </tr> <tr>
<td><p><kbd class="kbd docutils literal notranslate">Home</kbd></p></td> <td><p>KEY_HOME</p></td> </tr> <tr>
<td><p><kbd class="kbd docutils literal notranslate">End</kbd></p></td> <td><p>KEY_END</p></td> </tr> <tr>
<td><p><kbd class="kbd docutils literal notranslate">Page Up</kbd></p></td> <td><p>KEY_PPAGE</p></td> </tr> <tr>
<td><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Page</kbd> <kbd class="kbd docutils literal notranslate">Down</kbd></kbd></p></td> <td><p>KEY_NPAGE</p></td> </tr> </table> <p id="curses-acs-codes">The following table lists characters from the alternate character set. These are inherited from the VT100 terminal, and will generally be available on software emulations such as X terminals. When there is no graphic available, curses falls back on a crude printable ASCII approximation.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>These are available only after <a class="reference internal" href="#curses.initscr" title="curses.initscr"><code>initscr()</code></a> has been called.</p> </div> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>ACS code</p></th> <th class="head"><p>Meaning</p></th> </tr> </thead> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BBSS">
<code>curses.ACS_BBSS</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for upper right corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BLOCK">
<code>curses.ACS_BLOCK</code> </dt> <dd></dd>
</dl> </td> <td><p>solid square block</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BOARD">
<code>curses.ACS_BOARD</code> </dt> <dd></dd>
</dl> </td> <td><p>board of squares</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BSBS">
<code>curses.ACS_BSBS</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for horizontal line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BSSB">
<code>curses.ACS_BSSB</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for upper left corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BSSS">
<code>curses.ACS_BSSS</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for top tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BTEE">
<code>curses.ACS_BTEE</code> </dt> <dd></dd>
</dl> </td> <td><p>bottom tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_BULLET">
<code>curses.ACS_BULLET</code> </dt> <dd></dd>
</dl> </td> <td><p>bullet</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_CKBOARD">
<code>curses.ACS_CKBOARD</code> </dt> <dd></dd>
</dl> </td> <td><p>checker board (stipple)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_DARROW">
<code>curses.ACS_DARROW</code> </dt> <dd></dd>
</dl> </td> <td><p>arrow pointing down</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_DEGREE">
<code>curses.ACS_DEGREE</code> </dt> <dd></dd>
</dl> </td> <td><p>degree symbol</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_DIAMOND">
<code>curses.ACS_DIAMOND</code> </dt> <dd></dd>
</dl> </td> <td><p>diamond</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_GEQUAL">
<code>curses.ACS_GEQUAL</code> </dt> <dd></dd>
</dl> </td> <td><p>greater-than-or-equal-to</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_HLINE">
<code>curses.ACS_HLINE</code> </dt> <dd></dd>
</dl> </td> <td><p>horizontal line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_LANTERN">
<code>curses.ACS_LANTERN</code> </dt> <dd></dd>
</dl> </td> <td><p>lantern symbol</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_LARROW">
<code>curses.ACS_LARROW</code> </dt> <dd></dd>
</dl> </td> <td><p>left arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_LEQUAL">
<code>curses.ACS_LEQUAL</code> </dt> <dd></dd>
</dl> </td> <td><p>less-than-or-equal-to</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_LLCORNER">
<code>curses.ACS_LLCORNER</code> </dt> <dd></dd>
</dl> </td> <td><p>lower left-hand corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_LRCORNER">
<code>curses.ACS_LRCORNER</code> </dt> <dd></dd>
</dl> </td> <td><p>lower right-hand corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_LTEE">
<code>curses.ACS_LTEE</code> </dt> <dd></dd>
</dl> </td> <td><p>left tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_NEQUAL">
<code>curses.ACS_NEQUAL</code> </dt> <dd></dd>
</dl> </td> <td><p>not-equal sign</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_PI">
<code>curses.ACS_PI</code> </dt> <dd></dd>
</dl> </td> <td><p>letter pi</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_PLMINUS">
<code>curses.ACS_PLMINUS</code> </dt> <dd></dd>
</dl> </td> <td><p>plus-or-minus sign</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_PLUS">
<code>curses.ACS_PLUS</code> </dt> <dd></dd>
</dl> </td> <td><p>big plus sign</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_RARROW">
<code>curses.ACS_RARROW</code> </dt> <dd></dd>
</dl> </td> <td><p>right arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_RTEE">
<code>curses.ACS_RTEE</code> </dt> <dd></dd>
</dl> </td> <td><p>right tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_S1">
<code>curses.ACS_S1</code> </dt> <dd></dd>
</dl> </td> <td><p>scan line 1</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_S3">
<code>curses.ACS_S3</code> </dt> <dd></dd>
</dl> </td> <td><p>scan line 3</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_S7">
<code>curses.ACS_S7</code> </dt> <dd></dd>
</dl> </td> <td><p>scan line 7</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_S9">
<code>curses.ACS_S9</code> </dt> <dd></dd>
</dl> </td> <td><p>scan line 9</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_SBBS">
<code>curses.ACS_SBBS</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for lower right corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_SBSB">
<code>curses.ACS_SBSB</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for vertical line</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_SBSS">
<code>curses.ACS_SBSS</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for right tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_SSBB">
<code>curses.ACS_SSBB</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for lower left corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_SSBS">
<code>curses.ACS_SSBS</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for bottom tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_SSSB">
<code>curses.ACS_SSSB</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for left tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_SSSS">
<code>curses.ACS_SSSS</code> </dt> <dd></dd>
</dl> </td> <td><p>alternate name for crossover or big plus</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_STERLING">
<code>curses.ACS_STERLING</code> </dt> <dd></dd>
</dl> </td> <td><p>pound sterling</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_TTEE">
<code>curses.ACS_TTEE</code> </dt> <dd></dd>
</dl> </td> <td><p>top tee</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_UARROW">
<code>curses.ACS_UARROW</code> </dt> <dd></dd>
</dl> </td> <td><p>up arrow</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_ULCORNER">
<code>curses.ACS_ULCORNER</code> </dt> <dd></dd>
</dl> </td> <td><p>upper left corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_URCORNER">
<code>curses.ACS_URCORNER</code> </dt> <dd></dd>
</dl> </td> <td><p>upper right corner</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.ACS_VLINE">
<code>curses.ACS_VLINE</code> </dt> <dd></dd>
</dl> </td> <td><p>vertical line</p></td> </tr> </table> <p>The following table lists mouse button constants used by <a class="reference internal" href="#curses.getmouse" title="curses.getmouse"><code>getmouse()</code></a>:</p> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>Mouse button constant</p></th> <th class="head"><p>Meaning</p></th> </tr> </thead> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTONn_PRESSED">
<code>curses.BUTTONn_PRESSED</code> </dt> <dd></dd>
</dl> </td> <td><p>Mouse button <em>n</em> pressed</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTONn_RELEASED">
<code>curses.BUTTONn_RELEASED</code> </dt> <dd></dd>
</dl> </td> <td><p>Mouse button <em>n</em> released</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTONn_CLICKED">
<code>curses.BUTTONn_CLICKED</code> </dt> <dd></dd>
</dl> </td> <td><p>Mouse button <em>n</em> clicked</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTONn_DOUBLE_CLICKED">
<code>curses.BUTTONn_DOUBLE_CLICKED</code> </dt> <dd></dd>
</dl> </td> <td><p>Mouse button <em>n</em> double clicked</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTONn_TRIPLE_CLICKED">
<code>curses.BUTTONn_TRIPLE_CLICKED</code> </dt> <dd></dd>
</dl> </td> <td><p>Mouse button <em>n</em> triple clicked</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTON_SHIFT">
<code>curses.BUTTON_SHIFT</code> </dt> <dd></dd>
</dl> </td> <td><p>Shift was down during button state change</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTON_CTRL">
<code>curses.BUTTON_CTRL</code> </dt> <dd></dd>
</dl> </td> <td><p>Control was down during button state change</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.BUTTON_ALT">
<code>curses.BUTTON_ALT</code> </dt> <dd></dd>
</dl> </td> <td><p>Control was down during button state change</p></td> </tr> </table> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.10: </span>The <code>BUTTON5_*</code> constants are now exposed if they are provided by the underlying curses library.</p> </div> <p>The following table lists the predefined colors:</p> <table class="docutils align-default"> <thead> <tr>
<th class="head"><p>Constant</p></th> <th class="head"><p>Color</p></th> </tr> </thead> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_BLACK">
<code>curses.COLOR_BLACK</code> </dt> <dd></dd>
</dl> </td> <td><p>Black</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_BLUE">
<code>curses.COLOR_BLUE</code> </dt> <dd></dd>
</dl> </td> <td><p>Blue</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_CYAN">
<code>curses.COLOR_CYAN</code> </dt> <dd></dd>
</dl> </td> <td><p>Cyan (light greenish blue)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_GREEN">
<code>curses.COLOR_GREEN</code> </dt> <dd></dd>
</dl> </td> <td><p>Green</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_MAGENTA">
<code>curses.COLOR_MAGENTA</code> </dt> <dd></dd>
</dl> </td> <td><p>Magenta (purplish red)</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_RED">
<code>curses.COLOR_RED</code> </dt> <dd></dd>
</dl> </td> <td><p>Red</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_WHITE">
<code>curses.COLOR_WHITE</code> </dt> <dd></dd>
</dl> </td> <td><p>White</p></td> </tr> <tr>
<td>
<dl class="py data"> <dt class="sig sig-object py" id="curses.COLOR_YELLOW">
<code>curses.COLOR_YELLOW</code> </dt> <dd></dd>
</dl> </td> <td><p>Yellow</p></td> </tr> </table> </section> <div class="_attribution">
<p class="_attribution-p">
© 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br>
<a href="https://docs.python.org/3.12/library/curses.html" class="_attribution-link">https://docs.python.org/3.12/library/curses.html</a>
</p>
</div>
|