473,386 Members | 1,835 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,386 software developers and data experts.

saving curses screen state (putwin() and getwin() again)

I'm working on a curses-based application in Python. I've
implemented what I call a "Chooser" (a fancy name for a menu):

---> 1. Choice 1 <---
2. Choice 2
3. Choice 3

So the user can use the arrow keys to change choices. When he hits
enter, the screen is re-drawn with a new interface. When that
interface is quit, the screen should return to the Chooser, exactly
as it was left.

So my strategy is to call putwin() before going to the new
interface, and call getwin() after returning from the previous
interface.

This works as described the *first* time, but subsequent calls to
getwin() return the window that was saved with the first call to
putwin(). I.e., it's as though only the first call to putwin() has
any effect.

Any thoughts?

Thanks!
Matt

--
Matt Garman
email at: http://raw-sewage.net/index.php?file=email
Jul 18 '05 #1
3 2801
Matt Garman <fa**@not-real.bogus> writes:
I'm working on a curses-based application in Python. I've
implemented what I call a "Chooser" (a fancy name for a menu):

---> 1. Choice 1 <---
2. Choice 2
3. Choice 3

So the user can use the arrow keys to change choices. When he hits
enter, the screen is re-drawn with a new interface. When that
interface is quit, the screen should return to the Chooser, exactly
as it was left.

So my strategy is to call putwin() before going to the new
interface, and call getwin() after returning from the previous
interface.

This works as described the *first* time, but subsequent calls to
getwin() return the window that was saved with the first call to
putwin(). I.e., it's as though only the first call to putwin() has
any effect.

Any thoughts?


Yes. Show us some code, please. There are any number of bugs that
could cause this behavior, and it'd be easier to narrow things down if
we knew what you were actually doing.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 18 '05 #2
On Wed, 10 Nov 2004 13:04:09 -0600, Mike Meyer <mw*@mired.org> wrote:
This works as described the *first* time, but subsequent calls to
getwin() return the window that was saved with the first call to
putwin(). I.e., it's as though only the first call to putwin() has
any effect.


Yes. Show us some code, please. There are any number of bugs that
could cause this behavior, and it'd be easier to narrow things
down if we knew what you were actually doing.


I was hoping that the error was well-known or obvious and that
wouldn't be necessary.

Anyway, I posted some code that exhibits this behavior on my
website, http://www.raw-sewage.net/

Specifically, download the following files (and save in a common
directory):

http://raw-sewage.net/newwin.py
http://raw-sewage.net/curseschooser.py
http://raw-sewage.net/cursescolors.py

Then run the script "newwin.py". You are initially presented with
an option menu; the selection is controlled by either the up and
down arrow keys or 'j' and 'k'.

Example run to duplicate buggy behavior:

1. Run newwin.py, arrow down to option '3', press enter
2. The screen will redraw; press 'q' to go back to the menu
3. The screen should appear in the state you left it when you
pressed enter from the option menu (i.e. choice 3 selected)
4. Now choose option 5, press enter
5. The alternate screen appears, press 'q' to quit it
6. Now, the screen will re-draw as it did in step (3) above,
i.e. choice 3 is highlighted, *not* choice 5 where you left
off
7. But, if you use the up/down arrow keys, you'll realize that
the option menu thinks it left off on choice 5 (even though
it's not highlighted).

The behavior is consistent on my Linux box, running the following
version of Python:

Python 2.3.4 (#1, Oct 17 2004, 14:17:06)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)]
on linux2

Thanks again!
Matt

--
Matt Garman
email at: http://raw-sewage.net/index.php?file=email
Jul 18 '05 #3
Can you release a source code for this program ? Im wanting to use curses and
python, but havent found any doc.

Thanks !
Em Qua 10 Nov 2004 04:48, Matt Garman escreveu:
I'm working on a curses-based application in Python. I've
implemented what I call a "Chooser" (a fancy name for a menu):

---> 1. Choice 1 <---
2. Choice 2
3. Choice 3

So the user can use the arrow keys to change choices. When he hits
enter, the screen is re-drawn with a new interface. When that
interface is quit, the screen should return to the Chooser, exactly
as it was left.

So my strategy is to call putwin() before going to the new
interface, and call getwin() after returning from the previous
interface.

This works as described the *first* time, but subsequent calls to
getwin() return the window that was saved with the first call to
putwin(). I.e., it's as though only the first call to putwin() has
any effect.

Any thoughts?

Thanks!
Matt

--
Matt Garman
email at: http://raw-sewage.net/index.php?file=email


Jul 18 '05 #4

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

Similar topics

0
by: AK | last post by:
Hi, I have a medium sized app that I'm transferring to use curses. What happens is very very strange.. I am at my wits' ends. I worked with it all day yesterday and couldn't figure it out....
1
by: Matt Garman | last post by:
I've been working on a curses-based application in Python. My application effectively has a series of screens (or windows). When one screen closes, the previous screen should be exactly redrawin...
1
by: usl2222 | last post by:
Hi, I'm building this web application using asp.net and c# as code behind. Currently I save all my session data in session variables. One of the things that this application must do, is to...
2
by: Carpe Diem | last post by:
Hello all. My host is experiencing some troubles and I think you'll answer me before they can. After I uploaded a slightly changed JScript.NET .aspx page (the contents are not important, could be...
0
by: Stu | last post by:
Hi, I want to be able to come up with some way of navigating around a system that allows me to save certain screen info (Say combo box setting) so that when returning to the screen from a link...
1
by: George Homorozeanu | last post by:
We are developing a .net database driven application. The application is already quite complex and uses at time aprox. 150 data tables stored in the MSSQL 2000 database server. Our application has...
2
by: Greg | last post by:
I am building an SVG interface (with Javascript) for client side control of some hardware. The svg will be hosted on a micro PC (http://www.picotux.com/indexe.html). It runs a uClinux OS with GCC...
48
by: Daniele C. | last post by:
As soon as my sourceforge.net project gets approved, I am going to build a ncurses port to win32 bindable to sockets, e.g. allowing VT100/ANSI terminals and the creation of simple terminal servers...
4
by: yossi.kreinin | last post by:
Hi! Is there a way to save the state of a Python process for later inspection with a debugger? One way to do this is to dump core, but is the result usable for debugging with pdb (it can be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.