Open Dash app in PySide6 QWebEngineView browser

@echeung Thank you for pointing me in the right direction. Threading does the trick but one needs to add an additional argument to run the app. use_reloader=False in app.run(debug=True, use_reloader=False, port=port).

The complete code is shown below. The sources are cited appropriately.

Thank you once again.

import sys
import dash
import threading
from dash import html
import dash_bootstrap_components as dbc

from PySide6.QtCore import QUrl
from PySide6.QtWebEngineWidgets import QWebEngineView
from PySide6.QtWidgets import QApplication, QMainWindow


# Code to create simple browser modified to work with PySide6
# Source: https://www.pythonguis.com/examples/python-web-browser/
class MainWindow(QMainWindow):
    def __init__(self, _url):
        super().__init__()
        self.url = _url

        self.browser = QWebEngineView()
        self.browser.setUrl(QUrl(self.url))

        self.setCentralWidget(self.browser)


def launch_browser(url):
    app = QApplication(sys.argv)
    app.setStyle("Fusion")
    window = MainWindow(url)
    window.show()
    sys.exit(app.exec())


# Set default port
port = 8050
browser_url = f"http://localhost:{port}/"

# https://github.com/plotly/dash-core-components/issues/952#issuecomment-2015163046
# https://stackoverflow.com/questions/77724451/how-to-run-a-dash-app-with-threading-and-with-debug-true
def run_dash():
    app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
    app.layout = dbc.Container([
        dbc.Row([dbc.Col(html.H1("Test Dashboard", className="py-3"))]),
    ])  
    app.run(debug=True, use_reloader=False, port=port, dev_tools_ui=False)

if __name__ == "__main__":
    thread = threading.Thread(target=run_dash, daemon=True).start()
    launch_browser(browser_url)