I am using curses to print a pretty nice console UI, and I need for that something to be dependent of the terminal size. For this, I read here, that I could use shutil.get_terminal_size
.
So I'm doing this code :
def display(self):
size_x,size_y = shutil.get_terminal_size()
print(size_x,size_y)
window_stat = curses.newwin(size_y,size_x//2-5,0,0)
window_alert = curses.newwin(size_y,size_x//2-5,0,size_x//2+5)
window_alert.addstr("\n " + self.alert2string())
window_stat.addstr("\n " + self.stat2string())
window_alert.box()
window_stat.box()
self.stdscr.refresh()
window_stat.refresh()
window_alert.refresh()
But the fast is that, it is working perfectly the first time I call the function, but if I use my mouse to change the terminal size and recall the function, the result of shutil.get_terminal_size()
will always stay the same. (120 30).
Do you have any idea of where it could come from ? (I'm running Windows actually, and I'd like it to work under all common OS)
Thanks a lot everyone !