I’m using wxPython 4.0.0b1, on macOS. I have
instantiated a PropertyGrid and have created properties that
display ok. My first time using this widget !!
I want to press a button to do some actions, then update some of
the property values (e.g. serial numbers, etc).
The following reads the values ok, but when nothing updates when I
callSetPropertyValues()
. Adding call to Refresh()
doesn’t
help.
` def on_button_program(self, event):
pg = self.property_grid_1
d = pg.GetPropertyValues(inc_attributes=False)
`` d['SERIAL_NUMBER'] += 1``
`` pg.SetPropertyValues(d, autofill=False)``
`` #pg.Refresh()``
`
If I add `autofill=True` to `SetPropertyValues()` then the
propertygrid does update, but it appends the information instead
of replacing the property data that is already there.
` def on_button_program(self, event):
pg = self.property_grid_1
d = pg.GetPropertyValues(inc_attributes=False)
`` d['SERIAL_NUMBER'] += 1``
`` pg.SetPropertyValues(d, autofill=True)``
`` #pg.Refresh()``
`
I've tried clearing the
property grid before setting new values, but that doesn’t do
anything either.
` def on_button_program(self, event):
pg = self.property_grid_1
d = pg.GetPropertyValues(inc_attributes=False)
`` d['SERIAL_NUMBER'] += 1``
``` pg.Clear()``
` ``
pg.SetPropertyValues(d, autofill=True)``
`` #pg.Refresh()``
`
I've also tried this, instead of `SetPropertyValues()`, but
that causes a crash (I might be using it incorrectly).
` pg.AutoFill(d)``
`
I've also tried this, instead of `ReplaceProperty()`, but I get an
error.
` pg.ReplaceProperty("SERIAL_NUMBER",
wx.propgrid.IntProperty(“SERIAL_NUMBER”, wx.propgrid.PG_LABEL,
sn))``
`
` => GetPropertyByNameA(): no property with name
‘SERIAL_NUMBER’`
Any thoughts on what I'm doing wrong?
What is the best method to update 2 or 3 properties? e.g
increment a serial number, adjust a string property (based on new
serial number), etc?
Thanks, Brendan.