本文介绍了为什么我的诅咒盒不抽奖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在玩弄诅咒,但无法在屏幕上画一个盒子。
我创建了可以使用的边框,但是我想在边框中画一个框
I am toying with curses and I can't get a box to draw on the screen.I created a border which works but I want to draw a box in the border
这是我的代码
import curses
screen = curses.initscr()
try:
screen.border(0)
box1 = curses.newwin(20, 20, 5, 5)
box1.box()
screen.getch()
finally:
curses.endwin()
有什么建议吗?
推荐答案
来自:
因此,curses要求您使用窗口对象的 refresh()方法明确地告诉它重绘窗口。 ...
Accordingly, curses requires that you explicitly tell it to redraw windows, using the refresh() method of window objects. ...
您需要 screen.refresh()
和 box1 .refresh()
正确的顺序。
工作示例
#!/usr/bin/env python
import curses
screen = curses.initscr()
try:
screen.border(0)
box1 = curses.newwin(20, 20, 5, 5)
box1.box()
screen.refresh()
box1.refresh()
screen.getch()
finally:
curses.endwin()
或
#!/usr/bin/env python
import curses
screen = curses.initscr()
try:
screen.border(0)
screen.refresh()
box1 = curses.newwin(20, 20, 5, 5)
box1.box()
box1.refresh()
screen.getch()
finally:
curses.endwin()
您可以使用 immedok(True)
自动刷新窗口
You can use immedok(True)
to automatically refresh window
#!/usr/bin/env python
import curses
screen = curses.initscr()
screen.immedok(True)
try:
screen.border(0)
box1 = curses.newwin(20, 20, 5, 5)
box1.immedok(True)
box1.box()
box1.addstr("Hello World of Curses!")
screen.getch()
finally:
curses.endwin()
这篇关于为什么我的诅咒盒不抽奖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!