Home > other >  Python curses, program how to know the screen size is changed? How to get the size of the current wi
Python curses, program how to know the screen size is changed? How to get the size of the current wi

Time:09-23

Rt

Python curses under Linux programming, the program is started by screen. Getmaxyx () can get the size of the screen window, when change the window size, screen, getmaxyx () returns or original value, how to solve?

CodePudding user response:

The up
The up
up

CodePudding user response:

Don't know much about, is to refresh the what?

CodePudding user response:

refer to the second floor weixin_45903952 response:
don't understand, is to refresh the what?

Put one of the most simple example
 import time 
The import curses
The from the curses import wrapper

Def screen_size_changed (screen) :
The count=0
While True:
Time. Sleep (1)
If the count & gt; 10:
Break
Count +=1

Num_rows, num_cols=screen. Getmaxyx ()
Print (" Rows: {}, Colums: {} ". The format (num_rows num_cols))

Curses. Endwin ()


If __name__=="__main__" :
Screen=curses. Initscr ()
Wrapper (screen_size_changed)


The function of the code above is the biggest size within 10 to print the current screen (print will be a little messy, but not affect test result), you can simply try, during this time, you to change the window size, get the size of the values are the same, I just don't understand why is this
  • Related