7
7
msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
- "POT-Creation-Date : 2024-04-16 00:03 +0000\n "
10
+ "POT-Creation-Date : 2024-09-09 16:09 +0000\n "
11
11
"PO-Revision-Date : 2018-05-23 14:36+0000\n "
12
12
"
Last-Translator :
Adrian Liaw <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -141,20 +141,34 @@ msgid ""
141
141
"after the name of the corresponding C variable. ::"
142
142
msgstr ""
143
143
144
+ #: ../../howto/curses.rst:90
145
+ msgid ""
146
+ "import curses\n"
147
+ "stdscr = curses.initscr()"
148
+ msgstr ""
149
+
144
150
#: ../../howto/curses.rst:93
145
151
msgid ""
146
152
"Usually curses applications turn off automatic echoing of keys to the "
147
153
"screen, in order to be able to read keys and only display them under certain "
148
154
"circumstances. This requires calling the :func:`~curses.noecho` function. ::"
149
155
msgstr ""
150
156
157
+ #: ../../howto/curses.rst:98
158
+ msgid "curses.noecho()"
159
+ msgstr ""
160
+
151
161
#: ../../howto/curses.rst:100
152
162
msgid ""
153
163
"Applications will also commonly need to react to keys instantly, without "
154
164
"requiring the Enter key to be pressed; this is called cbreak mode, as "
155
165
"opposed to the usual buffered input mode. ::"
156
166
msgstr ""
157
167
168
+ #: ../../howto/curses.rst:104
169
+ msgid "curses.cbreak()"
170
+ msgstr ""
171
+
158
172
#: ../../howto/curses.rst:106
159
173
msgid ""
160
174
"Terminals usually return special keys, such as the cursor keys or navigation "
@@ -165,19 +179,34 @@ msgid ""
165
179
"keypad mode. ::"
166
180
msgstr ""
167
181
182
+ #: ../../howto/curses.rst:113
183
+ msgid "stdscr.keypad(True)"
184
+ msgstr ""
185
+
168
186
#: ../../howto/curses.rst:115
169
187
msgid ""
170
188
"Terminating a curses application is much easier than starting one. You'll "
171
189
"need to call::"
172
190
msgstr ""
173
191
192
+ #: ../../howto/curses.rst:118
193
+ msgid ""
194
+ "curses.nocbreak()\n"
195
+ "stdscr.keypad(False)\n"
196
+ "curses.echo()"
197
+ msgstr ""
198
+
174
199
#: ../../howto/curses.rst:122
175
200
msgid ""
176
201
"to reverse the curses-friendly terminal settings. Then call the :func:"
177
202
"`~curses.endwin` function to restore the terminal to its original operating "
178
203
"mode. ::"
179
204
msgstr ""
180
205
206
+ #: ../../howto/curses.rst:126
207
+ msgid "curses.endwin()"
208
+ msgstr ""
209
+
181
210
#: ../../howto/curses.rst:128
182
211
msgid ""
183
212
"A common problem when debugging a curses application is to get your terminal "
@@ -193,6 +222,25 @@ msgid ""
193
222
"by importing the :func:`curses.wrapper` function and using it like this::"
194
223
msgstr ""
195
224
225
+ #: ../../howto/curses.rst:137
226
+ msgid ""
227
+ "from curses import wrapper\n"
228
+ "\n"
229
+ "def main(stdscr):\n"
230
+ " # Clear screen\n"
231
+ " stdscr.clear()\n"
232
+ "\n"
233
+ " # This raises ZeroDivisionError when i == 10.\n"
234
+ " for i in range(0, 11):\n"
235
+ " v = i-10\n"
236
+ " stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))\n"
237
+ "\n"
238
+ " stdscr.refresh()\n"
239
+ " stdscr.getkey()\n"
240
+ "\n"
241
+ "wrapper(main)"
242
+ msgstr ""
243
+
196
244
#: ../../howto/curses.rst:153
197
245
msgid ""
198
246
"The :func:`~curses.wrapper` function takes a callable object and does the "
@@ -227,6 +275,13 @@ msgid ""
227
275
"window object. ::"
228
276
msgstr ""
229
277
278
+ #: ../../howto/curses.rst:178
279
+ msgid ""
280
+ "begin_x = 20; begin_y = 7\n"
281
+ "height = 5; width = 40\n"
282
+ "win = curses.newwin(height, width, begin_y, begin_x)"
283
+ msgstr ""
284
+
230
285
#: ../../howto/curses.rst:182
231
286
msgid ""
232
287
"Note that the coordinate system used in curses is unusual. Coordinates are "
@@ -282,6 +337,24 @@ msgid ""
282
337
"will be displayed. ::"
283
338
msgstr ""
284
339
340
+ #: ../../howto/curses.rst:223
341
+ msgid ""
342
+ "pad = curses.newpad(100, 100)\n"
343
+ "# These loops fill the pad with letters; addch() is\n"
344
+ "# explained in the next section\n"
345
+ "for y in range(0, 99):\n"
346
+ " for x in range(0, 99):\n"
347
+ " pad.addch(y,x, ord('a') + (x*x+y*y) % 26)\n"
348
+ "\n"
349
+ "# Displays a section of the pad in the middle of the screen.\n"
350
+ "# (0,0) : coordinate of upper-left corner of pad area to display.\n"
351
+ "# (5,5) : coordinate of upper-left corner of window area to be filled\n"
352
+ "# with pad content.\n"
353
+ "# (20, 75) : coordinate of lower-right corner of window area to be\n"
354
+ "# : filled with pad content.\n"
355
+ "pad.refresh( 0,0, 5,5, 20,75)"
356
+ msgstr ""
357
+
285
358
#: ../../howto/curses.rst:238
286
359
msgid ""
287
360
"The :meth:`!refresh` call displays a section of the pad in the rectangle "
@@ -515,6 +588,13 @@ msgid ""
515
588
"you could code::"
516
589
msgstr ""
517
590
591
+ #: ../../howto/curses.rst:364
592
+ msgid ""
593
+ "stdscr.addstr(0, 0, \" Current mode: Typing mode\" ,\n"
594
+ " curses.A_REVERSE)\n"
595
+ "stdscr.refresh()"
596
+ msgstr ""
597
+
518
598
#: ../../howto/curses.rst:368
519
599
msgid ""
520
600
"The curses library also supports color on those terminals that provide it. "
@@ -548,6 +628,12 @@ msgstr ""
548
628
msgid "An example, which displays a line of text using color pair 1::"
549
629
msgstr ""
550
630
631
+ #: ../../howto/curses.rst:391
632
+ msgid ""
633
+ "stdscr.addstr(\" Pretty text\" , curses.color_pair(1))\n"
634
+ "stdscr.refresh()"
635
+ msgstr ""
636
+
551
637
#: ../../howto/curses.rst:394
552
638
msgid ""
553
639
"As I said before, a color pair consists of a foreground and background "
@@ -571,13 +657,21 @@ msgid ""
571
657
"background, you would call::"
572
658
msgstr ""
573
659
660
+ #: ../../howto/curses.rst:408
661
+ msgid "curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)"
662
+ msgstr ""
663
+
574
664
#: ../../howto/curses.rst:410
575
665
msgid ""
576
666
"When you change a color pair, any text already displayed using that color "
577
667
"pair will change to the new colors. You can also display new text in this "
578
668
"color with::"
579
669
msgstr ""
580
670
671
+ #: ../../howto/curses.rst:414
672
+ msgid "stdscr.addstr(0,0, \" RED ALERT!\" , curses.color_pair(1))"
673
+ msgstr ""
674
+
581
675
#: ../../howto/curses.rst:416
582
676
msgid ""
583
677
"Very fancy terminals can change the definitions of the actual colors to a "
@@ -643,6 +737,18 @@ msgid ""
643
737
"program may look something like this::"
644
738
msgstr ""
645
739
740
+ #: ../../howto/curses.rst:462
741
+ msgid ""
742
+ "while True:\n"
743
+ " c = stdscr.getch()\n"
744
+ " if c == ord('p'):\n"
745
+ " PrintDocument()\n"
746
+ " elif c == ord('q'):\n"
747
+ " break # Exit the while loop\n"
748
+ " elif c == curses.KEY_HOME:\n"
749
+ " x = y = 0"
750
+ msgstr ""
751
+
646
752
#: ../../howto/curses.rst:471
647
753
msgid ""
648
754
"The :mod:`curses.ascii` module supplies ASCII class membership functions "
@@ -662,6 +768,14 @@ msgid ""
662
768
"number of characters. ::"
663
769
msgstr ""
664
770
771
+ #: ../../howto/curses.rst:484
772
+ msgid ""
773
+ "curses.echo() # Enable echoing of characters\n"
774
+ "\n"
775
+ "# Get a 15-character string, with the cursor on the top line\n"
776
+ "s = stdscr.getstr(0,0, 15)"
777
+ msgstr ""
778
+
665
779
#: ../../howto/curses.rst:489
666
780
msgid ""
667
781
"The :mod:`curses.textpad` module supplies a text box that supports an Emacs-"
@@ -670,6 +784,27 @@ msgid ""
670
784
"results either with or without trailing spaces. Here's an example::"
671
785
msgstr ""
672
786
787
+ #: ../../howto/curses.rst:495
788
+ msgid ""
789
+ "import curses\n"
790
+ "from curses.textpad import Textbox, rectangle\n"
791
+ "\n"
792
+ "def main(stdscr):\n"
793
+ " stdscr.addstr(0, 0, \" Enter IM message: (hit Ctrl-G to send)\" )\n"
794
+ "\n"
795
+ " editwin = curses.newwin(5,30, 2,1)\n"
796
+ " rectangle(stdscr, 1,0, 1+5+1, 1+30+1)\n"
797
+ " stdscr.refresh()\n"
798
+ "\n"
799
+ " box = Textbox(editwin)\n"
800
+ "\n"
801
+ " # Let the user edit until Ctrl-G is struck.\n"
802
+ " box.edit()\n"
803
+ "\n"
804
+ " # Get resulting contents\n"
805
+ " message = box.gather()"
806
+ msgstr ""
807
+
673
808
#: ../../howto/curses.rst:513
674
809
msgid ""
675
810
"See the library documentation on :mod:`curses.textpad` for more details."
0 commit comments