【问题标题】:window.delch() for virtual screenwindow.delch() 用于虚拟屏幕
【发布时间】:2016-01-20 22:41:19
【问题描述】:

当我在curses,python中使用window.delch(y, x)时,删除会发生在屏幕上,而不是虚拟屏幕上,也就是说即使我不调用window,字符也会被删除。刷新()。为什么会这样,我如何只删除虚拟屏幕上的角色?

【问题讨论】:

    标签: python python-curses


    【解决方案1】:

    如果您可以提供一些重现您的问题的示例代码,那将会很有帮助。据我所知,Windows 的行为是 delch() 在调用 refresh() 之前不会更新屏幕。请参阅我的示例代码,它演示了这一点:

    import curses
    import time
    
    stdscr = curses.initscr()
    curses.noecho()
    curses.cbreak()
    stdscr.keypad(True)
    
    stdscr.addch(1, 1, ord('a'))
    time.sleep(1)
    stdscr.refresh()
    stdscr.delch(1, 1)
    time.sleep(3)
    stdscr.refresh()
    time.sleep(1)
    
    curses.echo()
    curses.nocbreak()
    stdscr.keypad(False)
    curses.endwin()
    

    【讨论】:

    • 明天我会添加一个示例代码,我已经解决了这个问题,但现在代码有点难看。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多