-
Notifications
You must be signed in to change notification settings - Fork 39
feat: Table of contents #836
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
b3a1554
d9b4d32
a621dcf
0a6c69a
c747ef1
ebb3bd6
a55a09f
ebbf70f
5eeb709
63f22f1
167047a
5cce5f6
f345c60
b900dc7
a741012
6151737
0897f3d
d9f6c73
bd15c96
4bd6b2b
85b1793
28ff53d
4b31240
0db441d
fed8ac3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -247,7 +247,7 @@ def _add_extension_traits(self, extensions: Sequence[BaseExtension]) -> None: | |||||
|
||||||
highlight_color = VariableLengthTuple( | ||||||
t.Int(), | ||||||
default_value=None, | ||||||
default_value=[0, 0, 128, 128], | ||||||
minlen=3, | ||||||
maxlen=4, | ||||||
) | ||||||
|
@@ -281,6 +281,13 @@ def _add_extension_traits(self, extensions: Sequence[BaseExtension]) -> None: | |||||
for an example. | ||||||
""" | ||||||
|
||||||
title = t.CUnicode("Layer", allow_none=False).tag(sync=True) | ||||||
|
title = t.CUnicode("Layer", allow_none=False).tag(sync=True) | |
title = t.Unicode("Layer", allow_none=False).tag(sync=True) |
I can't remember but I think the CUnicode
trait is legacy from the Python 2/3 transition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the casting variant of the Unicode trait, I thought it would be safer in case someone set the layer's title to 1 instead of "1" then it would automatically be changed to "1". I'm happy to change it if you'd like, but that was the reason I used CUnicode
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,12 +2,19 @@ | |||
from functools import partial | ||||
from typing import Any | ||||
|
||||
import ipywidgets | ||||
import traitlets | ||||
from ipywidgets import FloatRangeSlider | ||||
from ipywidgets.widgets.trait_types import TypedTuple | ||||
|
||||
# Import from source to allow mkdocstrings to link to base class | ||||
from ipywidgets.widgets.widget_box import VBox | ||||
from ipywidgets.widgets.widget_box import HBox, VBox | ||||
|
||||
from lonboard._layer import BaseLayer | ||||
from lonboard.traits import ( | ||||
ColorAccessor, | ||||
FloatAccessor, | ||||
) | ||||
|
||||
|
||||
class MultiRangeSlider(VBox): | ||||
|
@@ -88,3 +95,310 @@ def callback(change: dict, *, i: int) -> None: | |||
initial_values.append(child.value) | ||||
|
||||
super().__init__(children, value=initial_values, **kwargs) | ||||
|
||||
|
||||
def _rgb2hex(r: int, g: int, b: int) -> str: | ||||
"""Convert an RGB color code values to hex.""" | ||||
return f"#{r:02x}{g:02x}{b:02x}" | ||||
|
||||
|
||||
def _hex2rgb(hex_color: str) -> list[int]: | ||||
"""Convert a hex color code to RGB.""" | ||||
hex_color = hex_color.lstrip("#") | ||||
rgb_color = [] | ||||
for i in (0, 2, 4): | ||||
rgb_color.append(int(hex_color[i : i + 2], 16)) | ||||
return rgb_color | ||||
|
def _to_rgba_no_colorcycle(c, alpha: float | None = None) -> Tuple[float, ...]: |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make the name in the layer selector editable? Then you wouldn't have to choose a new name from Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unrelated?
There's a question of where defaults should live: in JS code or in Python code. In this case, we don't override the upstream deck.gl default, so leaving this as
None
just means "refer to the underlying deck.gl default". I think that might be a better option than copying all the default values into Python code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did set that intentionally, because it was giving me trouble when it was None, but looking at it right now with eyes from a different day, I think I may be able to change some other stuff in the
_make_color_picker_widget
to make it work with it not being set on the base layer. I'll see what I can do thereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I think I may have actually come across a bug in the existing code when I was doing this and thought it was something I was doing. when I try to access the highlight_color property of a layer with None as the default value with
boundary_layer.highlight_color
I'm getting a Trait Error:
TraitError: The 'highlight_color' trait of a PolygonLayer instance must be of length 3 <= L <= 4, but a value of [] was specified.
can you re-create that error on your end?