I am running into a problem while trying to create a dashboard with Dash (plotly), while using a GUI created with PyQt5.
I have tried to have the following example code both as a module and at the end of my code:
import dash
import dash_core_components as dcc
import dash_html_components as html
def run_dash(data, layout):
app = dash.Dash()
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''
Dash: A web application framework for Python.
'''),
dcc.Graph(
id='example-graph',
figure={
'data': data,
'layout': layout
}
)
])
app.run_server(debug=True)
But everytime I get the error can't find '__main__' module in ''
I know that initially, to create a Dash a main guard like the following is used:
if __name__ == '__main__':
app.run_server(debug=True)
But I already have a main guard for my MainWindow so I can't figure out how to make both work together. For reference, this is my MainWindow main guard:
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit(app.exec_())
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…