Do_size_allocate in gtk4

Hi all. I’m trying to set ColumnViewColumns to a fixed width when the ScrolledWindow they’re inside has its size allocated. This is so I can make the columns all nicely take up available space.

I see in gtk4 this has all changed. I’ve found I can create a do_size_allocate() method, but when I put this in it:

    def do_size_allocate( self, width: int, height: int, baseline: int ) -> None:
        print( "Total Width: {0}".format( width ) )
        for d in self._column_definitions:
            if d['x_percent']:
                this_width = width / ( 100 / d['x_percent'] )
                print( " column {0} ==> width {1}".format( d['name'] , this_width ) )
                d['cvc'].set_fixed_width( width / ( 100 / d['x_percent'] ) )

… I get errors:

(python:278899): Gtk-WARNING **: 12:14:07.228: Trying to snapshot GtkColumnView 0x55e823e6e290 without a current allocation

… and also the ColumnView doens’t work properly at all ( I get a single column that takes up all the width, but doesn’t display anything ). However the logic ( for setting column widths ) appears to be working correctly:

Total Width: 917
 column template_name ==> width 229.25
 column param_name ==> width 229.25
 column param_desc ==> width 229.25
 column param_default ==> width 229.25

Does anyone know what’s going on?

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