Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # Ideal for presentations desktop recordings where you need hands free
- # Tested on openSUSE 15.3
- # A small python script that will read a text file in , split this into paragraphs
- # then prints line by line the characters of that paragraph in slow motion in a Linux terminal
- # according to prompt from user
- # Colours of text are interchangeable
- # Speed can be altered for slow motion print of chars Introductory messages and end message changeable Enjoy Mark Harrington
- from datetime import datetime
- import argparse
- import time
- import sys
- import os
- # Author MD Harrington Facebook https://www.facebook.com/mark.harrington.142892 links to this there as well for you
- #
- # You need to include a text file in your folder with the python script make sure ecah paragraph is seperated by two
- # line breaks
- # usage :: python paragraphs.py
- # python version Python 2.7.14
- # You can also download this from git hub
- # https://github.com/markh2016/pyReadparagraphs.git
- # global colour settings
- CBLACK = '\33[30m'
- CRED = '\33[31m'
- CGREEN = '\33[32m'
- CYELLOW = '\33[33m'
- CBLUE = '\33[34m'
- CVIOLET = '\33[35m'
- CBEIGE = '\33[36m'
- CWHITE = '\33[37m'
- CYAN = "\033[1;36m"
- CBLACKBG = '\33[40m'
- CREDBG = '\33[41m'
- CGREENBG = '\33[42m'
- CYELLOWBG = '\33[43m'
- CBLUEBG = '\33[44m'
- CVIOLETBG = '\33[45m'
- CBEIGEBG = '\33[46m'
- CWHITEBG = '\33[47m'
- CGREY = '\33[90m'
- CRED2 = '\33[91m'
- CGREEN2 = '\33[92m'
- CYELLOW2 = '\33[93m'
- CBLUE2 = '\33[94m'
- CVIOLET2 = '\33[95m'
- CBEIGE2 = '\33[96m'
- CWHITE2 = '\33[97m'
- CGREYBG = '\33[100m'
- CREDBG2 = '\33[101m'
- CGREENBG2 = '\33[102m'
- CYELLOWBG2 = '\33[103m'
- CBLUEBG2 = '\33[104m'
- CVIOLETBG2 = '\33[105m'
- CBEIGEBG2 = '\33[106m'
- CWHITEBG2 = '\33[107m'
- ENDC = '\033[0m'
- arraylength=0
- # function definitions
- def f_clearscreen(time_delay):
- os.system('clear')
- time.sleep(time_delay)
- for x in range(2):
- print('')
- def f_openfile(fileopen):
- global paragraphs
- global arraylength
- # open the file
- f = open(fileopen, "r")
- # read the open file
- data =f.read()
- # split this into paragrapghs
- paragraphs = data.split("\n\n")
- paragraphs[:] = (value for value in paragraphs if value != '\t')
- #get number of paragraghs
- arraylength = len(paragraphs)
- # sleep 3
- time.sleep(4)
- # clear the screen
- os.system('clear')
- f.close()
- def readpar_lines(counter):
- # make this global so that functions can see this
- global lines
- lines= paragraphs[counter].splitlines()
- def slowPrint():
- for line in lines:
- for mychar in line:
- sys.stdout.write(CGREEN + mychar)
- sys.stdout.flush()
- time.sleep(0.05)
- sys.stdout.write(ENDC)
- sys.stdout.flush()
- def slowPrintMsgString(var):
- for mychar in var:
- sys.stdout.write(CBLUE + mychar)
- sys.stdout.flush()
- time.sleep(0.05)
- sys.stdout.write(ENDC)
- sys.stdout.flush()
- # main execution starts here
- print("Ready")
- f_clearscreen(4.00)
- # get filename
- m_file = "instructions"
- # Print introduction
- slowPrintMsgString("Good evening all todays tutorial is on how to use git from within QT\n\n")
- # open this file and split into paragraphs
- f_openfile(m_file)
- # get user input and count
- for x in range(arraylength):
- # split each paragraph into lines
- readpar_lines(x)
- slowPrint()
- my_next = raw_input(':')
- now = datetime.now()
- # dd/mm/YY H:M:S
- dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
- slowPrintMsgString("\n\nThanking you all for watching presentation Mark Harrington " + dt_string +"\n\n" )
- time.sleep(10)
- # clear the screen
- os.system('clear')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement