Skip to content

Commit

Permalink
Add color pallete swatches
Browse files Browse the repository at this point in the history
  • Loading branch information
WarmCyan committed Aug 24, 2023
1 parent 014a5f6 commit da81950
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
49 changes: 46 additions & 3 deletions icat/anchorlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,38 @@
_kill_param_auto_docstring()


ANCHOR_COLOR_PALLETE = [
[
"#2ABD7F", # pleasant pale green
"#42803F", # dark green
],
[
"#8C27C1", # dark purple
"#5B3D7B", # darker purple
],
[
"#2EA5A5", # mid pale blue
"#424E80", # dark washed blue
],
[
"#BFA74C", # gold
"#6E9613", # olive green
],
[
"#DA707C", # salmon
"#A75B13", # burnt orange
],
[
"#CA3296", # pink
"#881515", # red
],
[
"#8D6E63", # brown
"#777777", # grey
],
]


class AnchorListTemplate(v.VuetifyTemplate):
"""The ipyvuetify contents of the anchorlist table. This handles all the special considerations
like the slot for the expanded rows containing the anchor widgets, and the coverage v-html etc.
Expand Down Expand Up @@ -374,7 +406,7 @@ def __init__(
if anchor_types is None:
anchor_types = [
DictionaryAnchor,
{"ref": TFIDFAnchor, "color": "#FF00FF"},
{"ref": TFIDFAnchor, "color": ANCHOR_COLOR_PALLETE[4][0]},
]

self.coverage_info = {}
Expand Down Expand Up @@ -787,7 +819,16 @@ def _populate_anchor_types_col(self):
# for anchor_type in Anchor.anchor_types():
for anchor_type_dict in self.possible_anchor_types:
color_picker = v.ColorPicker(
hide_inputs=True, v_model=anchor_type_dict["color"]
hide_inputs=True,
v_model=anchor_type_dict["color"],
hide_canvas=True,
hideSliders=True,
hide_mode_switch=True,
hide_sliders=True,
disabled=True,
show_swatches=True,
swatches=ANCHOR_COLOR_PALLETE,
width=250,
)
color_picker.on_event(
"input",
Expand Down Expand Up @@ -960,7 +1001,9 @@ def add_anchor_types(self, anchor_types: list[type | dict[str, any]]):
ref = anchor_type.pop("ref")
self.add_anchor_type(ref, **anchor_type)

def add_anchor_type(self, anchor_type: type, name: str = None, color: str = "#777"):
def add_anchor_type(
self, anchor_type: type, name: str = None, color: str = "#777777"
):
if name is not None:
# if the user specified a specific name, use that.
anchor_type_name = name
Expand Down
5 changes: 4 additions & 1 deletion icat/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def __init__(
if anchor_types is None:
anchor_types = [
DictionaryAnchor,
{"ref": TFIDFAnchor, "color": "#FF00FF"},
{
"ref": TFIDFAnchor,
"color": icat.anchorlist.ANCHOR_COLOR_PALLETE[4][0],
},
]

self.training_data: pd.DataFrame = None
Expand Down

0 comments on commit da81950

Please sign in to comment.