Advertisement
Mark2020H

Python presentation script with a difference

Aug 1st, 2021
2,469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.65 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. # Ideal for presentations desktop recordings  where you need hands free  
  5. # Tested on openSUSE 15.3
  6.  
  7. #  A small python script that will read a text file in , split this into paragraphs
  8. #  then prints line by line the characters of that paragraph in slow motion in a Linux terminal
  9. #  according to prompt from user
  10.  
  11. #  Colours of text are interchangeable
  12. #  Speed can be altered for slow motion print of chars Introductory messages and end message changeable Enjoy Mark Harrington
  13.  
  14. from datetime import datetime
  15. import argparse
  16. import time
  17. import sys
  18. import os
  19.  
  20.  
  21. # Author MD Harrington  Facebook https://www.facebook.com/mark.harrington.142892 links to this there as well for you
  22. #
  23. # You need to include a  text file  in your  folder  with the python script make sure  ecah paragraph is seperated by two
  24. # line breaks
  25. # usage ::  python paragraphs.py
  26.  
  27. # python version Python 2.7.14
  28. # You can also download this from git hub
  29. # https://github.com/markh2016/pyReadparagraphs.git
  30.  
  31. # global colour settings
  32.  
  33. CBLACK  = '\33[30m'
  34. CRED    = '\33[31m'
  35. CGREEN  = '\33[32m'
  36. CYELLOW = '\33[33m'
  37. CBLUE   = '\33[34m'
  38. CVIOLET = '\33[35m'
  39. CBEIGE  = '\33[36m'
  40. CWHITE  = '\33[37m'
  41. CYAN  = "\033[1;36m"
  42.  
  43. CBLACKBG  = '\33[40m'
  44. CREDBG    = '\33[41m'
  45. CGREENBG  = '\33[42m'
  46. CYELLOWBG = '\33[43m'
  47. CBLUEBG   = '\33[44m'
  48. CVIOLETBG = '\33[45m'
  49. CBEIGEBG  = '\33[46m'
  50. CWHITEBG  = '\33[47m'
  51.  
  52. CGREY    = '\33[90m'
  53. CRED2    = '\33[91m'
  54. CGREEN2  = '\33[92m'
  55. CYELLOW2 = '\33[93m'
  56. CBLUE2   = '\33[94m'
  57. CVIOLET2 = '\33[95m'
  58. CBEIGE2  = '\33[96m'
  59. CWHITE2  = '\33[97m'
  60.  
  61. CGREYBG    = '\33[100m'
  62. CREDBG2    = '\33[101m'
  63. CGREENBG2  = '\33[102m'
  64. CYELLOWBG2 = '\33[103m'
  65. CBLUEBG2   = '\33[104m'
  66. CVIOLETBG2 = '\33[105m'
  67. CBEIGEBG2  = '\33[106m'
  68. CWHITEBG2  = '\33[107m'
  69. ENDC = '\033[0m'
  70.  
  71.  
  72. arraylength=0
  73.  
  74. # function  definitions
  75.  
  76.  
  77. def f_clearscreen(time_delay):
  78.     os.system('clear')
  79.     time.sleep(time_delay)
  80.     for x in range(2):
  81.         print('')
  82.    
  83.    
  84.  
  85.  
  86. def f_openfile(fileopen):
  87.    
  88.     global paragraphs
  89.     global arraylength
  90.    
  91.     # open the file
  92.     f = open(fileopen, "r")
  93.     # read the open file
  94.     data =f.read()
  95.     # split this into paragrapghs
  96.     paragraphs = data.split("\n\n")
  97.     paragraphs[:] = (value for value in paragraphs if value != '\t')
  98.     #get number of paragraghs
  99.     arraylength = len(paragraphs)
  100.     # sleep 3
  101.    
  102.     time.sleep(4)
  103.     # clear the screen
  104.     os.system('clear')
  105.    
  106.    
  107.        
  108.     f.close()
  109.    
  110. def  readpar_lines(counter):
  111.      # make this global so that functions can see this
  112.     global lines
  113.     lines= paragraphs[counter].splitlines()
  114.    
  115.  
  116.  
  117. def slowPrint():
  118.    
  119.     for line in lines:
  120.         for mychar in line:
  121.             sys.stdout.write(CGREEN + mychar)
  122.             sys.stdout.flush()
  123.             time.sleep(0.05)
  124.     sys.stdout.write(ENDC)
  125.     sys.stdout.flush()
  126.  
  127.  
  128. def slowPrintMsgString(var):
  129.    
  130.     for mychar in var:
  131.         sys.stdout.write(CBLUE + mychar)
  132.         sys.stdout.flush()
  133.         time.sleep(0.05)
  134.     sys.stdout.write(ENDC)
  135.     sys.stdout.flush()
  136.    
  137. # main execution starts here
  138.  
  139. print("Ready")
  140. f_clearscreen(4.00)
  141.  
  142. # get filename
  143. m_file = "instructions"
  144.  
  145. # Print introduction
  146.  
  147. slowPrintMsgString("Good evening all todays tutorial is on how to use git from within QT\n\n")
  148.  
  149. # open this file and split into paragraphs
  150. f_openfile(m_file)
  151.  
  152. # get user input and count
  153. for x in range(arraylength):
  154.     # split each paragraph into lines
  155.     readpar_lines(x)
  156.     slowPrint()
  157.     my_next = raw_input(':')
  158.    
  159. now = datetime.now()
  160. # dd/mm/YY H:M:S
  161. dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
  162. slowPrintMsgString("\n\nThanking you all for watching presentation Mark Harrington " + dt_string +"\n\n" )
  163.  
  164. time.sleep(10)
  165.  
  166. # clear the screen
  167. os.system('clear')
  168.    
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement