Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- class box:
- def __init__(self, text):
- t = []
- maxlen = []
- text = text.split("[p]")
- for i, p in enumerate(text):
- p = p.split('[l]')
- maxlen.append(max(len(line) for line in p))
- t.append('')
- t.append(' \033[47;30m '+' '*maxlen[i]+' \033[0m')
- for line in p:
- t.append(' \033[47;30m '+line+' '*(maxlen[i]-len(line))+' \033[0m')
- t.append(' \033[47;30m '+' '*maxlen[i]+' \033[0m')
- t.append('')
- self.t = t
- del t, maxlen, i
- def output(self):
- print('\n'.join(self.t))
- if __name__ == '__main__':
- a = box('this is the first box\
- [l]as you can see\
- [p]now you\'re reading the content from the second box\
- [p]we just switched to the third box\
- [l]not as large a box\
- [l]though slightly higher\
- [l]you can see that even though\
- [l]it goes on and on\
- [l]nothing broke yet\
- [l](well i hope so at least)\
- [p]anyway we reached the last box\
- [l]so it\'s time for good byes')
- a.output()
- if 'win' in os.sys.platform:
- os.system('PAUSE')
Advertisement
Add Comment
Please, Sign In to add comment