curses

How to get a brightwhite color in ncurses?

梦想的初衷 提交于 2019-12-23 09:36:22
问题 How to init a color pair with light grey background, and bright white foregraound? init_pair(number, COLOR_WHITE, COLOR_WHITE) creates a color pair with light grey foreground and backround, but I need foreground to be really white. I tried combining COLOR_WHITE with A_BLINK (through bitwise OR) but that doesn't work. Ncurses howto's/examples/documentaion couldn't help me either. 回答1: You need to set the bold attribute. Call attron(A_BOLD) before you write and attroff(A_BOLD) after. 回答2: I had

python celery - ImportError: No module named _curses - while attempting to run manage.py celeryev

折月煮酒 提交于 2019-12-23 07:11:15
问题 Background Windows 7 x 64 Python 2.7 Django 1.4 Celery with Redis bundle While trying to run manage.py celeryev, I get the following error in the terminal import curses File 'c:\Python2\lib\curses\__init__.py', line 15, in <module> from _curses import * ImportError: No module named _curses I've tried looking at other posts, but haven't been able to solve this problem. Any thoughts on what is causing this error? Thanks in advance. 回答1: According to http://docs.python.org/library/curses.html

How to extend the curses window class in Python3?

梦想与她 提交于 2019-12-23 04:49:07
问题 I would like to extend the curses built-in window class that is created by calling curses.newwin() . However, I am hard-pressed to find out the actual name of that class that should replace the ¿newwin? placeholder below. #!/usr/bin/python3 import curses class Window(curses.¿newwin?): def __init__(self, title, h, w, y, x): super().__init__(h, w, y, x) self.box() self.hline(2, 1, curses.ACS_HLINE, w-2) self.addstr(1, 2, title) self.refresh() def main(screen): top_win = Window('Top window', 6,

How to detect curses ALT + key combinations in python

喜你入骨 提交于 2019-12-22 07:55:14
问题 New to python here and using the curses import. I want to detect key combinations like ALT + F and similar. Currently, I am using getch() to receive a key and then printing it in a curses window. The value does not change for F or ALT + F . How can I detect the ALT key combinations? import curses def Main(screen): foo = 0 while foo == 0: ch = screen.getch() screen.addstr (5, 5, str(ch), curses.A_REVERSE) screen.refresh() if ch == ord('q'): foo = 1 curses.wrapper(Main) 回答1: Try this: import

Python curses.getmouse()

柔情痞子 提交于 2019-12-22 07:27:06
问题 #!/usr/bin/env python # -*- coding: utf-8 -*- import curses screen = curses.initscr() curses.noecho() curses.curs_set(0) screen.keypad(1) curses.mousemask(1) screen.addstr("This is a Sample Curses Script\n\n") while True: event = screen.getch() if event == ord("q"): break if event == curses.KEY_MOUSE: screen.addstr(curses.getmouse()) curses.endwin() if event == curses.KEY_MOUSE: screen.addstr(curses.getmouse()) I think I should get the text where mouse is clicked or not? All I get is

Using ncurses to capture mouse clicks on a console application

雨燕双飞 提交于 2019-12-22 04:05:15
问题 I'm making a console application for unix platforms, and I'm using the curses (or ncurses) library to handle keyboard and mouse input. The problem is that I've found very little documentation on how exactly to use it for that, appart from this page and this one, which don't have very detailed examples. I've managed to capture the left click, but I can't get it to work for the right click because the options menu for the terminal emulator appears at the cursor location, but the event is not

Keep stdin line at top or bottom of terminal screen

天大地大妈咪最大 提交于 2019-12-22 03:49:12
问题 So I am writing a project where I run a program that constantly receives/sends messages to other computers running the same program. The receiver/sender of data is running on a thread and prints to stdout. I get stuff like this: [INFO] User 'blah' wants to send message to you. [INFO] some other info [MSG REC] Message 'hello' received from blah. Now the issue is that sometimes I wish to input commands into the terminal, the problem is when I try to enter a command and a new info message or MSG

How to use python curses module to create a key event?

青春壹個敷衍的年華 提交于 2019-12-22 01:06:23
问题 I'm trying to make a key event in python. I think that with curses module i can do that but i don't know how to. Please help me. How can i call a function with a press of a keyboard key. Like, if "space" key is pressed do something, if "c" key is pressed show image, if "s" key is pressed save image. My problem is only to make that key event. I'm using Linux o.s. I tried to use urwid module and when i use this code: import PIL import Image im=Image.open("im.tif") imshow(im,cmap=cm.gray ,origin

Shell in ncurses window?

不羁岁月 提交于 2019-12-21 20:46:32
问题 I'm currently attempting to write a minimal terminal multiplexer using ncurses. However, when I try to execv a shell, it doesn't print to the window, and instead starts a new subprocess that takes control of the window (i.e. ignores ncurses). How can I prevent that and have ncurses control it? Is there some way of getting the tty and controlling that? EDIT Thanks to Ross Ridge in the comments, I now know that I need to create a pseudo-terminal, which I then read into an ncurses window.

Install pdcurses on Visual Studio 2017

落爺英雄遲暮 提交于 2019-12-21 18:38:13
问题 I was making a 2048 game on CodeBlocks, but due to debugging problems, I move to Visual Studio Community 2017. It seems that conio.h doesn't work there, so I'm trying to switch to curses.h library. I've read a lot of tutorials, but none of them worked for me. I visited their website and downloaded the zip file with 384KB, but I do not know what to do with these files. Help, please? 回答1: I have found a very useful website which talks about PDCurses and its installation in Visual Studio. Even