Advertisement
MRtecno98

TextPy V.1.0.1 PC/Mobile

May 9th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. #WARNING: Requires Minimum Techcore V.1.1.0
  2.  
  3. import sys , os , time , techcore
  4.  
  5. def saveFile(text , path) :
  6.     text = text[1:]
  7.     file = open(path , "w")
  8.     file.write(text)
  9.     file.close()
  10.  
  11. def readFile(path) :
  12.     if not os.path.isfile(path) :
  13.         filec = open(path , "w")
  14.         filec.write("")
  15.         filec.close
  16.     file = open(path , "r")
  17.     text = file.read()
  18.     file.close()
  19.     return text
  20.  
  21. menu = """===================
  22. | PyText V.1.0.0  |
  23. |   by MRtecno98  |
  24. ===================
  25.         """
  26.  
  27. print(menu , end='')
  28. time.sleep(1)
  29. print()
  30.  
  31. while True :
  32.     try :
  33.         txtList = []
  34.         files = os.listdir()
  35.         maxLen = 0
  36.         for x in files :
  37.             if x[-4:] == ".txt" :
  38.                 txtList.append(x)
  39.                 if len(x) + 3 > maxLen :
  40.                     maxLen = len(x) + 3
  41.         techcore.createTable("Files",txtList,"=","|",maxLen,0.5)
  42.         path = input("Inserisci il percorso del file, E per uscire: ")
  43.         if path.lower() == "e" :
  44.             print("Uscendo...")
  45.             time.sleep(3)
  46.             sys.exit()
  47.         if not path[-4:] == ".txt" :
  48.             path = path + ".txt"
  49.         #while True :
  50.         #    path = input("Inserisci il percorso del file: ")
  51.         #    if os.path.ispath(path) :
  52.         #        break
  53.         #    else :
  54.         #       print("Path non valido")
  55.         text = readFile(path)
  56.         print("File Caricato!")
  57.         print("Per modificare il testo scrivi e premi invio per ogni riga,\nUsa |back| per cancellare una riga,\nUsa |end| per terminare la scrittura.")
  58.         newText = techcore.editText(text , "|end|" , "|back|")
  59.         saveFile(newText , path)
  60.         print("\nFile Salvato!")
  61.         time.sleep(3)
  62.         continue
  63.     except KeyboardInterrupt :
  64.         print("\nProgramma Terminato!")
  65.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement