Skip to content

Commit

Permalink
fix: do not share the Expr for text_color and background_color
Browse files Browse the repository at this point in the history
Signed-off-by: Maarten A. Breddels <maartenbreddels@gmail.com>
  • Loading branch information
maartenbreddels authored and martinRenou committed Feb 17, 2023
1 parent 506d5ea commit 8482383
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ipydatagrid/cellrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
from bqplot import ColorScale, Scale
from ipywidgets import Color, Widget, widget_serialization
from py2vega import Variable, py2vega
from traitlets import Any, Bool, Enum, Float, Instance, Unicode, Union, validate
from traitlets import (
Any,
Bool,
Enum,
Float,
Instance,
Unicode,
Union,
default,
validate,
)

from ._frontend import module_name, module_version

Expand Down Expand Up @@ -68,11 +78,9 @@ class TextRenderer(CellRenderer):
).tag(sync=True, **widget_serialization)
text_color = Union(
(Color(), Instance(VegaExpr), Instance(ColorScale)),
default_value=Expr("default_value"),
).tag(sync=True, **widget_serialization)
background_color = Union(
(Color(), Instance(VegaExpr), Instance(ColorScale)),
default_value=Expr("default_value"),
).tag(sync=True, **widget_serialization)
vertical_alignment = Union(
(
Expand All @@ -98,6 +106,14 @@ class TextRenderer(CellRenderer):
)
missing = Unicode("").tag(sync=True)

@default("text_color")
def _default_text_color(self):
return Expr("default_value")

@default("background_color")
def _default_background_color(self):
return Expr("default_value")


class BarRenderer(TextRenderer):
_model_name = Unicode("BarRendererModel").tag(sync=True)
Expand Down

0 comments on commit 8482383

Please sign in to comment.