title: How do I run the pyglet.window.clear function through a on_button_press event?
body: <p>Long story short I'm making a text based game in python 3 using Pyglet and I'm having trouble clearing the window. I want to clear out everything so I can put new words and new pictures in. I was hoping to set it up like this:</p>
  
  <pre><code>@window.event
  def on_key_press(key.escape,modifier)
      window.clear
  </code></pre>
  
  <p>Or something along those lines but it doesn't seem to work. Does anyone have any suggestions, ideas? the only other idea would be to convert the words to black and any images to black and layer it up but then the window will still be loading that stuff and I could see as the game goes on it starts eating up more and more ram to run the window with it loading all the previous pictures and text.</p>
  
  <p>I'd prefer to avoid that and just clear it out, also then I don't have to basically copy the same code over and over again making it black. </p>
  
  <p>Thanks,
   Ben</p>