diff --git a/CHANGES.rst b/CHANGES.rst index d94522ba..d2a0be38 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -80,7 +80,7 @@ Changes in this release include the following: * Update SizedControls to do a sanity check on the parent's sizer, as GetSizer can return None for SizedParent under certain circumstances, such as when - AUI reparents the control during pane movement. (#523) + AUI reparents the control during pane movement. (#523, #537) * Added Vagrant configs for Fedora 23 and Fedora 26, and dropped Fedora 24. Wheels built on F23 can also be used on F24 and F25, and F26 adds Python 3.6 diff --git a/demo/PropertyGrid.py b/demo/PropertyGrid.py index a6a40196..3216388b 100644 --- a/demo/PropertyGrid.py +++ b/demo/PropertyGrid.py @@ -701,20 +701,22 @@ class TestPanel( wx.Panel ): # # Add properties # - + # NOTE: in this example the property names are used as variable names + # in one of the tests, so they need to be valid python identifiers. + # pg.AddPage( "Page 1 - Testing All" ) pg.Append( wxpg.PropertyCategory("1 - Basic Properties") ) pg.Append( wxpg.StringProperty("String",value="Some Text") ) - sp = pg.Append( wxpg.StringProperty('StringProperty w/ Password flag', value='ABadPassword') ) + sp = pg.Append( wxpg.StringProperty('StringProperty_as_Password', value='ABadPassword') ) sp.SetAttribute('Hint', 'This is a hint') sp.SetAttribute('Password', True) - pg.Append( wxpg.IntProperty("Int",value=100) ) - pg.Append( wxpg.FloatProperty("Float",value=100.0) ) - pg.Append( wxpg.BoolProperty("Bool",value=True) ) - boolprop = pg.Append( wxpg.BoolProperty("Bool_with_Checkbox",value=True) ) + pg.Append( wxpg.IntProperty("Int", value=100) ) + self.fprop = pg.Append( wxpg.FloatProperty("Float", value=123.456) ) + pg.Append( wxpg.BoolProperty("Bool", value=True) ) + boolprop = pg.Append( wxpg.BoolProperty("Bool_with_Checkbox", value=True) ) pg.SetPropertyAttribute( "Bool_with_Checkbox", # You can find the property by name, #boolprop, # or give the property object itself. diff --git a/etg/propgridiface.py b/etg/propgridiface.py index 306f6b7d..b74d96cf 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, or 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/etgtools/extractors.py b/etgtools/extractors.py index 5022a22a..49fe036a 100644 --- a/etgtools/extractors.py +++ b/etgtools/extractors.py @@ -596,6 +596,7 @@ class ParamDef(BaseDef): self.transferBack = False # transfer ownership of arg from C++ to Python? self.transferThis = False # ownership of 'this' pointer transferred to this arg self.keepReference = False # an extra reference to the arg is held + self.constrained = False # limit auto-conversion of similar types (like float -> int) self.__dict__.update(kw) if element is not None: self.extract(element) diff --git a/etgtools/sip_generator.py b/etgtools/sip_generator.py index 6256db21..315fbcae 100644 --- a/etgtools/sip_generator.py +++ b/etgtools/sip_generator.py @@ -959,6 +959,8 @@ from .%s import * annotations.append('ArraySize') if item.keepReference: annotations.append('KeepReference') + if item.constrained: + annotations.append('Constrained') if isinstance(item, (extractors.ParamDef, extractors.FunctionDef)): if item.transfer: 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 #--------------------------------------------------------------------------- diff --git a/unittests/test_propgridmanager.py b/unittests/test_propgridmanager.py index d29d3c40..d60c1ad7 100644 --- a/unittests/test_propgridmanager.py +++ b/unittests/test_propgridmanager.py @@ -1,14 +1,20 @@ import unittest from unittests import wtc import wx +import wx.propgrid as pg #--------------------------------------------------------------------------- class propgridmanager_Tests(wtc.WidgetTestCase): - # TODO: Remove this test and add real ones. - def test_propgridmanager1(self): - self.fail("Unit tests for propgridmanager not implemented yet.") + def test_propgridmanager01(self): + page = pg.PropertyGridPage() + + + def test_propgridmanager02(self): + mgr = pg.PropertyGridManager(self.frame) + page1 = mgr.AddPage('label') + #--------------------------------------------------------------------------- diff --git a/unittests/test_propgridproperty.py b/unittests/test_propgridproperty.py index 8415bf47..4a60a4b5 100644 --- a/unittests/test_propgridproperty.py +++ b/unittests/test_propgridproperty.py @@ -48,15 +48,15 @@ class property_Tests(wtc.WidgetTestCase): c = pg.PGCell() - def test_propgridproperty07(self): - attrs = pg.PGAttributeStorage() - attrs.Set('name', 'value') - attrs.Set('one', 1) - attrs.Set('two.one', 2.1) - attrs.Set('true', True) - assert attrs.GetCount() == 4 - assert attrs.FindValue('name') == 'value' - # TODO: Add some iteration tests + # def test_propgridproperty07(self): + # attrs = pg.PGAttributeStorage() + # attrs.Set('name', 'value') + # attrs.Set('one', 1) + # attrs.Set('two.one', 2.1) + # attrs.Set('true', True) + # assert attrs.GetCount() == 4 + # assert attrs.FindValue('name') == 'value' + # # TODO: Add some iteration tests def test_propgridproperty08(self): diff --git a/wx/lib/agw/aui/framemanager.py b/wx/lib/agw/aui/framemanager.py index 874a7fc5..feef93cd 100644 --- a/wx/lib/agw/aui/framemanager.py +++ b/wx/lib/agw/aui/framemanager.py @@ -98,7 +98,6 @@ __date__ = "31 March 2009" import wx # just for isinstance -import wx.lib.sized_controls as sc import time import warnings @@ -4470,8 +4469,6 @@ class AuiManager(wx.EvtHandler): if not managed_window: raise Exception("Specified managed window must be non-null. ") - if isinstance(managed_window, sc.SizedParent): - raise Exception("Do not use wx.lib.sized_control for managed window. ") self.UnInit()