python-curses

I need an example of overlapping curses windows using panels in python

做~自己de王妃 提交于 2019-12-06 11:59:15
I'm looking for an example on how to use curses.panel to maintain overlapping windows. Mark Lakata I found this one here https://mail.python.org/pipermail/python-list/2001-April/105015.html . It moves one panel around the screen, below another panel. from time import sleep import curses, curses.panel def make_panel(h,l, y,x, str): win = curses.newwin(h,l, y,x) win.erase() win.box() win.addstr(2, 2, str) panel = curses.panel.new_panel(win) return win, panel def test(stdscr): try: curses.curs_set(0) except: pass stdscr.box() stdscr.addstr(2, 2, "panels everywhere") win1, panel1 = make_panel(10

Standard keys functions in curses module

戏子无情 提交于 2019-12-06 01:59:26
Have a simple program: import curses import time window = curses.initscr() curses.cbreak() window.nodelay(True) while True: key = window.getch() if key != -1: print key time.sleep(0.01) curses.endwin() How can i turn on mode that doesn't ignore standart Enter, Backspace and Arrows keys functions? or only the way is to add all special characters to elif: if event == curses.KEY_DOWN: #key down function I'm trying modes curses.raw() and other, but there no effect... Please add example if you can. Here is an example that allows you to keep backspace (keep in mind ASCII code for backspace is 127):

Why does the escape key have a delay in Python curses?

眉间皱痕 提交于 2019-12-05 01:36:43
In the Python curses module, I have observed that there is a roughly 1-second delay between pressing the esc key and getch() returning. This delay does not seem to occur for other keys. Why does this happen and what can I do about it? Test case: import curses import time def get_delay(window, key): while True: start = time.time() ch = window.getch() end = time.time() if ch == key: return end-start def main(stdscr): stdscr.clear() stdscr.nodelay(1) stdscr.addstr("Press ESC") esc_delay = get_delay(stdscr, 27) stdscr.addstr("\nPress SPACE") space_delay = get_delay(stdscr, ord(' ')) return esc

Python curses not displaying colors, whereas C ncurses works fine

空扰寡人 提交于 2019-12-04 21:45:50
I can't seem to get the Python curses module to display colors, whereas the ncurses C library works fine. Here is a simple script that should work: import curses def main(stdscr): if not curses.has_colors(): raise stdscr.addstr("Hello world\n", curses.color_pair(curses.COLOR_RED)) stdscr.addstr("Press any key to exit.\n") stdscr.refresh() while stdscr.getch() == -1: pass if __name__ == '__main__': curses.wrapper(main) I can only see "Press any key to exit.". I know "Hello world" is being written because of the new line, but I can't see the text. I attempted various color pairs, but only 0, i.e

Terminating a process breaks python curses

最后都变了- 提交于 2019-12-03 21:30:06
Using python multiprocessing and curses, it appears that terminating a Process interferes with curses display. For example, in the following code, why does terminating the process stops curses from displaying the text ? (pressing b after pressing a) More precisely, it seems that not only the string "hello" is not displayed anymore but also the whole curses window. import curses from multiprocessing import Process from time import sleep def display(stdscr): stdscr.clear() curses.newwin(0,0) stdscr.timeout(500) p = None while True: stdscr.addstr(1, 1, "hello") stdscr.refresh() key = stdscr.getch

Python issue with curses.intscr()

时光毁灭记忆、已成空白 提交于 2019-12-02 17:18:02
问题 I am new in Python and I am using curses for my script. But when I am try to run the script in server(let say 1) I am getting below error. _curses.error: addstr() returned ERR And the same script when I am try to run in another server(let say 2) it is running successfully. The reason is server 1 is producing more data to display on screen and server 1 is producing less data to display on screen. So while searching found that curses.intscr() getting the screen size fixed and that's why it is