Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
00a2bf9b
Commit
00a2bf9b
authored
Jan 16, 2019
by
Michael Droettboom
Committed by
GitHub
Jan 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #296 from madhur-tandon/widgets
Add style to matplotlib widgets
parents
833ce1a5
8bcb07b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
1 deletion
+38
-1
packages/matplotlib/src/wasm_backend.py
packages/matplotlib/src/wasm_backend.py
+38
-1
No files found.
packages/matplotlib/src/wasm_backend.py
View file @
00a2bf9b
...
...
@@ -27,7 +27,6 @@ from js import ImageData
interactive
(
True
)
class
FigureCanvasWasm
(
backend_agg
.
FigureCanvasAgg
):
supports_blit
=
False
...
...
@@ -38,6 +37,41 @@ class FigureCanvasWasm(backend_agg.FigureCanvasAgg):
self
.
_id
=
"matplotlib_"
+
hex
(
id
(
self
))[
2
:]
self
.
_title
=
''
self
.
_ratio
=
1
matplotlib_figure_styles
=
self
.
_add_matplotlib_styles
()
if
document
.
getElementById
(
'matplotlib-figure-styles'
)
is
None
:
document
.
head
.
appendChild
(
matplotlib_figure_styles
)
def
_add_matplotlib_styles
(
self
):
toolbar_buttons_css_content
=
"""
button.matplotlib-toolbar-button {
font-size: 14px;
color: #495057;
text-transform: uppercase;
background: #e9ecef;
padding: 9px 18px;
border: 1px solid #fff;
border-radius: 4px;
transition-duration: 0.4s;
}
button.matplotlib-toolbar-button#text {
font-family: -apple-system, BlinkMacSystemFont,
"Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol";
}
button.matplotlib-toolbar-button:hover {
color: #fff;
background: #495057;
}
"""
toolbar_buttons_style_element
=
document
.
createElement
(
'style'
)
toolbar_buttons_style_element
.
id
=
'matplotlib-figure-styles'
toolbar_buttons_css
=
document
.
createTextNode
(
toolbar_buttons_css_content
)
toolbar_buttons_style_element
.
appendChild
(
toolbar_buttons_css
)
return
toolbar_buttons_style_element
def
get_element
(
self
,
name
):
"""
...
...
@@ -449,6 +483,7 @@ class NavigationToolbar2Wasm(backend_bases.NavigationToolbar2):
button
=
document
.
createElement
(
'button'
)
button
.
classList
.
add
(
'fa'
)
button
.
classList
.
add
(
_FONTAWESOME_ICONS
[
image_file
])
button
.
classList
.
add
(
'matplotlib-toolbar-button'
)
button
.
addEventListener
(
'click'
,
getattr
(
self
,
name_of_method
))
div
.
appendChild
(
button
)
...
...
@@ -457,6 +492,8 @@ class NavigationToolbar2Wasm(backend_bases.NavigationToolbar2):
button
=
document
.
createElement
(
'button'
)
button
.
classList
.
add
(
'fa'
)
button
.
textContent
=
format
button
.
classList
.
add
(
'matplotlib-toolbar-button'
)
button
.
id
=
'text'
button
.
addEventListener
(
'click'
,
self
.
ondownload
)
div
.
appendChild
(
button
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment