curses

How to make a scrolling menu in python-curses

纵然是瞬间 提交于 2019-12-28 06:50:11
问题 There is a way to make a scrolling menu in python-curses? I have a list of records that I got from a query in sqlite3 and I have to show them in a box but they are more than the max number of rows: can I make a little menu to show them all without making curses crashing? 回答1: This code allows you to create a little menu in a box from a list of strings. You can also use this code getting the list of strings from a sqlite query or from a csv file. To edit the max number of rows of the menu you

Prevent Terminal resize python curses

ε祈祈猫儿з 提交于 2019-12-26 15:26:35
问题 I'm writing a program on python curses and I was wondering if there is a way to block terminal resizing in order to prevent curses' crashing both on Linux and Windows. This is what happens.. Can I prevent this? Under Windows this does not happen cause window resizing doesn't influence prompt proportions... http://alessio.ragno.info/Before%20Resize.png http://alessio.ragno.info/After%20Resize.png ` import curses screenTest = curses.initscr() boxTest = curses.newwin(24,80,0,0) boxTest.box()

Prevent Terminal resize python curses

旧街凉风 提交于 2019-12-26 15:26:05
问题 I'm writing a program on python curses and I was wondering if there is a way to block terminal resizing in order to prevent curses' crashing both on Linux and Windows. This is what happens.. Can I prevent this? Under Windows this does not happen cause window resizing doesn't influence prompt proportions... http://alessio.ragno.info/Before%20Resize.png http://alessio.ragno.info/After%20Resize.png ` import curses screenTest = curses.initscr() boxTest = curses.newwin(24,80,0,0) boxTest.box()

Write an UTF8 character to the last position of the screen with Python curses

我是研究僧i 提交于 2019-12-25 08:21:08
问题 How to write a UTF8 character to the last position (bottom right) of the screen with Python's curses module? The task might look straight forward at first, but it isn't. First of all, Python 2.x is incapable of outputting UTF-8 using curses, so we'll assume Python 3.x here. There are two obvious candidates for doing it: screen.insch(lines - 1, columns - 1, u"\u00a9") This gives an OverflowError: byte doesn't fit in chtype . Bummer. What about: screen.addch(lines - 1, columns - 1, u"\u00a9")

(Python Unicurses) stdscr not passing between files?

旧城冷巷雨未停 提交于 2019-12-25 07:48:57
问题 I've been trying to learn Curses (Unicurses since I'm on Windows) and have been following a tutorial, but I've gotten stuck. I am running into this error message: D:\Python34>python ./project/cursed.py Traceback (most recent call last): File "./project/cursed.py", line 35, in <module> main() File "./project/cursed.py", line 20, in main obj_player = Player(stdscr, "@") File "D:\Python34\project\cursedplayer.py", line 10, in __init__ self.max_x = stdscr.getmaxyx()[1] - 1 AttributeError: 'c_void

Python curses TypeError when exiting wrapper

﹥>﹥吖頭↗ 提交于 2019-12-25 04:24:28
问题 I'm running Mac OS X 10.9.5 and when wrapping my main() function with curses.wrapper I'm getting the following error after my program exits successfully: Traceback (most recent call last): File "test.py", line 42, in <module> wrapper(main(SCREEN)) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/curses/__init__.py", line 94, in wrapper return func(stdscr, *args, **kwds) TypeError: 'NoneType' object is not callable Some amplifying code: if __name__ == "__main__": #

PDcurses displaying question marks in place of intended character

倾然丶 夕夏残阳落幕 提交于 2019-12-24 15:42:12
问题 Ive got a problem with PDcurses displaying some symbols as ? instead of the proper character. I made a little test program to display code page 437 to determine which symbols were working and which werent. Strangely, when I turned off PDcurses the problem symbols displayed correctly. The problem symbols are ÇéâäàåçêëèïîÄæÆôöòûùÿÖÜ¢£₧ƒ This is the source code without PDcurses: #include "stdafx.h" #include <curses.h> #include <iostream> #include <panel.h> using namespace std; int _tmain(int

getting a char from keyboard using curses.h

余生长醉 提交于 2019-12-24 11:27:33
问题 I'm trying to get a character from the keyboard using curses.h. This is my source (get_char_example.c): #include <curses.h> #include <stdio.h> int main(void) { char ch; printf("Enter a character: "); ch = getch(); printf("\nIts ASCII code is %d\n", ch); return 0; } I use the following command to compile: gcc get_char_example.c -o get_char_example And I get the following error: /tmp/ccjaXwRU.o: In function `main': get_char_example.c:(.text+0x1c): undefined reference to `stdscr' get_char

Set a window's background color in Ruby curses

三世轮回 提交于 2019-12-24 10:48:11
问题 Trying to add a background to a curses window. I have these two properties I've found these two methods: bkgd(ch) and bkgdset(ch) However, I can't implement them: win1.new(10,10,10,10) win1.box('|','-') win1.bkg(COLOR_RED) This fills win1 with a load of diamonds! Very insteresting effect but not what I wanted. I want a red background. Colors work perfectly in my terminal. 回答1: It's been a while, but maybe my examples are still useful: It is the same "diamonds" for me when using window.bkgd

Sending curses input to another terminal in C via a fifo

坚强是说给别人听的谎言 提交于 2019-12-24 00:46:00
问题 My C program run multiple thread in the terminal that print messages asynchronously. I'd like a thread to show curses output, but as it is asynchronous it must be in another terminal. My idea is to write the curses output to a fifo and open a terminal with cat fifo . But how could I recover the ouput the curses out and output it to a file? Thank you. 回答1: curses uses a terminal for its input and output, so if you want to intercept that and make it go somewhere other than a terminal, the