Advertisement
Guest User

Display Notes (GUI)

a guest
Oct 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.03 KB | None | 0 0
  1. import pygame
  2. pygame.font.init()
  3.  
  4.  
  5. x = 1440  # Length of Macbook Pro 13" screen
  6. y = 805  # height of Macbook Pro 13" screen
  7. screenSize = (x, y)  # Creates a tuple containing screen dimensions
  8. screen = pygame.display.set_mode(screenSize)  # Creates a screen with dimensions (x,y) px
  9. pygame.display.set_caption('Piano Tutor')  # Sets the name of the window
  10. clock = pygame.time.Clock()  # Initialises the Pygame clock
  11.  
  12. colours = {"white": (255, 255, 255), "black": (0, 0, 0), "dark_green": (0, 150, 0), "light_green": (0, 255, 0),
  13.            "light_dark_blue": (72, 94, 108)}  # A colour dictionary that returns RBG colour values
  14. font = pygame.font.SysFont(None, 48)  # Sets the font to the default font (hence 'None') and gives it a size
  15. small_font = pygame.font.SysFont(None, 20)
  16.  
  17. ########################################################################################################################
  18.  
  19. song = ['A','B','C','D','E','F','END']
  20. current_count = -1
  21. next_count = 0
  22.  
  23. done = False
  24.  
  25. while True:    # When any subprogram finishes, the program lands here
  26.     for event in pygame.event.get():
  27.         if event.type == pygame.QUIT:
  28.             pygame.quit()
  29.             quit()
  30.         screen.fill((255, 255, 255))
  31.  
  32.         for item in song:  # For each note in the song array...
  33.             current_count = current_count + 1
  34.             next_count = next_count + 1
  35.  
  36.             if item != "END":  # If it isn't the terminating item...
  37.                 current_note = item  # Sets the current note to the item being iterated over in the list. This is done for readability
  38.                 text_current_note = font.render(current_note, True, colours["black"])
  39.  
  40.                 next_note = song[next_count]  # Sets the next note to the next position along in the list
  41.                 text_next_note = font.render(next_note, True, colours["black"])
  42.  
  43.                 if next_note == song[-1]:  # If the next_note is "END"
  44.                     next_note = " "  # Displays a blank space rather than END
  45.                     text_next_note = font.render(next_note, True, colours["black"])
  46.  
  47.                 if current_note == song[0]:  # If the current note is the beginning
  48.                     previous_note = " "  # Displays a blank space in the previous note space (prevents errors too!)
  49.                     text_previous_note = font.render(previous_note, True, colours["black"])
  50.  
  51.                 else:  # If the current note is not at the beginning
  52.                     previous_note = song[current_count - 1]  # Sets the previous note to the previous position in the list
  53.                     text_previous_note = font.render(previous_note, True, colours["black"])
  54.  
  55.                 #print("| {0} | {1} | {2} |".format(previous_note, current_note, next_note))  # Displays the notes
  56.                 #played_note = input(">").upper()  # Gets the input
  57.  
  58.                 screen.blit(text_previous_note, (250, 385))
  59.                 screen.blit(text_current_note, (400, 385))
  60.                 screen.blit(text_next_note, (550, 385))
  61.  
  62.     pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement