私はテキストをその枠の内側にとどめようと多くのことを試みましたが、私は道を見つけることができません。以下は私がすでに試したことです。Pythonの内部でテキストを収縮させるにはどうすればよいですか?
#!/usr/bin/env python
import curses
import textwrap
screen = curses.initscr()
screen.immedok(True)
try:
screen.border(0)
box1 = curses.newwin(20, 40, 6, 50)
box1.immedok(True)
text = "I want all of this text to stay inside its box. Why does it keep going outside its borders?"
box1.box()
box1.addstr(1, 0, textwrap.fill(text, 39))
#box1.addstr("Hello World of Curses!")
screen.getch()
finally:
curses.endwin()
注.derwin'サブウィンドウを作成して、おそらくそれを実行するより良い方法です。私の写真があります。コインを反転:) – larsks