Python GTK: Scrollable Grid with clickable images

Question:

I’m writing an python program (gui in gtk) (linux btw.)
I want to have a (scrollable) grid of images that are clickable like buttons.

I’m planning to have 3 images per line, show 2 lines and then scroll vertically through the rest.

I don’t really know which elements to use, a Gtk.Grid, a Gtk.table or something else ?
Should I use a image and make it clickable or should I use a Gtk.Button and make it look like an image ?

Would really appreciate any help 🙂

Asked By: Ansgar

||

Answers:

I think you’re on the right track. The widgets I’d use are:

Gtk.ScrolledWindow
  Gtk.Grid
    Gtk.Button
    Gtk.Button
    ...
    Gtk.Button

I’m not really aware of the advantages of using Gtk.Grid over Gtk.Table, but I see it’s the default widget now in glade, so I’d stick to the defaults.

Regarding using a Gtk.Image or Gtk.Button, it’s documented how to display an image in a button, but I’d say isn’t so easy to make an image clickable because that’s not an event supported out of the box by image widgets. Hence, the safest approach in my opinion is to use buttons.

Answered By: jcollado
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.