Ever wondered how you can achieve a layout like below with GTK? Well you can, it is slightly hacky, but very quick to implement – which suits me🙂
Unfortunately Gtk.IconView doesn’t have a set_rows() function, but it does have a set_columns() function, which we can use.
All you have to do is call the set_columns() function on the Gtk.IconView and change the default value of -1 (i.e. vary the number of columns based on the width it is given) to a high number, I use 999.
[...] myiconview.set_columns(999); [...]
Now the IconView will fill up until that number of columns, and then start a new row, however if the number is high enough, it will never reach it and therefore never start a new row!
If you wanted to do something less hacky and more clever, you could find out the number of items that will be in the IconView, and then set the number of columns to that number to achieve the same effect.