Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8162297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:40:37+00:00 2026-06-06T18:40:37+00:00

I have a simple python curses code that creates a subwindow. However, in the

  • 0

I have a simple python curses code that creates a subwindow. However, in the process of running the function window.subwin() fails with the message:

Here a test case:

import curses

if __name__ == '__main__':
    curses.initscr()

    window = curses.newwin(15, 40, 7, 20)
    window.box()
    window.refresh()

    subwindow = window.subwin(5, 10, 2, 2)
    subwindow.box()
    subwindow.refresh()

    subwindow.getkey()

    curses.endwin()

produces the following output:

Traceback (most recent call last):
File "c.py", line 12, in <module>
  subwindow = window.subwin(5, 10, 2, 2)
_curses.error: curses function returned NULL

Is there any way to get a more descriptive message?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:40:38+00:00Added an answer on June 6, 2026 at 6:40 pm

    The error likely happens when it is not possible to create a sub-window (illegal operation). This can happen because you are asking to paint the sub-window outside of the window.

    The method subwin receives absolute coordinates (with respect to the screen, not the parent window). It will fail if the subwin coordinates are outside of window. Another reason to fail: the width or height overflows the window.

    Instead of subwin, you can use derwin (derivated window), which receives relatives coordinates (less prone to error).

    import curses
    
    if __name__ == '__main__':
        curses.initscr()
    
        window = curses.newwin(15, 40, 7, 20)
        window.box()
        window.refresh()
    
        subwindow = window.derwin(5, 10, 2, 2)  # <- here is the change
        subwindow.box()
        subwindow.refresh()
    
        subwindow.getkey()
    
        curses.endwin()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather simple Python script that contains a function call like f(var,
I have a simple class in python that has a __str__() function. Like this:
I have the following simple Python code that makes a simple post request to
I have a simple Python script that uses the socket module to send a
I have a simple python program that I'd like to daemonize. Since the point
I have a very simple python script that should scan a text file, which
I have the following simple python test script that uses Suds to call a
I have a fairly simple python loop that calls a few functions, and writes
Well, i have written a simple python program that parses HTML with HTMLParser. Here
I have a simple form in python + pylons that submits to a controller.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.