From 69188d8e749295ffb3a27155e42cd53f54699b10 Mon Sep 17 00:00:00 2001 From: Andrew Stein Date: Fri, 28 Jan 2022 21:21:44 -0500 Subject: [PATCH] Update `perspective-python` for new theme API --- packages/perspective-jupyterlab/src/js/psp_widget.js | 1 - packages/perspective-jupyterlab/src/js/view.js | 1 - python/perspective/perspective/tests/viewer/test_viewer.py | 4 ++-- python/perspective/perspective/viewer/viewer.py | 6 +++--- python/perspective/perspective/viewer/viewer_traitlets.py | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/perspective-jupyterlab/src/js/psp_widget.js b/packages/perspective-jupyterlab/src/js/psp_widget.js index 495cd220ed..340fbd8d5f 100644 --- a/packages/perspective-jupyterlab/src/js/psp_widget.js +++ b/packages/perspective-jupyterlab/src/js/psp_widget.js @@ -243,7 +243,6 @@ export class PerspectiveWidget extends Widget { this._server = server; } - get editable() { return this._editable; } diff --git a/packages/perspective-jupyterlab/src/js/view.js b/packages/perspective-jupyterlab/src/js/view.js index 938c1fbaf2..c9a90b4fd9 100644 --- a/packages/perspective-jupyterlab/src/js/view.js +++ b/packages/perspective-jupyterlab/src/js/view.js @@ -412,7 +412,6 @@ export class PerspectiveView extends DOMWidgetView { theme: this.model.get("theme"), }); } - } editable_changed() { this.pWidget.editable = this.model.get("editable"); diff --git a/python/perspective/perspective/tests/viewer/test_viewer.py b/python/perspective/perspective/tests/viewer/test_viewer.py index 13486e9a04..8374296173 100644 --- a/python/perspective/perspective/tests/viewer/test_viewer.py +++ b/python/perspective/perspective/tests/viewer/test_viewer.py @@ -74,12 +74,12 @@ def test_viewer_load_data_with_options(self): def test_viewer_load_clears_state(self): table = Table({"a": [1, 2, 3]}) - viewer = PerspectiveViewer(dark=True, row_pivots=["a"]) + viewer = PerspectiveViewer(theme="Material Dark", row_pivots=["a"]) viewer.load(table) assert viewer.row_pivots == ["a"] viewer.load({"b": [1, 2, 3]}) assert viewer.row_pivots == [] - assert viewer.dark is True # should not break UI + assert viewer.theme == "Material Dark" # should not break UI def test_viewer_load_np(self): table = Table({"a": np.arange(1, 100)}) diff --git a/python/perspective/perspective/viewer/viewer.py b/python/perspective/perspective/viewer/viewer.py index 3808f23052..1935010d59 100644 --- a/python/perspective/perspective/viewer/viewer.py +++ b/python/perspective/perspective/viewer/viewer.py @@ -66,7 +66,7 @@ def __init__( filter=None, expressions=None, plugin_config=None, - dark=None, + theme=None, editable=False, ): """Initialize an instance of `PerspectiveViewer` with the given viewer @@ -96,7 +96,7 @@ def __init__( select by default. plugin_config (:obj:`dict`): A configuration for the plugin, i.e. the datagrid plugin or a chart plugin. - dark (:obj:`bool`): Whether to invert the color theme. + theme (:obj:`str`): The color theme to use. editable (:obj:`bool`): Whether to allow editability using the grid. Examples: @@ -128,7 +128,7 @@ def __init__( self.filter = validate_filter(filter) or [] self.expressions = validate_expressions(expressions) or [] self.plugin_config = validate_plugin_config(plugin_config) or {} - self.dark = dark + self.theme = theme self.editable = editable @property diff --git a/python/perspective/perspective/viewer/viewer_traitlets.py b/python/perspective/perspective/viewer/viewer_traitlets.py index adda298e7f..b7a7a5f46a 100644 --- a/python/perspective/perspective/viewer/viewer_traitlets.py +++ b/python/perspective/perspective/viewer/viewer_traitlets.py @@ -44,7 +44,7 @@ class PerspectiveTraitlets(HasTraits): filter = List(default_value=[]).tag(sync=True) expressions = List(default_value=[]).tag(sync=True) plugin_config = Dict(default_value={}).tag(sync=True) - dark = Bool(None, allow_none=True).tag(sync=True) + theme = Unicode("Material Light", allow_none=True).tag(sync=True) editable = Bool(False).tag(sync=True) server = Bool(False).tag(sync=True) client = Bool(False).tag(sync=True)