473,326 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Losing curses decorations.

I'm working on a small curses application that opens an external
editor occasionally; in the current case I'm testing its running vi.
Once I exit vi and return to the curses application I lose the
background color, window frames, and any text I had on the screen
before I opened vi. I can still see the program functioning though as
it is still responding to key strokes and still updating small
portions of the screen. I'm obviously doing something wrong but so
far I haven't been able to figure out what from the documentation.

I've boiled the problem I'm seeing down to a relatively small program:

import curses
import os

def vitest():
os.system('vi /tmp/foo_bar_baz');
return 1

def quit():
return 0

def nocommand():
return 1

command_table = { 'a' : vitest,
'q' : quit}

def refresh():
screen.refresh()

def keyhandler():
key = screen.getkey()
result = command_table.get(key,nocommand)()
screen.addstr(1,1,"Got: "+key)
return result

def main(stdscr):
global navigation, text, screen
screen = stdscr
screen.border()
screen.addstr(0,1," Test Window ")

refresh()

while keyhandler():
refresh()

curses.wrapper(main)
Oct 8 '08 #1
2 1121
Joe Keen wrote:
I'm working on a small curses application that opens an external
editor occasionally; in the current case I'm testing its running vi.
Once I exit vi and return to the curses application I lose the
background color, window frames, and any text I had on the screen
before I opened vi. I can still see the program functioning though as
it is still responding to key strokes and still updating small
portions of the screen. I'm obviously doing something wrong but so
far I haven't been able to figure out what from the documentation.

I've boiled the problem I'm seeing down to a relatively small program:
Does redrawing
def vitest():
os.system('vi /tmp/foo_bar_baz');
screen.redrawwin()
screen.refresh()
return 1
help?

Peter
Oct 8 '08 #2
On Oct 8, 1:16 am, Peter Otten <__pete...@web.dewrote:
Joe Keen wrote:
I'm working on a small curses application that opens an external
editor occasionally; in the current case I'm testing its running vi.
Once I exit vi and return to the curses application I lose the
background color, window frames, and any text I had on the screen
before I opened vi. I can still see the program functioning though as
it is still responding to key strokes and still updating small
portions of the screen. I'm obviously doing something wrong but so
far I haven't been able to figure out what from the documentation.
I've boiled the problem I'm seeing down to a relatively small program:

Does redrawing
def vitest():
os.system('vi /tmp/foo_bar_baz');

screen.redrawwin()
screen.refresh()
return 1

help?

Peter
It helps a little bit. Using that the line I modified with
screen.addstr(1,1,"Got: "+key) now has the proper background color and
the window decorations on the far ends. Only that line does though.
My understanding is that curses is going to try and redraw as little
as possible. Is there a function to force a full redraw? Or is that
redrawwin function supposed to be doing that?
Oct 8 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Edmond Ho | last post by:
Hi, I'm having trouble with a small curses program. I'm associate a pad with a panel. As I understand, a pad is supposed to be just a window with an arbitrary size. That seems to imply that a pad...
1
by: Riccardo Galli | last post by:
Hi, I'm writing some widgets in curses. Actually I'm trying to write a combobox. To do so, I need to create a pad inside a panel, so that I can hide/show it. I can't do it. I can create a...
0
by: Matthew Alton | last post by:
The appended program freaks python 2.2 & 2.3 completely out. To reproduce the wierdness: i) copy the source to a file called consarn.py ii) $ python consarn.py; iii) the program is now doing a...
0
by: Matt Garman | last post by:
I'd like to write a class or module in python that allows me to do on-the-fly color changing in the curses module. I'm thinking about something along the lines of this: addstr(y, x, 'hello',...
4
by: schwerdy | last post by:
Hi together, can someone provide an example of a curses application that works in a xterm that can be resized? I could not find any working example yet... Thanks in advance, Sebastian...
1
by: Jerry Fleming | last post by:
Hi, I have wrote a game with python curses. The problem is that I want to confirm before quitting, while my implementation doesn't seem to work. Anyone can help me? #!/usr/bin/python # #...
3
by: Simon Morgan | last post by:
Hi, I'm having trouble with the following code. The problem is that the value read by getch() when I hit the up or down keys doesn't match curses.KEY_UP or curses.KEY_DOWN respectively. Other...
7
by: Gasten | last post by:
Hello. The last weeks I've been coding a roguelike (you know, like nethack) in python using the nCurses library. Some week ago I ran into a problem: When I made the object for messagebar-output, I...
5
by: 7stud | last post by:
I can't see to get any y, x coordinates to work with curses. Here is an example: import curses def my_program(screen): while True: ch = screen.getch() if ch == ord("q"): break
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.