title: How to output text to a screen, while also outputting Object Orientated buttons - Pygame
body: <pre><code>#Importing Modules
  import pygame
  import sys
  import random
  
  #All pygame stuff under here
  pygame.init()
  
  #Font definitions
  backFont = pygame.font.SysFont("monospace",40)
  titleFont = pygame.font.SysFont("garamond", 100)
  buttonFont = pygame.font.SysFont("garamond", 25)
  bigFont = pygame.font.SysFont("garamond",100)
  
  #Colour definitions
  BackGray = pygame.Color('gray60')
  screenGray = pygame.Color('gray80')
  buttonGray1 = pygame.Color('gray40')
  buttonGray2 = pygame.Color('gray50')
  buttonGray3 = pygame.Color('gray30')
  textColour = pygame.Color('navy')
  
  #Screen size set
  screen = pygame.display.set_mode((800, 600))
  
  #Class for the buttons set here
  class Button:
      def __init__(self, x, y, width, height, colour, surface):
          self.x = x
          self.y = y
          self.height = height
          self.width = width
          self.colour = colour
          self.surface = surface
  
      def isPressed(self):
          mouse_position = pygame.mouse.get_pos()
          mouse_x = mouse_position[0]
          mouse_y = mouse_position[1]
          if mouse_x &gt; self.x:
              if mouse_x &lt; self.x + self.width:
                  if mouse_y &gt; self.y:
                      if mouse_y &lt; self.y + self.height:
                          mouse_click = pygame.mouse.get_pressed()
                          left_click = mouse_click[0]
                          if left_click:
                              self.colour = (0,0,0)
                              return True
          self.colour = (230, 230, 230)
          return False
  
      def drawButton(self):
          pygame.draw.rect(self.surface, self.colour,  (self.x, self.y, self.width, self.height))
          pygame.display.flip()
  
  def FrontPage():
      #Back screen
      screen.fill(screenGray)
  
      #The background is defined here
      BinaryPage = []
      for i in range(0,15):
          BinaryString = ""
          for j in range(0,33):
              BinaryString += random.choice(["0","1"])
          BinaryPage.append(BinaryString)
  
      for i in range(0,15):
          screen.blit(backFont.render(BinaryPage[i], 1, BackGray), (0,i * 40))
  
      #The title is defined and printed here
      Title1 = titleFont.render("The Six", 10, textColour)
      Title2 = titleFont.render("Cipher", 10, textColour)
      Title3 = titleFont.render("Simulator", 10, textColour)
      screen.blit(Title1, (100, 100))
      screen.blit(Title2, (100, 200))
      screen.blit(Title3, (100, 300))
  
      #Text for the button
      buttonText = buttonFont.render("Continue", 10, textColour)
      screen.blit(buttonText, (115,405))
  
      #Where the buttons are defined and drawn
      ButtonBig = Button(100, 450, 120, 60, buttonGray1, screen)
      ButtonSmall = Button(105, 455, 110, 50, buttonGray2, screen)
      ButtonBig.drawButton()
      ButtonSmall.drawButton()
  
  
      #Pygame While loop
      clock = pygame.time.Clock()
      while True:
          for event in pygame.event.get():
              if ButtonBig.isPressed():
                  print("Hello")
                  break
              if event.type == pygame.QUIT:
                  pygame.quit()
                  sys.exit()
  
          clock.tick(60)
  </code></pre>
  
  <p>The above code runs a window that has 0's and 1's in a random order as the background, with the title of my program in the middle.</p>
  
  <p>Then, there should be a button at the bottom, or a grey rectangle. However, when I try to .blit, or print, something onto the button frame, after I have drawn the button onto the screen, it does not appear. </p>
  
  <p>Can anybody tell me why and how to fix it?
  Or any alternatives of how to output text onto the buttons.</p>
  
  <p>Thanks in advance</p>