Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ Module boxed_msg1 that prints a box around text.
- """
- def box_msg(msg, indent=1, width=None, title=None):
- """Print message-box with optional title."""
- lines = msg.split('\n')
- space = " " * indent
- if not width:
- width = max(map(len, lines))
- box = f'╔{"═" * (width + indent * 2)}╗\n' # upper_border
- if title:
- box += f'║{space}{title:^{width}}{space}║\n' # title
- box += f'║{space}{"-" * width:<{width}}{space}║\n' # underscore
- box += ''.join([f'║{space}{line:<{width}}{space}║\n' for line in lines])
- box += f'╚{"═" * (width + indent * 2)}╝' # lower_border
- print(box)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement