Get the height and width of the console. Returns: - tuple: Height and width of the console.
(self)
| 461 | if TIOCGWINSZ: |
| 462 | |
| 463 | def getheightwidth(self): |
| 464 | """ |
| 465 | Get the height and width of the console. |
| 466 | |
| 467 | Returns: |
| 468 | - tuple: Height and width of the console. |
| 469 | """ |
| 470 | try: |
| 471 | return int(os.environ["LINES"]), int(os.environ["COLUMNS"]) |
| 472 | except (KeyError, TypeError, ValueError): |
| 473 | try: |
| 474 | size = ioctl(self.input_fd, TIOCGWINSZ, b"\000" * 8) |
| 475 | except OSError: |
| 476 | return 25, 80 |
| 477 | height, width = struct.unpack("hhhh", size)[0:2] |
| 478 | if not height: |
| 479 | return 25, 80 |
| 480 | return height, width |
| 481 | |
| 482 | else: |
| 483 |