title: Pyglet unstable frame rate
body: <p>I am trying to create a simple program in Pyglet that shows an animation and retrieves some mouse input and saves it to a text file. The code I have shows a significant unstable frame rate even when I am not using the mouse.</p>
  
  <p>I have also looked at similar questions and the answers suggest to use a subclassed window, or to call the function <code>on_draw</code> with <code>schedule_interval</code>. I do not know, however, how to use a subclassed window to display my animation and, when I try to call <code>on_draw</code> with <code>schedule_interval</code> I get the error that <code>on_draw</code> does not receives any argument.</p>
  
  <p>This is part of the code I am using:</p>
  
  <pre><code>fps = pyglet.clock.ClockDisplay()# Show FPS
  
  @mywindow.event
  def on_mouse_press(x, y, button, modifiers):
      global timeStart, file, count
      timeNow = time.clock() - timeStart
  
      if button == mouse.LEFT:
          print('left click press in {}').format(timeNow)
          with open(out_file_name, 'a') as file:
              file.write(str(count) +'\t'+ str(timeNow) +'\t'+ '-1\n')
              #file.write('' + count + timeNow + 'left click press\n')                 
      count += 1
  
  def update_frames(dt):
      global x
      x=x+1
  
  @mywindow.event
  def on_draw():
      pyglet.gl.glClearColor(0,0,0,0)
      mywindow.clear()
      glColor4f(1,0,0,1)
      drawSquare(x,y)#this draws an opengl square
      fps.draw()# Show FPS
  
  
  dt = 1/10.0
  pyglet.clock.schedule_interval(update_frames,dt)
  pyglet.app.run()
  </code></pre>
  
  <p>What can I add to the code in order to obtain an stable frame rate?</p>