![]() The tasks are added to a list and saved in a. Tinkerer, maker, hacker, teacher, writer, learner, failure.I'm doing a simple task manager program. If you would like to fork the code, then please do so. Change the size and colour of the window?Īll of the code and the video to illustrate how this works can be downloaded from Github If you would like to use it / remix it.GO FOR IT!.A GUI to load the file that we wish to read?.Perhaps a slider to control the speed of the text?.In the Python 3 editor, click on Run > Run Module to start the code.now brace yourself for some super sonic speed reading! Taking it further How can we improve this project? We now come out of the two for loops and our last line of code is used to close the Pygame window once all of the text has been read. Then we update the display to ensure that the changes are are rendered correctly. Then we fill the window with our background black colour. So after rendering the word we need to give the reader time to read it, so 1/5 of a second 0.2 seconds is plenty of time. text = myfont.render(word,1,(0,255,0))Īfter each word is rendered to the screen, we need to clear the display otherwise we get word soup.words rendered on top of words that become unreadable. Lastly we update the display to show the text in the window. In this case we set it to 300 pixels (x axis) and 300 pixels (y axis). We then use the blitter to load the text into memory and place it in a certain position on the screen. It will render the text green (0,255,0 is R,G,B) as we set Green to 255, the maximum value possible. Inside of the for loop we now create an object called text and this is used to render each word that we have split. The Python editor will automatically indent our code, but remember that it is either four spaces, or one tab key press. Now from each line we want to read word by word, so another for loop, nested inside the previous, is used to split the line into a series of words, exactly how a sentence is constructed. We use a for loop to read the text from our file, line by line. Remember to change the filename to something that you want to read! And for best results use a plain text file, not a Office or other filetype. The file name is the full path to find the file, in this case I used /home/les/text.txt and use "r" to open in read only mode. We create an object called f (short for file) and in there we store the output of opening a file and reading its contents. Now we come to opening an external file that contains the text that we wish to speed read. Now lets create an object that will store the setup of our font. Then we shall fill our window with a black background. Now lets create a background colour, in this case 0,0,0 (R,G,B) which is Black. Our text will be contained inside a window, which we shall call screen so lets set our window to 800 by 600 pixels screen = _mode((800,600)) To use Pygame we need to initialise it, in particular we will be using the font class. The second library is time and it is used to control the speed of text to our window. The first is Pygame, which we shall later use to create a custom window to contain our text. ![]() ![]() We start our code by importing two libraries of pre-written code. In the new window click on File > Save and name your file speed-reader.py So click on File > New to open a new blank window. Handy for testing logic, but not useful for writing a large amount of code. Now when the editor opens, we will see a Python Shell, in here we can issue quick commands to Python, and get instant responses. Go the Programming menu and select Python3 So lets assume that we are using a Raspberry Pi. But it can be easily installed using pip3. This powerful library comes pre-loaded with Raspbian for your Raspberry Pi so there is no installation necessary. The code to accomplish this project uses the PyGame library a library of code that enables users to create games and multimedia content using Python. If the words are printed in one location we can increase the speed at which we can read, in fact we can increase the speed quite dramatically. But we can improve our speed using a little logic and a some Python code. Reading generally involves our eyes scanning a page of text looking for the next word in the sequence. For some Friday Fun this week we shall create a Python application that will help us to read MUCH more quickly.
0 Comments
Leave a Reply. |