Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1
Play_Music(SongList,SongNumber)
SongNumber = SongNumber + 1
#
while True:
# Introduction Screen ##############################
#
PrezScreen.fill(ScreenColor)
#
# Put Intro Text Line 1 above Center of Screen
IntroText1Location = IntroText1.get_rect()
IntroText1Location.center = AboveCenterScreen
PrezScreen.blit(IntroText1,IntroText1Location)
#
# Put Intro Text Line 2 at Center of Screen
IntroText2Location = IntroText2.get_rect()
IntroText2Location.center = CenterScreen
PrezScreen.blit(IntroText2,IntroText2Location)
#
display.update()
#
#Get HD Pictures ###################################
#
for Picture in listdir(PictureDirectory):
if Picture.endswith(PictureFileExtension):
Picture = PictureDirectory + '/' + Picture
#
Picture = image.load(Picture)
#
for Event in event.get():
#
if Event.type == USEREVENT:
if SongNumber < MaxSongs:
Play_Music(SongList,SongNumber)
SongNumber = SongNumber + 1
if SongNumber >= MaxSongs:
SongNumber = randint(0,MaxSongs - 1)
Play_Music(SongList,SongNumber)
SongNumber = MaxSongs #Keep it random
#
if Event.type in (QUIT,KEYDOWN):
Graceful_Exit()
#
# If Picture is bigger than screen, scale it down.
if Picture.get_size() > PrezScreenSize:
Picture = transform.scale(Picture,Scale)
#
PictureLocation=Picture.get_rect() #Current location
PictureLocation.center=CenterScreen #Put in center
#
#Display HD Images to Screen #################3
PrezScreen.fill(ScreenColor)
PrezScreen.blit(Picture,PictureLocation)
display.update()
#
# Quit with Keyboard if Desired
for Event in event.get():
if Event.type in (QUIT,KEYDOWN):
Graceful_Exit()

Remember that you can also get a copy of these scripts from the publisher’s website. That way, you

Free download pdf