From 14b38c9639c53367a4b5d543a6b681c79345812f Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 7 Jun 2021 13:25:53 -0500 Subject: [PATCH 1/4] set transient metadata on traits who (according to subclasses) should be transient --- enable/stacked_container.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/enable/stacked_container.py b/enable/stacked_container.py index c77e50838..de40bd906 100644 --- a/enable/stacked_container.py +++ b/enable/stacked_container.py @@ -23,15 +23,15 @@ class StackedContainer(Container): # The dimension along which to stack components that are added to # this container. - stack_dimension = Enum("h", "v") + stack_dimension = Enum("h", "v", transient=True) # The "other" dimension, i.e., the dual of the stack dimension. - other_dimension = Enum("v", "h") + other_dimension = Enum("v", "h", transient=True) # The index into obj.position and obj.bounds that corresponds to # **stack_dimension**. This is a class-level and not an instance-level # attribute. It must be 0 or 1. - stack_index = 0 + stack_index = Int(0, transient=True) # The amount of space to put between components. spacing = Float(0.0) From e1a7e2251d04e714f34a61ba40da7e0d6c1b1e23 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 7 Jun 2021 13:32:02 -0500 Subject: [PATCH 2/4] import Int --- enable/stacked_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enable/stacked_container.py b/enable/stacked_container.py index de40bd906..b644f42e9 100644 --- a/enable/stacked_container.py +++ b/enable/stacked_container.py @@ -11,7 +11,7 @@ """ -from traits.api import Enum, Float +from traits.api import Enum, Float, Int from .container import Container from .stacked_layout import stacked_preferred_size, stack_layout From c161b8e67692889ad96e7325072d3031bd816899 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 7 Jun 2021 13:38:15 -0500 Subject: [PATCH 3/4] actually we do need getstate because stack_index is a class attribute. Pull getstate method down here to the baseclass --- enable/stacked_container.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/enable/stacked_container.py b/enable/stacked_container.py index b644f42e9..05595c86e 100644 --- a/enable/stacked_container.py +++ b/enable/stacked_container.py @@ -11,7 +11,7 @@ """ -from traits.api import Enum, Float, Int +from traits.api import Enum, Float from .container import Container from .stacked_layout import stacked_preferred_size, stack_layout @@ -31,7 +31,7 @@ class StackedContainer(Container): # The index into obj.position and obj.bounds that corresponds to # **stack_dimension**. This is a class-level and not an instance-level # attribute. It must be 0 or 1. - stack_index = Int(0, transient=True) + stack_index = 0 # The amount of space to put between components. spacing = Float(0.0) @@ -39,6 +39,15 @@ class StackedContainer(Container): def get_preferred_size(self, components=None): return stacked_preferred_size(self, components) + ### Persistence ########################################################### + + # PICKLE FIXME: blocked with _pickles, but not sure that was correct. + def __getstate__(self): + state = super().__getstate__() + if "stack_index" in state: + del state["stack_index"] + return state + class HStackedContainer(StackedContainer): """ From 3db07d4dcf21c85d44df6d74fa478389cb17ebbb Mon Sep 17 00:00:00 2001 From: aaronayres35 <36972686+aaronayres35@users.noreply.github.com> Date: Thu, 10 Jun 2021 09:21:16 -0500 Subject: [PATCH 4/4] remove PICKLE FIXME comment Co-authored-by: Poruri Sai Rahul --- enable/stacked_container.py | 1 - 1 file changed, 1 deletion(-) diff --git a/enable/stacked_container.py b/enable/stacked_container.py index 05595c86e..6a76ce183 100644 --- a/enable/stacked_container.py +++ b/enable/stacked_container.py @@ -41,7 +41,6 @@ def get_preferred_size(self, components=None): ### Persistence ########################################################### - # PICKLE FIXME: blocked with _pickles, but not sure that was correct. def __getstate__(self): state = super().__getstate__() if "stack_index" in state: