I can't add Gtk.Image to Gtk.GridView (python&gtk4)

grid = Gtk.GridView()

class NM(GObject.Object):
name = GObject.Property(type=str)
def init(self, name):
self.name = name

ls = Gio.ListStore()
for i in range(20):
ss = Gtk.SingleSelection()
factory = Gtk.SignalListItemFactory()

def f_setup(fact, item):
img = Gtk.Image()
factory.connect(“setup”, f_setup)

def f_bind(fact, item):
factory.connect(“bind”, f_bind)


First of all, this code is incomprehensible and incomplete. Please use the forum’s code formatting tool and include a minimum working example, if possible, include information such as error messages too.

That said, Gtk.Image does not have a set_selectable() method.

1 Like

I don’t know how to secure the code

I took this example:
GTK4PythonTutorial/part1.py at main · Taiko2k/GTK4PythonTutorial · GitHub
and replaced Gtk.Label with a Gtk.Image

You cannot take a widget and replace it randomly with another one: different classes have different methods.

1 Like

Okay, if you’re learning, which is what it seems like, I recommend starting here.

There are several basic concepts that you need to understand to be able to use Gtk correctly.

I know the amount of initial information and the forum can be a little intimidating, but you’re welcome and feel free to ask questions.

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.