-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcallbacks.py
115 lines (94 loc) · 4.11 KB
/
callbacks.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
import dash_table
import plotly.graph_objs as go
import pandas as pd
import numpy as np
import math
import abc
from app import app
import base64
# TODO update this name
import json
import ezdxf
from ezdxf.filemanagement import dxf_stream_info
import io
import urllib
import urllib.parse
from tempfile import NamedTemporaryFile
from ezdxf.math import Vector
# import os
@app.callback(
[
Output('hub-results-table', 'children'),
Output('bearing-results-table', 'children'),
],
[Input('calc-bending-moment', 'n_clicks')],
[
State('general-arrangement-dims', 'data'),
State('stress-concentrations', 'data'),
State('design-criteria-table', 'data'),
State('load-two-table', 'data')
]
)
def Calculate_Automatic_Results(
n_clicks,
general_arrangement_dims,
stress_concentrations,
design_criteria_table2,
loads
):
# Don't update callback when program loads first time to prevent None types being returned:
if n_clicks is None:
raise PreventUpdate
dummy_shaft_table_data = [
dict(Component='Selected Shaft Material', Result='to be programmed 1'),
dict(Component='Selected Shaft Yield Stress (MPa)', Result='to be programmed 1'),
]
# Create DataFrame.
dummy_shaft_table_df = pd.DataFrame(dummy_shaft_table_data)
# extract data/rows and columns
columns = [{"name": i, "id": i, } for i in (dummy_shaft_table_df.columns)]
data = dummy_shaft_table_df.to_dict('rows')
# Create a dash datatable
dummy_shaft_results_table = dash_table.DataTable(data=data, columns=columns,
style_as_list_view=True,
style_cell={'textAlign': 'center',
'minWidth': '0px', 'width': '200px', 'maxWidth': '200px',
'overflow': 'hidden',
'textOverflow': 'ellipsis',
'font-family': 'sans-serif',
},
style_cell_conditional=[
{
'if': {'column_id': 'Component'},
'textAlign': 'left'
}
]
)
dummy_table_data = [
dict(Component='Selected Bearing Manufacturer', Result='to be programmed 1'),
dict(Component='Bearing Life (Hrs)', Result='to be programmed 3'),
]
# Create DataFrame.
dummy_table_df = pd.DataFrame(dummy_table_data)
# extract data/rows and columns
columns = [{"name": i, "id": i, } for i in (dummy_table_df.columns)]
data = dummy_table_df.to_dict('rows')
# Create a dash datatable
dummy_table = dash_table.DataTable(data=data, columns=columns,
style_as_list_view=True,
style_cell={'textAlign': 'center',
'minWidth': '0px', 'width': '200px', 'maxWidth': '200px',
'overflow': 'hidden',
'textOverflow': 'ellipsis',
'font-family': 'sans-serif',
},
style_cell_conditional=[
{
'if': {'column_id': 'Component'},
'textAlign': 'left'
}
]
)
return dummy_table, dummy_shaft_results_table