Inserting Streamlit script in pyqt5 application

Hello Everyone…

I want to insert streamlit dashboard inside the pyqt5 application local host URL within the python code.
The problem is, every time if I have to run the code and see the dashboard, I need to run the streamlit run app.py in command prompt. After running in the command prompt the dashboard is showing in the pyqt application.

Is there any alternate ways to stop using command prompt.

Please anybody help me on this.

Maybe you can use the subprocess module instead of the command prompt

https://docs.python.org/3/library/subprocess.html

I used ‘subprocess’ and ‘os’ module also. But its only executing streamlit run command and Dashboard is opening in local browser and stopping.
My requirement is first streamlit run command has to execute and after that automatically dashboard has to display in the pyqt5 window.

Anybody who knows the solution. Please help me on this.
Below is my code:

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *
import os
import subprocess
import sys

def dashboardUi(self):

    self.mainLayout = QVBoxLayout()

    dashboardcmd = "py -m streamlit run Dashboard2.py"
    jk = os.system(dashboardcmd)
   
    self.browserView = QWebEngineView()
    self.browserView.setUrl(QUrl("http://localhost:8501"))
    self.browserView.setUrl(QUrl("http://192.168.68.108:8501"))
    self.mainLayout.addWidget(self.browserView)
    self.setCentralWidget(self.browserView)
    

main = QWidget()
main.setLayout(self.mainLayout)
return main

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.