[Tutor] How to use "curses.resizeterm(nlines, ncols)"

boB Stepp robertvstepp at gmail.com
Sun Feb 24 18:25:00 EST 2019


On Sun, Feb 24, 2019 at 4:40 PM Cameron Simpson <cs at cskk.id.au> wrote:
>
> On 24Feb2019 14:30, boB Stepp <robertvstepp at gmail.com> wrote:

> >What you say makes sense and supports much of what I had concluded
> >from my coding experiments.  However, I still cannot get the function
> >call, curses.resizeterm(), to do anything meaningful, which suggests
> >that I still do not truly understand its usage.
>
> Likely so. The important thing you may be missing is that curses
> _itself_ calls resizeterm() automatically when it gets a SIGWINCH, so in
> normal situations you do not need to call this function.

AHA!  It is exactly that.  How am I to know this from reading the
existing Python 3 docs???  I spent *much* time trying different coding
efforts to get resizeterm() to do something, ANYTHING, when all along
this was happening automatically behind the scenes.

> Because of this, getmaxyx() is always correct for the size of the
> terminal.
>
> Secondarily, resizeterm() does not make a change to the terminal itself.

I realized this before I sent my original post.  I really think the
name chosen, resizeterm, is a very misleading name!

> >I created the
> >following script to test things out:
> [...]
>
> I've modified your script. Please try the script appended below. The
> short answer is that resizeterm() is _not_ normally useful to you, the
> programmer; it will only be useful if curses does not get to notice
> terminal size changes - _then_ you could use it to provide that
> facility.

Thanks for the additional clarity provided with your modifications!

boB


More information about the Tutor mailing list