From 1bf2a0bc134c58b73d5939edef13cc5a230d5de3 Mon Sep 17 00:00:00 2001 From: kollivier Date: Wed, 13 Sep 2017 16:17:48 -0700 Subject: [PATCH 1/6] After fixing AddChild in sized_controls, it appears to work with AGW's AUI now. --- wx/lib/agw/aui/framemanager.py | 3 --- 1 file changed, 3 deletions(-) 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() From 9dfd7ca9c797626851d635c2907995b5d3250f73 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 14 Sep 2017 15:43:25 -0700 Subject: [PATCH 2/6] Add 2nd PR number for the SizedControls fix. --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 08fc6369..56956bd0 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 From fc2c6cda57c01508ca47a8b12a69adbc7af74864 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 14 Sep 2017 19:53:17 -0700 Subject: [PATCH 3/6] Add support for using the /Constrained/ annotation --- etgtools/extractors.py | 1 + etgtools/sip_generator.py | 2 ++ 2 files changed, 3 insertions(+) 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: From 90be887af60df520c9118c49e6b70ae6015156be Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 14 Sep 2017 19:56:09 -0700 Subject: [PATCH 4/6] Reorder the SetPropertyValue overloads and constrain the bool and double overloads. This avoids choosing the int overload for anything that can be implicitly converted to an integer. --- etg/propgridiface.py | 23 ++++++++++++++++++----- unittests/test_propgridiface.py | 13 +++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) 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 #--------------------------------------------------------------------------- From 4ce9c2b46fc9e2a7517fda77458aa7c6e49011a7 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 14 Sep 2017 19:57:26 -0700 Subject: [PATCH 5/6] Various other propgrid related tweaks --- demo/PropertyGrid.py | 14 ++++++++------ unittests/test_propgridmanager.py | 12 +++++++++--- unittests/test_propgridproperty.py | 18 +++++++++--------- 3 files changed, 26 insertions(+), 18 deletions(-) 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/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): From 2b2040647cbe40c8f690ab9b6d9f2ee91b5f2c17 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 14 Sep 2017 20:07:58 -0700 Subject: [PATCH 6/6] typo --- etg/propgridiface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etg/propgridiface.py b/etg/propgridiface.py index 158447ef..b74d96cf 100644 --- a/etg/propgridiface.py +++ b/etg/propgridiface.py @@ -120,7 +120,7 @@ def run(): # 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. + # 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')