Hi,
Continuing about the window sizes (and I'm now basing my evidence on the 2.2.3+ release).
This works:
xterm -fn 6x10 -geometry 40x27 -e pytone
This doesn't:
xterm -fn 6x10 -geometry 40x26 -e pytone xterm -fn 6x10 -geometry 39x27 -e pytone
So on startup the minimum width and height is 40x27. I see no reason why this cannot be even smaller.
I also noticed something very strange, if you start pytone with a 40x27 window, and then resize the window it will automatically switch to 80x25 whatever size you take less than 80x25, regardless of the fact that on startup 40x25 looked good.
If I replace the getmaxyx() function with the code I am using for dstat, it works better:
def getmaxyx(self): # taken from http://dag.wieers.com/home-made/dstat/ try: return int(os.environ["LINES"]), int(os.environ["COLUMNS"]) except: try: return curses.tigetnum('lines'), curses.tigetnum('cols') except: try: import fcntl, struct, termios s = struct.pack('HHHH', 0, 0, 0, 0) x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, s) return struct.unpack('HHHH', x)[:2] except: return 25, 80
Still it crashes when going below a certain treshold for the height (27 lines), so I looked into what the lowest values are and I came up with this:
def getmaxyx(self): # taken from http://dag.wieers.com/home-made/dstat/ try: h, w = int(os.environ["LINES"]), int(os.environ["COLUMNS"]) except: try: h, w = curses.tigetnum('lines'), curses.tigetnum('cols') except: try: import fcntl, struct, termios s = struct.pack('HHHH', 0, 0, 0, 0) x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, s) h, w = struct.unpack('HHHH', x)[:2] except: h, w = 25, 80 if h < 27: h = 27 if w < 25: w = 25 return h, w
This will prevent pytone from crashing when the width or height are lower than allowed (it will draw beyond the window limits if the window limits are too small). Although I'm not sure why the height can only be 27, so fixing that would probably better.
-- dag wieers, dag@wieers.com, http://dag.wieers.com/ -- [all I want is a warm bed and a kind word and unlimited power]