0

I have some python2 code that I'im migrating to python3 as python2 will reach EOL soon. And in so doing I'm also migrating from gtk2 to gtk3 via GIR. However, I am unable to find any proper documentation on how to do so.

I have the following snippets in my code that I'd like to change:

pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,width,height)
pixbuf.get_from_drawable(
gtk.gdk.get_default_root_window(),
gtk.gdk.colormap_get_system(),
0,0,0,0,
width,height)
pixbuf.save(...)
gtk.gdk.screen_width()
gtk.gdk.screen_width()

I came across https://lazka.github.io/pgi-docs/ and https://developer.gnome.org/pygtk/stable/class-gdkpixbuf.html, but I'm kinda new to python and GTK and am not able to figure out the equivalent transformations

Any references to documentation would help too.

liberforce
  • 11,189
  • 37
  • 48
Rohit Sukumaran
  • 163
  • 1
  • 2
  • 10

1 Answers1

0

You will find the replacement class for GdkPixbuf here:

For the changes from GTK+ 2 to GTK+ 3, they are mostly documented in the C documentation, unless I overlooked something.

You'll find a tutorial on GTK+ 3 with python here:

liberforce
  • 11,189
  • 37
  • 48
  • sifting through all that definitely wasn't easy. But I managed to get it done once I realized The code snippets I used were basically taking a screenshot. Found that here: https://stackoverflow.com/questions/20816280/pygtk3-pygobject-to-create-screenshot. Thanks anyway – Rohit Sukumaran Feb 27 '19 at 06:35
  • Sorry, I thought that you knew you were taking a screenshot. That's basically what getting the root window and saving the pixels in it is. – liberforce Feb 27 '19 at 09:13
  • This isn't my code and I just needed to do the migration. But thanks for the references @liberforce. I will need it now. – Rohit Sukumaran Feb 28 '19 at 10:35