(text, width=55)
| 104 | |
| 105 | |
| 106 | def header(text, width=55): |
| 107 | cls() |
| 108 | print(" {}".format("#" * width)) |
| 109 | mid_len = int(round(width / 2 - len(text) / 2) - 2) |
| 110 | middle = " #{}{}{}#".format(" " * mid_len, text, " " * ((width - mid_len - len(text)) - 2)) |
| 111 | if len(middle) > width + 1: |
| 112 | # Get the difference |
| 113 | di = len(middle) - width |
| 114 | # Add the padding for the ...# |
| 115 | di += 3 |
| 116 | # Trim the string |
| 117 | middle = middle[:-di] + "...#" |
| 118 | print(middle) |
| 119 | print("#" * width) |
| 120 | |
| 121 | |
| 122 | class TUIMenu: |