diff --git a/etg/propgridiface.py b/etg/propgridiface.py index 306f6b7d..158447ef 100644 --- a/etg/propgridiface.py +++ b/etg/propgridiface.py @@ -110,11 +110,24 @@ def run(): if m.type == 'wxPropertyGridConstIterator': m.ignore() - c.find('SetPropertyValue').findOverload('int value').ignore() - c.find('SetPropertyValue').findOverload('bool value').ignore() - c.find('SetPropertyValue').findOverload('wxLongLong_t value').ignore() - c.find('SetPropertyValue').findOverload('wxULongLong_t value').ignore() - c.find('SetPropertyValue').findOverload('wxObject *value').ignore() + spv = c.find('SetPropertyValue') + spv.findOverload('int value').ignore() + spv.findOverload('wxLongLong_t value').ignore() + spv.findOverload('wxULongLong_t value').ignore() + spv.findOverload('wxObject *value').ignore() + + # Reorder SetPropertyValue overloads so the one taking a long int is not + # first. Mark others that could be auto-converted from int as + # "constrained" so they will only be used for that specific type. This + # should result in SetPropertyValue(id, double) only used for floats and + # not ints, opr other things that can convert to int. + spv.findOverload('bool value').find('value').constrained = True + spv.findOverload('double value').find('value').constrained = True + spv_long = spv.findOverload('long value') + spv_long.ignore() + spv.reorderOverloads() # Ensures an ignored item is not first, + spv_long.ignore(False) # and then we can unignore it. + c.find('Append.property').transfer = True c.find('AppendIn.newProperty').transfer = True diff --git a/unittests/test_propgridiface.py b/unittests/test_propgridiface.py index 5d4fa20f..1a7a53c3 100644 --- a/unittests/test_propgridiface.py +++ b/unittests/test_propgridiface.py @@ -16,6 +16,19 @@ class propgridiface_Tests(wtc.WidgetTestCase): iface = pg.PropertyGridInterface() + def test_propgridiface03(self): + # Ensure SetPropertyValue doesn't truncate floats + pgrid = pg.PropertyGrid(self.frame) + pgrid.Append(pg.FloatProperty('Float', value=123.456)) + + value = pgrid.GetPropertyValue('Float') + assert type(value) is float + assert value == 123.456 + + pgrid.SetPropertyValue('Float', 654.321) + value = pgrid.GetPropertyValue('Float') + assert type(value) is float + assert value == 654.321 #---------------------------------------------------------------------------