Skip to content
← Back to Community
Python display terminal size in characters
Profile icon

Been working on a python curses application and I want it to take advantage of the whole console I have.

Unfortunately when I run os.get_terminal_size()
it always returns the 80 24 of the default console
even when I can clearly see the console longer or larger than that to the right of the code.
I loop printed the letter a and it went to about 60 rows displayed.

This display console obviously depends on your own browser and window, so it would be nice if I could be able to get updates on the screen size as maybe the window resizes or a different user opens the page with different settings.

Like, instead of just figuring out my default screen size and setting it with os.system('mode con: cols=200 lines=49') which doesn't even work.

Sorry if I sound frustrated, unfortunately I need to use Repl It specifically and it'd drive me crazy if I have to make text user interface with on 80 24 width... tho I guess that might just be the case... Any help is appreciated

Profile icon
Profile icon
Profile icon

The issue is that Replit is running your code in a Docker container, the output of which is then piped to your computer. The container has no idea how large your output terminal is, unfortunately. (you could submit this as a feature request at feedback)

Profile icon

Hmm... interesting to know about the Docker container. And yeah, I guess I'll go to the feedback. For now I have just written my code to adapt to what ever size the terminal is, so if I can change it later then it should still work. Fingers Crossed. Thank you for the repy tho :3