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

Remove guideline color key when setting color none #457

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion Lib/defcon/objects/guideline.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ def _set_color(self, color):
oldColor = self.get("color")
if newColor == oldColor:
return
self["color"] = newColor
if newColor is None:
del self["color"]
else:
self["color"] = newColor
self.postNotification("Guideline.ColorChanged", data=dict(oldValue=oldColor, newValue=newColor))

color = property(_get_color, _set_color, doc="The guideline's :class:`Color` object. When setting, the value can be a UFO color string, a sequence of (r, g, b, a) or a :class:`Color` object. Setting this posts *Guideline.ColorChanged* and *Guideline.Changed* notifications.")
Expand Down
2 changes: 2 additions & 0 deletions Lib/defcon/test/objects/test_guideline.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ def test_color(self):
g = Guideline()
g.color = "1,1,1,1"
self.assertEqual(g.color, "1,1,1,1")
self.assertTrue("color" in g)
self.assertTrue(g.dirty)
g.color = None
self.assertIsNone(g.color)
self.assertFalse("color" in g)
self.assertTrue(g.dirty)

def test_identifier(self):
Expand Down
Loading