curses and python (linux, debian)

Discussion in 'Python' started by Guido, May 3, 2004.

  1. Guido

    Guido Guest


    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?

    Guido, May 3, 2004
    1. Advertisements

  2. 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":

    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'):

    David M. Cooke, May 3, 2004
    1. Advertisements

  3. Don't you call initscr() first?

    Michael Hudson, May 4, 2004
  4. Guido

    Guido Guest

    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!

    Guido, May 4, 2004
  5. Guido

    Guido Guest

    i did, but i forget to copy it
    Guido, May 4, 2004
  6. 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 :)
    David M. Cooke, May 4, 2004
  7. Guido

    Guido Guest

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

    Do you have any other suggestions?

    Otherwise I'll stay with the combo solution
    Guido, May 5, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.