curses and python (linux, debian)

G

Guido

Hello

I'm new to python and i'm trying to write a script
that shows a menu.

Now, I have some troubles with curses.setsyx()

I do:

import curses

curses.setsyx(2, 20)
curses.putp("TEST TITLE")
curses.setsyx(25, 35)
curses.putp("TEST CENTER")
curses.setsyx(12, 35)
curses.putp("TEST CENTER")

but it just prints all the string after each other
at the first lines..

can anybody help me please?

thx!
 
D

David M. Cooke

At some point said:
Hello

I'm new to python and i'm trying to write a script that shows a menu.

Now, I have some troubles with curses.setsyx()

I do:

import curses

curses.setsyx(2, 20)
curses.putp("TEST TITLE")
curses.setsyx(25, 35)
curses.putp("TEST CENTER")
curses.setsyx(12, 35)
curses.putp("TEST CENTER")

but it just prints all the string after each other at the first
lines..

Er, that's really the wrong way to do it. For one thing, curses.putp
doesn't do what you think you want it to do. Have a look at "Curses
Programming with Python":
http://www.amk.ca/python/howto/curses/

Something like this:

import curses

def main(stdscr):
stdscr.addstr(2, 20, "TEST TITLE")
stdscr.addstr(25,35, "TEST CENTER")
stdscr.addstr(12,35, "TEST CENTER")
while 1:
c = stdscr.getch()
if c == ord('q'):
return

curses.wrapper(main)
 
M

Michael Hudson

Guido said:
Hello

I'm new to python and i'm trying to write a script that shows a menu.

Now, I have some troubles with curses.setsyx()

I do:

import curses

curses.setsyx(2, 20)
curses.putp("TEST TITLE")
curses.setsyx(25, 35)
curses.putp("TEST CENTER")
curses.setsyx(12, 35)
curses.putp("TEST CENTER")

but it just prints all the string after each other at the first
lines..

can anybody help me please?

Don't you call initscr() first?

Cheers,
mwh
 
G

Guido

David said:
Er, that's really the wrong way to do it. For one thing, curses.putp
doesn't do what you think you want it to do. Have a look at "Curses
Programming with Python":
http://www.amk.ca/python/howto/curses/

Something like this:

import curses

def main(stdscr):
stdscr.addstr(2, 20, "TEST TITLE")
stdscr.addstr(25,35, "TEST CENTER")
stdscr.addstr(12,35, "TEST CENTER")
while 1:
c = stdscr.getch()
if c == ord('q'):
return

curses.wrapper(main)

thx very much

very handy tutorial!

Now, i'm using DrPython, it looks fine, but i
can't debug my curses program

It gives an error with this message:
curses.wrapper returned ERR on curses.cbreak

if i run it with python, it works!

anybody?
 
D

David M. Cooke

At some point said:
thx very much

very handy tutorial!

Now, i'm using DrPython, it looks fine, but i can't debug my curses
program

It gives an error with this message: curses.wrapper returned ERR on
curses.cbreak

I'm not familiar with DrPython, but it looks like a IDE. The console
widget it uses for the Python shell probably doesn't support enough to
be a 'real' terminal, so curses likely doesn't work in it. You'll have
to run it in a terminal program like xterm.
if i run it with python, it works!

From the command line, right? There you go :)
 
G

Guido

David said:
I'm not familiar with DrPython, but it looks like a IDE. The console
widget it uses for the Python shell probably doesn't support enough to
be a 'real' terminal, so curses likely doesn't work in it. You'll have
to run it in a terminal program like xterm.




From the command line, right? There you go :)

well, I like a good editor, and DrPython seemed nice.

Do you have any other suggestions?

Otherwise I'll stay with the combo solution
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top