-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathapp.py
60 lines (48 loc) · 1.51 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from dash_canvas import DashCanvas
import dash
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objs as go
import dash_daq as daq
filename = 'https://www.publicdomainpictures.net/pictures/60000/nahled/flower-outline-coloring-page.jpg'
canvas_width = 300
app = dash.Dash(__name__)
app.layout = html.Div([
html.Div([
DashCanvas(
id='canvas-color',
width=canvas_width,
filename=filename,
hide_buttons=['line', 'zoom', 'pan'],
)
], className="six columns"),
html.Div([
html.H6(children=['Brush width']),
dcc.Slider(
id='bg-width-slider',
min=2,
max=40,
step=1,
value=[5]
),
daq.ColorPicker(
id='color-picker',
label='Brush color',
value='#119DFF'
),
], className="three columns"),
])
@app.callback(Output('canvas-color', 'lineColor'),
[Input('color-picker', 'value')])
def update_canvas_linewidth(value):
if isinstance(value, dict):
return value['hex']
else:
return value
@app.callback(Output('canvas-color', 'lineWidth'),
[Input('bg-width-slider', 'value')])
def update_canvas_linewidth(value):
return value
if __name__ == '__main__':
app.run_server(debug=True)