curses

Error no module named curses

老子叫甜甜 提交于 2019-12-09 15:06:57
问题 When I try to run the following code... from telnetsrvlib import * if __name__ == '__main__': "Testing - Accept a single connection" class TNS(SocketServer.TCPServer): allow_reuse_address = True class TNH(TelnetHandler): def cmdECHO(self, params): """ [<arg> ...] Echo parameters Echo command line parameters back to user, one per line. """ self.writeline("Parameters:") for item in params: self.writeline("\t%s" % item) def cmdTIME(self, params): """ Print Time Added by dilbert """ self

Ruby infinite loop causes 100% cpu load

不问归期 提交于 2019-12-08 07:59:41
问题 I implemented some code, which runs in a loop: loop do .. end In that loop, I handle keypresses with Curses library. If I press N and entered something, I start a new Thread, which counts time( loop do .. end again) The question is, why loop or while true causes 100% cpu load on one of the cpu cores? Is the problem actaully in loop? Is there a way to do infinite loop with lower cpu consumption in ruby? The full sources available here UPD - Strace $ strace -c -p 5480 Process 5480 attached -

python: Using ncurses when underlying library logs to stdout

不羁的心 提交于 2019-12-08 03:54:39
问题 I am trying to write a small python program that uses curses and a SWIGed C++ library. That library logs a lot of information to STDOUT, which interferes with the output from curses. I would like to somehow intercept that content and then display it nicely through ncurses. Is there some way to do this? 回答1: A minimal demonstrating example will hopefully show how this all works. I am not going to set up SWIG just for this, and opt for a quick and dirty demonstration of calling a .so file

Canonical vs. non-canonical terminal input

瘦欲@ 提交于 2019-12-08 00:44:33
问题 I am studying for an exam and I am confused as to how canonical vs. non-canonical input/output works in Unix (e.g., curses). I understand that there is a buffer to which "line disciplines" are applied for canonical input. Does this mean that the buffer is bypassed for non-canonical input, or does it simply mean that no line disciplines are applied? How does this process differ for input and output operations? In the curses programs I have worked with that demonstrate canonical input, the

Python3 + Curses: How to press “q” for ending program immediately?

放肆的年华 提交于 2019-12-07 07:42:56
问题 When I run the following sample code and press just "q", it'll ends properly, but if I pressed any other characters "for instance many breaks and a lot of other characters" and then press "q" it'll not exit, how can I solve this? import curses, time def main(sc): sc.nodelay(1) while True: sc.addstr(1, 1, time.strftime("%H:%M:%S")) sc.refresh() if sc.getch() == ord('q'): break time.sleep(1) if __name__=='__main__': curses.wrapper(main) 回答1: Pressing other keys cause time.sleep(1) call, you

curses library: why does getch() clear my screen?

寵の児 提交于 2019-12-07 00:59:21
问题 I'm trying to learn the curses library (pdcurses, as I'm in Windows OS), with C++. I have a program that displays 3 windows, then a while loop to do some processing based in key presses captured by getch(). The loop gets exited when the F1 key is pressed. However, despite refreshing all three windows with wrefresh(), nothing appears before I enter my first key press. Without the while loop, everything is displayed fine. I've made numerous tests and it's like the first call to getch() will

Python curses not displaying colors, whereas C ncurses works fine

喜你入骨 提交于 2019-12-06 16:17:47
问题 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

Canonical vs. non-canonical terminal input

家住魔仙堡 提交于 2019-12-06 12:33:43
I am studying for an exam and I am confused as to how canonical vs. non-canonical input/output works in Unix (e.g., curses). I understand that there is a buffer to which "line disciplines" are applied for canonical input. Does this mean that the buffer is bypassed for non-canonical input, or does it simply mean that no line disciplines are applied? How does this process differ for input and output operations? In the curses programs I have worked with that demonstrate canonical input, the input typed by a user is automatically entered either after a certain number of characters have been typed

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

Detect Caps Lock in Python curses

a 夏天 提交于 2019-12-06 06:16:07
问题 For such a basic question, I'm surprised I couldn't find anything by searching... Anyways, I made a curses app in Python that assists in solving puzzles of a certain DSiWare game. With it, you can take a puzzle and inspect the components of it individually. The keys qweasdzx are used to paint tiles (the keys are arranged in some sort of palette). Pressing one of these keys while holding Shift highlights tiles with that color. I couldn't ask for a more natural control scheme. So it's a shame