Black Lives Matter. Please consider donating to Black Girls Code today.

Use Dash in PyQt5 GUI

I have a script for which I have created a GUI with PyQT5. As of now, I am able to plot my data with plot.ly, with the snippet of the code at the end of my script that follows:

    data = [trace1, trace1_dots, trace1_reliability,trace2, trace2_dots, trace2_reliability]

    layout = {
'xaxis': {
    'range': [lower_limit,upper_limit]
},

'shapes': [

    # Line Horizontal
    {
        'type': 'line',
        'x0': 0,
        'y0': 1_current_rank,
        'x1': upper_limit,
        'y1': 1_current_rank,
        'opacity': 0.5,
        'line': {
            'color': 'rgb(0,179,134)',
            'width': 4,
            'dash': 'dash',
        },
    },
    # Line Diagonal
    {
        'type': 'line',
        'x0': 0,
        'y0': 2_current_rank,
        'x1': upper_limit,
        'y1': 2_current_rank,
        'opacity': 0.5,
        'line': {
            'color': 'rgb(255,191,0)',
            'width': 4,
            'dash': 'dash',
        }
    }
]
}

    plotly.offline.plot({
        "data": data,
        "layout": layout


    }, auto_open=True)




if __name__ == '__main__':

app = QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit(app.exec_())

However, I would like to use Dash instead but cannot wrap my head around how it could be done, mainly because ‘app’ is already used by PyQt5 and when I try to use ‘app1’ for example, it says it is not defined when running the script.

I am new to Dash and tried to look around but couldn’t find a solution to my problem.

hi, have you solved you problem, I encouter similar question, any experience share?

Hi,

It might not be the best solution but what I have done is using subprocess.Popen to open a file Dash.py where I am creating the Dash and pass the variables I have created so far.

Something like:

subprocess.Popen([“python”, path_to_Dash.py, variable1, variable2, variable3], creationflags=CREATE_NEW_CONSOLE)