toggle_renderer = Gtk.CellRendererToggle() toggle_renderer.set_property("activatable", True) toggle_renderer.connect("toggled", on_toggle) def on_toggle(widget, path): model[path][1] = not model[path][1]
column = Gtk.TreeViewColumn("Check", Gtk.CellRendererToggle(), active=0) def on_toggle(widget, path): model[path][0] = not model[path][0] column.set_cell_data_func(toggle_renderer, on_toggle)In this example, we create a new TreeViewColumn with a CellRendererToggle as the renderer. We set the "active" property to 0, which means that the first column in the model specifies the active state of the toggle button. We also set a cell data function for the renderer, which will be called when the cell data is being displayed. The on_toggle function updates the model when the toggle button is clicked. The package library for the gi.repository Gtk library is PyGObject. It provides Python bindings for the GObject and GLib libraries, as well as the Gtk+ and GStreamer multimedia libraries.