I want to write a pygame programme where I am receiving data from a Raspberry Pi over a socket connection. However I only want the Pygame code to run once the string has arrived. This involves the code waiting for some time, then when a string is received from the Raspberry Pi, pygame runs code to update the display.
Currently my Pygame freezes and shuts down when waiting for data to income. 
Any ideas. Thanks.
Pygame "freezes" is most likely due to the network call being blocking. Consider spinning a new thread to handle the data communication while Pygame takes over the main thread and updates the display with some "waiting" message. Once you have received the data, the second thread should pass it to the main thread which will display it.
Only running Pygame display code once data revieved from python socket connection