示例#1
0
 def run(self):
   '''run method for drawing the screen to dispay'''
   mainloop = True
   # set index of list to first item
   index = 0
   # use infinity loop for drawing screen
   while mainloop:
     # Limit frame speed to 30 FPS
     self.clock.tick(30)
     for event in pygame.event.get():
       # draw interface on screen
       self.interface.list_interface(self.screen, 
         self.library[index].get_title(), self.library[index].get_artist(),
         self.library[index].get_total_playtime(), self.library[index].get_cover())
       # wit for touchscreen event
       if event.type == pygame.MOUSEBUTTONDOWN:
         # draw circle for touchscreen feedback
         pygame.draw.circle(self.screen, YELLOW, pressed(), 10, 0)
         # update index in library
         index = self.on_click(index)
         # exit mainloop
         if index == 999: mainloop = False
         
     # update display
     pygame.display.flip()
示例#2
0
    def run(self):
        '''run method for drawing the screen to dispay'''
        mainloop = True
        # set index of list to first item
        index = 0
        # use infinity loop for drawing screen
        while mainloop:
            # Limit frame speed to 30 FPS
            self.clock.tick(30)
            for event in pygame.event.get():
                # draw interface on screen
                self.interface.list_interface(
                    self.screen, self.library[index].get_title(),
                    self.library[index].get_artist(),
                    self.library[index].get_total_playtime(),
                    self.library[index].get_cover())
                # wit for touchscreen event
                if event.type == pygame.MOUSEBUTTONDOWN:
                    # draw circle for touchscreen feedback
                    pygame.draw.circle(self.screen, YELLOW, pressed(), 10, 0)
                    # update index in library
                    index = self.on_click(index)
                    # exit mainloop
                    if index == 999: mainloop = False

            # update display
            pygame.display.flip()
示例#3
0
 def on_click(self, index):
   '''recognize touchscreen and mouse selections to 
   run functionalities of buttons'''
   # get actual position of mouse click 
   click_pos = pressed()
   # go back to main screen
   if 10 <= click_pos[0] <= 55 and 190 <= click_pos[1] <= 235:
     return 999
   # scroll to left
   if 155 <= click_pos[0] <= 200 and 190 <= click_pos[1] <= 235:
     index -=1
     # make negative index to max index to start new round
     if index == -1:
       index = len(self.library) -1
     return index
   # scroll to right
   if 210 <= click_pos[0] <= 255 and 190 <= click_pos[1] <= 235:
     index = index + 1
     # set max index to 0 for start new round 
     if index >= len(self.library):
       index = 0
     return index
   # select a book
   if 265 <= click_pos[0] <= 310 and 190 <= click_pos[1] <= 235:
     # select actual book and go to play window
     self.function(self.library[index])
   return index
示例#4
0
 def on_click(self, index):
     '''recognize touchscreen and mouse selections to 
   run functionalities of buttons'''
     # get actual position of mouse click
     click_pos = pressed()
     # go back to main screen
     if 10 <= click_pos[0] <= 55 and 190 <= click_pos[1] <= 235:
         return 999
     # scroll to left
     if 155 <= click_pos[0] <= 200 and 190 <= click_pos[1] <= 235:
         index -= 1
         # make negative index to max index to start new round
         if index == -1:
             index = len(self.library) - 1
         return index
     # scroll to right
     if 210 <= click_pos[0] <= 255 and 190 <= click_pos[1] <= 235:
         index = index + 1
         # set max index to 0 for start new round
         if index >= len(self.library):
             index = 0
         return index
     # select a book
     if 265 <= click_pos[0] <= 310 and 190 <= click_pos[1] <= 235:
         # select actual book and go to play window
         self.function(self.library[index])
     return index
示例#5
0
 def on_click(self):
   ''' recognize touchscreen and mouse selections to 
   run functionalities of buttons '''
   click_pos = pressed()
   # stop music and return to previous screen
   if 10 <= click_pos[0] <= 55 and 190 <= click_pos[1] <= 235:
     self.music.stop()
     return False
   # play previous chapter
   if 65 <= click_pos[0] <= 110 and 190 <= click_pos[1] <= 235:
     self.music.previous_chapter()
   # play next chapter
   if 115 <= click_pos[0] <= 160 and 190 <= click_pos[1] <= 235:
     self.music.next_chapter()
   # pause/unpause the music
   if 165 <= click_pos[0] <= 210 and 190 <= click_pos[1] <= 235:
     self.music.pause()
   # stop the music the music        
   if 215 <= click_pos[0] <= 260 and 190 <= click_pos[1] <= 235:
     self.music.stop()
   # play the music
   if 265 <= click_pos[0] <= 310 and 190 <= click_pos[1] <= 235:
     self.music.play()
   # skip to selected position on the progress bar 
   if 10 <= click_pos[0] <= 310 and 160 <= click_pos[1] <= 185:
     self.music.set_pos(click_pos[0])
   return True
示例#6
0
 def on_click(self):
     ''' recognize touchscreen and mouse selections to 
   run functionalities of buttons '''
     click_pos = pressed()
     # stop music and return to previous screen
     if 10 <= click_pos[0] <= 55 and 190 <= click_pos[1] <= 235:
         self.music.stop()
         return False
     # play previous chapter
     if 65 <= click_pos[0] <= 110 and 190 <= click_pos[1] <= 235:
         self.music.previous_chapter()
     # play next chapter
     if 115 <= click_pos[0] <= 160 and 190 <= click_pos[1] <= 235:
         self.music.next_chapter()
     # pause/unpause the music
     if 165 <= click_pos[0] <= 210 and 190 <= click_pos[1] <= 235:
         self.music.pause()
     # stop the music the music
     if 215 <= click_pos[0] <= 260 and 190 <= click_pos[1] <= 235:
         self.music.stop()
     # play the music
     if 265 <= click_pos[0] <= 310 and 190 <= click_pos[1] <= 235:
         self.music.play()
     # skip to selected position on the progress bar
     if 10 <= click_pos[0] <= 310 and 160 <= click_pos[1] <= 185:
         self.music.set_pos(click_pos[0])
     return True
示例#7
0
 def run(self):
   '''run method for drawing the screen to dispay'''
   mainloop = True
   while mainloop:
     # Limit frame speed to 30 FPS
     self.clock.tick(30)
     # draw interface to screen
     self.interface.player_interface(self.screen, self.book.get_title(),
       self.book.get_artist(), self.music.get_chapter() + 1, self.book.get_num_chapter(),
       self.book.get_chapter_playtime()[self.music.get_chapter()], 
       self.music.get_pos(), self.book.get_cover())
     for event in pygame.event.get():
       if event.type == pygame.USEREVENT:
         # start playing next chapter when a song ends
         self.music.next_chapter()
       # wait for touchscreen pressed
       if event.type == pygame.MOUSEBUTTONDOWN:
         # draw touchscreen feedback to screen
         pygame.draw.circle(self.screen, YELLOW, pressed(), 10, 0)
         # run functionalities
         mainloop = self.on_click()
     # update display
     pygame.display.flip()
示例#8
0
 def run(self):
     '''run method for drawing the screen to dispay'''
     mainloop = True
     while mainloop:
         # Limit frame speed to 30 FPS
         self.clock.tick(30)
         # draw interface to screen
         self.interface.player_interface(
             self.screen, self.book.get_title(), self.book.get_artist(),
             self.music.get_chapter() + 1, self.book.get_num_chapter(),
             self.book.get_chapter_playtime()[self.music.get_chapter()],
             self.music.get_pos(), self.book.get_cover())
         for event in pygame.event.get():
             if event.type == pygame.USEREVENT:
                 # start playing next chapter when a song ends
                 self.music.next_chapter()
             # wait for touchscreen pressed
             if event.type == pygame.MOUSEBUTTONDOWN:
                 # draw touchscreen feedback to screen
                 pygame.draw.circle(self.screen, YELLOW, pressed(), 10, 0)
                 # run functionalities
                 mainloop = self.on_click()
         # update display
         pygame.display.flip()