My sample code below creates a 2 row x 10 column Grid. The len() of the Grid seems to print the number of widgets within, not the row or column count. How can I get the column count?
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
window = Gtk.Window()
window.connect("destroy", Gtk.main_quit)
grid = Gtk.Grid(column_homogenous=True)
for i in range(5):
grid.add(Gtk.Label(str(i)))
grid.attach(Gtk.Label("123456789A"), 0, 1, 10, 1)
window.add(grid)
window.show_all()
print(len(grid))
Gtk.main()
I have considered the following:
- Loop over child widgets and find MAX(width + column)
- Connect to Gtk.Grid signal emitted when column is added and update counter.
Problem with (1) is that it seems like it'll be slow when my Grid contains 1000s of children. Problem with (2) is that I don't see a documented signal for this purpose.