Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set transient metadata and pull up __getstate__ method #841

Merged
merged 4 commits into from
Jun 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions enable/stacked_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ 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
Expand All @@ -39,6 +39,14 @@ class StackedContainer(Container):
def get_preferred_size(self, components=None):
return stacked_preferred_size(self, components)

### Persistence ###########################################################

def __getstate__(self):
state = super().__getstate__()
if "stack_index" in state:
del state["stack_index"]
return state


class HStackedContainer(StackedContainer):
"""
Expand Down