[英]How do I access curscr in Python curses?
When using curses in Python, I know how to use stdscr
which is returned by curses.initscr()
. 在Python中使用curses时,我知道如何使用
curses.initscr()
返回的stdscr
。 How do I access curscr
which holds the current screen image? 如何访问保存当前屏幕图像的
curscr
?
Background: I have several (overlapping) windows. 背景:我有几个(重叠)窗口。 To make them look nice, I added shadows.
为了使它们看起来不错,我添加了阴影。 For even more candy I wanted the shadow to be a black and white version of the underlying text, so I need to get the text my window shadow is covering.
为了获得更多的糖果,我希望阴影是基础文本的黑白版本,因此我需要获取窗口阴影覆盖的文本。 If I use
stdscr.inch(y, x)
, I get all blanks, since my stdscr
is empty (everything is displayed using windows). 如果我使用
stdscr.inch(y, x)
, stdscr.inch(y, x)
得到所有空格,因为我的stdscr
是空的(所有内容都使用Windows显示)。
The ncurses C API contains curscr
, which I believe solves my problem. ncurses C API包含
curscr
,我相信它可以解决我的问题。 The only other solution for the moment would be to keep track of all existing windows (which I already wrapped in python classes) and in case I need to get a character from the screen, iterate through all known windows and check if they intersect my test point (adding more complexity because I would need to implement Z axis management, too). 目前唯一的其他解决方案是跟踪所有现有的窗口(我已经将它们包装在python类中),以防万一我需要从屏幕上获取字符,请遍历所有已知的窗口并检查它们是否与我的测试相交点(增加了更多的复杂度,因为我也需要实现Z轴管理)。
How it looks like at the moment (notice how the white context menu overlaps the bus node windows not using the correct attributes for lower left/upper right corners): 此刻的外观(注意白色上下文菜单如何与总线节点窗口重叠,而左下角/右上角未使用正确的属性):
尽管我没有找到使用curscr
的解决方案,但我实现了自己的窗口管理器类,该类负责正确的刷新顺序,不需要使用curscr
进行正确的重叠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.