【发布时间】:2023-07-21 19:36:01
【问题描述】:
我尝试了很多方法试图使文本保持在其边界内,但我找不到方法。以下是我已经尝试过的。
#!/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()
【问题讨论】: