title: Creating a screenshot of a gtk.Window
body: <p>For testing and documentation purposes I would like to create a screenshot of a gtk.Window object. I'm following a basic pygtk sample at the moment. The example with my modifications looks like the following:</p>
  
  <pre><code>import gtk
  
  def main():
      button = gtk.Button("Hello")
      scroll_win = gtk.ScrolledWindow()
      scroll_win.add(button)
      win = gtk.Window(gtk.WINDOW_TOPLEVEL)
      win.add(scroll_win)
      win.show_all()
  
      if win.is_drawable() is not True:
          raise RuntimeError("Not drawable?")
  
      width, height = win.get_size()
      pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8,
                              width, height)
      screenshot = pixbuf.get_from_drawable(win, win.get_colormap(),
                                            0, 0, 0, 0, width, height)
      screenshot.save('screenshot.png', 'png')
  
  if __name__ == '__main__':
      main()
      gtk.main()
  </code></pre>
  
  <p>I'm ending up with an error when the get_from_drawable method is invoked.</p>
  
  <pre><code>TypeError: Gdk.Pixbuf.get_from_drawable() argument 1 must be gtk.gdk.Drawable, not gtk.Window
  </code></pre>
  
  <p>Apparently <a href="https://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-linux/782768#782768">the screenshot example</a> that I merged into the basic example is using a gtk.gdk.Window that inherits from gtk.gdk.Drawable.</p>
  
  <p>My questions:</p>
  
  <ul>
  <li>Is there another way to make the Pixbuf object capture the window?</li>
  <li>Can I make a gtk.Window a gtk.gdk.Window or find the gtk.gdk.Window functionality within the gtk.Window?</li>
  </ul>