Set column width of wx.propgrid.PropertyGridManager

I’m trying to use wx.propgrid.PropertyGridManager in a dialog, but am having lots of trouble getting it to display nicely. Platform is Windows 10.

I have used it before with Linux/GTK and don’t recall having these issues, though the layout was a little more complicated (lots of other widgets) and it was within in Frame (not a dialog).

Are there any methods to auto-size a column? I couldn’t find anything.

Are there any methods to set the minimum size of a column?

I tried pg.Grid.FitColumns() but that didn’t seem to do anything.

The wxdemo looks ok, but it uses an auto-centre splitter. The sizer area is big enough that the text looks ok. If make the window frame as small as possible then some of the first column text is cropped, but the sizer has a minimum size which restricts the frame from being set too small.

I don’t really want to use auto-centre splitter. I want the first column to be a fixed size that fits the data, and I want the second column to grow if the frame is resized.

I feel like everthing is setup ok. Here is the code that wxglade has generated for the dialog.

class Settings_Dialog_WXG(wx.Dialog):
    def __init__(self, *args, **kwds):
        # begin wxGlade: Settings_Dialog_WXG.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.STAY_ON_TOP
        wx.Dialog.__init__(self, *args, **kwds)
        self.settings_sizer = wx.BoxSizer(wx.VERTICAL)
        self.property_grid_1 = wx.propgrid.PropertyGridManager(self, wx.ID_ANY, style=wx.propgrid.PG_BOLD_MODIFIED)
        self.settings_sizer.Add(self.property_grid_1, 1, wx.EXPAND, 0)
        self.settings_sizer.Add((0, 0), 0, 0, 0)
        # end wxGlade

My derived class looks like this:

class Settings_Dialog ( Settings_Dialog_WXG ) :

    def __init__ ( self, *args, **kwds ) :
        super().__init__( *args, **kwds )

        pg = self.property_grid_1

        pg.AddPage( "Page 1" )  #! Required if using `PropertyGridManager` instead of `PropertyGrid`

        pg.Append( wxpg.PropertyCategory( "Rings" ) )

        pg.Append( wxpg.FloatProperty( label="diameter lower limit", name="diameter_limit_lower" ) )

        pg.Append( wxpg.FloatProperty( label="diameter upper limit", name="diameter_limit_upper" ) )

        settings_dict = \
                            'diameter_limit_lower': 1.123, 'diameter_limit_upper': 2.234,

        pg.SetPropertyValues( settings_dict, autofill=True )  


        # self.settings_sizer.Fit( self )
        # self.settings_sizer.SetSizeHints( self )
        # self.Layout()
        # self.Refresh()

        # self.SetAutoLayout( True )
        # self.Fit()
        # self.Layout()
        # self.Fit()
        # self.Layout()

Any ideas why the above doesn’t render nicely in my dialog ?

Thanks, Brendan.