[Solved] PropertyGrid: Set unspecified value text

After creating a pg = wx.propgrid.PropertyGrid(…) I can access the string, which will be displayed, if a property has an unspecified value with pg.GetUnspecifiedValueText().

How would I set that to a different value, e.g. to '<Unspecified>'.

I tried

  • pg.SetUnspecifiedValueText('<Unspecified>') but get an AttributeError.
  • pg.UnspecifiedValue = '<Unspecified>' does not work either.

I think you can perhaps use pg.SetUnspecifiedValueAppearance()?

https://docs.wxpython.org/wx.propgrid.PropertyGrid.html?highlight=propertygrid#wx.propgrid.PropertyGrid.SetUnspecifiedValueAppearance

Thanks, that worked:

# To keep fore- and background color for cells with unspecified value, get the current appearance
cell = pg.GetUnspecifiedValueAppearance()
# Set the text
cell.SetText('<Unspecified>')
# Update the appearance
pg.SetUnspecifiedValueAppearance(cell)

I was disheartened to look into this method because I thought it is all about the appearance (colours, fonts, …) and not the text displayed.