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

Support panel 1.0 #41

Open
wants to merge 12 commits into
base: main
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
10 changes: 5 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: [3.8, 3.9, '3.10', '3.11']
exclude:
- os: windows-latest
python-version: 3.8
- os: windows-latest
python-version: 3.9
- os: windows-latest
python-version: '3.10'
- os: macos-latest
python-version: 3.8
- os: windows-latest
python-version: '3.11'
- os: macos-latest
python-version: 3.9
- os: macos-latest
python-version: '3.10'
- os: macos-latest
python-version: '3.11'

env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Below we describe how to install and use this project for development.
To install for development you will need to create and activate a virtual environment

```bash
conda create --name panel-chemistry python=3.9 nodejs
conda create --name panel-chemistry python=3.10 nodejs
conda activate panel-chemistry
```

Expand Down
4 changes: 2 additions & 2 deletions examples/reference/JSMEEditor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -175,7 +175,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.4"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
13 changes: 3 additions & 10 deletions examples/reference/NGLViewer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,7 @@
"cell_type": "code",
"execution_count": null,
"id": "6e35c77b",
"metadata": {
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"file_input = pn.widgets.FileInput(accept=','.join('.' + s for s in EXTENSIONS[1:]))\n",
Expand Down Expand Up @@ -183,7 +176,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -197,7 +190,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.4"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
540 changes: 7 additions & 533 deletions examples/reference/PDBe_MolStar.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions examples/reference/Py3DMol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.4"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classifiers = [
"Topic :: Software Development :: Libraries",
]
dependencies = [
"panel",
"panel>=1.0",
]
dynamic = ["version"]

Expand Down Expand Up @@ -65,7 +65,7 @@ profile = "black"
src_paths = ["src", "tests"]

[tool.pylint.main]
py-version=3.9
py-version=3.10
output-format = "colorized"
max-attributes=12
max-args=10
Expand All @@ -75,7 +75,7 @@ max-module-lines = 1000
max-line-length=100

[tool.mypy]
python_version = "3.9"
python_version = "3.10"
namespace_packages = true
explicit_package_bases = true
mypy_path = "src"
Expand All @@ -84,11 +84,13 @@ exclude = []
[[tool.mypy.overrides]]
module = [
"bokeh.*",
"comm.*",
"holoviews.*",
"hvplot.*",
"param",
"pyviz_comms",
"py3Dmol",
"pydantic.*",
"pyviz_comms",
]
ignore_missing_imports = true

Expand Down
49 changes: 49 additions & 0 deletions script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import panel as pn
from panel_chemistry.pane import NGLViewer # panel_chemistry needs to be imported before you run pn.extension()
from panel_chemistry.pane.ngl_viewer import EXTENSIONS

pn.extension("ngl_viewer", sizing_mode="stretch_width")

viewer = NGLViewer(object="1CRN", background_color="#F7F7F7", styles={"border": "1px solid lightgray"}, min_height=700, sizing_mode="stretch_both")

settings = pn.Param(
viewer,
parameters=["object","extension","representation","color_scheme","custom_color_scheme","effect",],
name="⚙️ Settings"
)

file_input = pn.widgets.FileInput(accept=','.join('.' + s for s in EXTENSIONS[1:]))

def filename_callback(target, event):
target.extension = event.new.split('.')[1]

def value_callback(target, event):
target.object = event.new.decode('utf-8')

file_input.link(viewer, callbacks={'value': value_callback, 'filename': filename_callback})

header = pn.widgets.StaticText(value='<b>{0}</b>'.format("&#128190; File Input"))
file_column = pn.layout.Column(header, file_input)

layout = pn.Param(
viewer,
parameters=["sizing_mode", "width", "height", "background_color"],
name="&#128208; Layout"
)

pn.Row(
viewer,
pn.WidgetBox(settings, layout, width=300, sizing_mode="fixed",),
)


accent="#D2386C"

pn.template.FastListTemplate(
site="Panel Chemistry", site_url="./",
title="NGLViewer",
sidebar=[file_column, settings, layout],
main=[viewer],
accent_base_color=accent, header_background=accent,
).servable();

2 changes: 1 addition & 1 deletion src/panel_chemistry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
develop high-quality [Panel](https://awesome-panel.org) **data apps** within the domain of
**chemistry**.
"""
VERSION = "0.2.2"
VERSION = "0.3.0"
34 changes: 21 additions & 13 deletions src/panel_chemistry/bokeh_extensions/jsme_editor.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
"""A Bokeh model for the JSMEEditor"""
from bokeh.core.properties import List, String
from bokeh.models import HTMLBox
from panel import extension
from panel.models.layout import HTMLBox

# pylint: disable=protected-access
extension._imports["jsme"] = "panel_chemistry.bokeh_extensions.jsme_editor"
# pylint: enable=protected-access


class JSMEEditor(HTMLBox):
class JSMEEditor(HTMLBox): # pylint: disable=too-few-public-methods,too-many-ancestors
"""JSMEEditor Bokeh Model"""

__javascript__ = ["https://unpkg.com/[email protected]/jsme.nocache.js"]
__javascript__ = [
"https://cdn.jsdelivr.net/npm/[email protected]/jsme.nocache.js",
]

value = String()
format = String()
subscriptions = List(String())
options = List(String())
__css__ = [
"https://cdn.jsdelivr.net/npm/[email protected]/gwt/chrome/mosaic.css",
"https://cdn.jsdelivr.net/npm/[email protected]/jsa.css",
"https://cdn.jsdelivr.net/npm/[email protected]/gwt/chrome/chrome.css",
]

jme = String()
smiles = String()
mol = String()
mol3000 = String()
sdf = String()
value = String(default="")
format = String(default="smiles")
subscriptions = List(String, default=[]) # type: ignore
options = List(String, default=[]) # type: ignore

guicolor = String()
jme = String(default="")
smiles = String(default="")
mol = String(default="")
mol3000 = String(default="")
sdf = String(default="")

guicolor = String(default="#c0c0c0")
Loading
Loading