Advertisement
asweigart

box_message.py

Feb 18th, 2023 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. UP_DOWN = chr(9474) # Character 9474 is '│'
  2. LEFT_RIGHT = chr(9472) # Character 9472 is '─'
  3. DOWN_RIGHT = chr(9484) # Character 9484 is '┌'
  4. DOWN_LEFT = chr(9488) # Character 9488 is '┐'
  5. UP_RIGHT = chr(9492) # Character 9492 is '└'
  6. UP_LEFT = chr(9496) # Character 9496 is '┘'
  7.  
  8. def box_message(width, height, message):
  9. # Print top line:
  10. print(DOWN_RIGHT + (LEFT_RIGHT * (width - 2)) + DOWN_LEFT)
  11.  
  12. for i in range(height - 2):
  13. if i == height // 2 - 1:
  14. # Print message:
  15. print(UP_DOWN + message.center(width - 2) + UP_DOWN)
  16. else:
  17. # Print empty line:
  18. print(UP_DOWN + (' ' * (width - 2)) + UP_DOWN)
  19.  
  20. # Print bottom line:
  21. print(UP_RIGHT + (LEFT_RIGHT * (width - 2)) + UP_LEFT)
  22.  
  23. box_message(50, 5, 'Do not ignore this message!')
  24. box_message(50, 3, 'It is very important!')
  25.  
  26. """
  27. Prints out:
  28. ┌────────────────────────────────────────────────┐
  29. │ │
  30. │ Do not ignore this message! │
  31. │ │
  32. └────────────────────────────────────────────────┘
  33. ┌────────────────────────────────────────────────┐
  34. │ It is very important! │
  35. └────────────────────────────────────────────────┘
  36. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement