def _get_size_tput():
 try:
  import subprocess
  proc = subprocess.Popen(['tput', 'cols'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  output = proc.communicate(input=None)
  cols = int(output[0])
  proc = subprocess.Popen(['tput', 'lines'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  output = proc.communicate(input=None)
  rows = int(output[0])
  return (cols, rows)
 except:
  return None

def _get_size_tput ( ) : try : import subprocess proc = subprocess . Popen ( [ 'tput' , 'cols' ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE ) output = proc . communicate ( input = None ) cols = int ( output [ 0 ] ) proc = subprocess . Popen ( [ 'tput' , 'lines' ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE ) output = proc . communicate ( input = None ) rows = int ( output [ 0 ] ) return ( cols , rows ) except : return None
attempt to discover the dimensions of a terminal window .