Advertisement
1400_SpaceCat

mdl_magic.py

Oct 24th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. import platform
  2. from time import sleep
  3. from os import system
  4. import colorama,platform
  5. from colorama import init,Fore,Back,Style
  6.  
  7. class Colors:
  8.     init()
  9.  
  10.     sblack    = Fore.BLACK
  11.     sred      = Fore.RED
  12.     sgreen    = Fore.GREEN
  13.     syellow   = Fore.YELLOW
  14.     sblue     = Fore.BLUE
  15.     swhite    = Fore.WHITE
  16.  
  17.     bgblack   = Back.BLACK
  18.     bgred     = Back.RED
  19.     bggreen   = Back.GREEN
  20.     bgyellow  = Back.YELLOW
  21.     bgblue    = Back.BLUE
  22.     bgmagenta = Back.MAGENTA
  23.     bgwhite   = Back.WHITE
  24.  
  25.     endc      = Style.RESET_ALL
  26.    
  27. class magic:
  28.     Clear = lambda: print(chr(27) + "[2J")
  29.     Sleep = lambda s: sleep(s)
  30.     ShowNicely = lambda cl,tw: [ print(cl[i],end="") and sleep(tw) for i in range(len(cl)) ]
  31.     PressKey = lambda eventWord: input(""+eventWord)
  32.  
  33. class ClearSaves:
  34.     if ( platform == "Windows" ): (stdout,stderr) = Popen("wclean.bat", cwd=r".").communicate()
  35.     else: system("chmod +x pclean.sh && ./pclean.sh")
  36.    
  37. class ShowNicely(Colors):
  38.     def __init__(self):
  39.         self.printer(Colors.sred,Colors.bgblue)
  40.  
  41.     def printer(self,color,bg):
  42.         print(color+bg+"TEST")
  43.    
  44. class vhLines(Colors):
  45.     MINY, MAXY = 1, 24
  46.     MINX, MAXX = 1, 80
  47.     pos = lambda y, x: '\x1b[%d;%dH' % (y, x)
  48.    
  49.     print(Colors.bgwhite,end="")
  50.     print('%s%s' % (pos(MINY, MINX), ' '*MAXX), end='')
  51.     print('%s%s' % (pos(MAXY, MINX), ' '*MAXX), end='')
  52.     print('%s%s%s%s' % (pos(MINY, MINX), Colors.swhite, Colors.sblack, Colors.endc), end='')
  53.     print(Colors.endc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement