Curses and resizing windows

Discussion in 'Python' started by Chris Share, Jun 22, 2004.

  1. Chris Share

    Chris Share Guest

    I've been writing an application using curses, and have been trying to
    handle resizing the terminal, if running in xterm or similar. Increasing
    the window size is working perfectly, however shrinking it is not
    working at all. No matter how much I shrink the window, the size
    returned by getmaxyx() does not change. However as soon as I increase it
    again, it works fine.

    I've tracked the problem down to the fact I have created a window
    derived from stdscr. A small script showing the effect is at the end of
    this post.

    Can anyone suggest how to solve this problem, that doesn't involve not
    making a derwin of stdscr?

    I've been googling for hours, but found nothing to help.

    Python version is 2.3.4 on debian testing.

    chris

    #!/usr/bin/python
    import curses, sys

    def init_display(stdscr):
    stdscr.clear()
    stdscr.refresh()
    size = stdscr.getmaxyx()
    sys.stderr.write("Now %u x %u\n" % (size[1],size[0]))
    rootwin = stdscr.derwin(20, 50, 0, 0)
    return rootwin

    def main(stdscr):
    rootwin = init_display(stdscr)
    while 1:
    input = rootwin.getch()
    if ( input == curses.KEY_RESIZE):
    init_display(stdscr)
    elif input == ord("q"):
    sys.exit()
    rootwin.refresh()

    curses.wrapper(main)
    Chris Share, Jun 22, 2004
    #1
    1. Advertising

  2. Chris Share <> wrote:
    > I've been writing an application using curses, and have been trying to
    > handle resizing the terminal, if running in xterm or similar. Increasing
    > the window size is working perfectly, however shrinking it is not
    > working at all. No matter how much I shrink the window, the size
    > returned by getmaxyx() does not change. However as soon as I increase it
    > again, it works fine.


    > I've tracked the problem down to the fact I have created a window
    > derived from stdscr. A small script showing the effect is at the end of
    > this post.


    odd (thanks for the example - I don't know if this is a problem in
    ncurses or in the python interface to it, but will check/see).

    > Can anyone suggest how to solve this problem, that doesn't involve not
    > making a derwin of stdscr?


    > I've been googling for hours, but found nothing to help.


    > Python version is 2.3.4 on debian testing.


    probably should report it as a bug (so it's not overlooked).

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
    Thomas Dickey, Jun 22, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. resizing curses window

    , Aug 26, 2003, in forum: Python
    Replies:
    0
    Views:
    576
  2. Jean-Paul Calderone
    Replies:
    2
    Views:
    421
    Joel Hedlund
    Feb 9, 2006
  3. Nick !

    Curses and resizing windows

    Nick !, Feb 28, 2007, in forum: Python
    Replies:
    1
    Views:
    1,287
    Thomas Dickey
    Feb 28, 2007
  4. Pil (Trustworthy from Experience)

    Resizing a div by resizing its borders

    Pil (Trustworthy from Experience), Apr 18, 2009, in forum: Javascript
    Replies:
    9
    Views:
    334
    Proper
    Apr 21, 2009
  5. Proper
    Replies:
    0
    Views:
    188
    Proper
    Apr 18, 2009
Loading...

Share This Page