Aug-12-2023, 12:33 PM
(This post was last modified: Aug-12-2023, 01:08 PM by Yoriz.
Edit Reason: Moved to GUI, Prefix added
)
I am developing a GUI Application using PyQt5.
There is a tab with charts and the idea is when clicking a button, it displays a chart.
The following code works just fine:
I modified the code keeping same structure as the one above and everytime I click the button, my application is closing and I receive this error: Process finished with exit code -1073740791 (0xC0000409)
There is a tab with charts and the idea is when clicking a button, it displays a chart.
The following code works just fine:
from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets import plotly.graph_objects as go import pandas as pd class CandlestickTab(QtWidgets.QWidget): def __init__(self, parent=None): super().__init__(parent) self.button = QtWidgets.QPushButton('Plot', self) self.browser = QtWebEngineWidgets.QWebEngineView(self) vlayout = QtWidgets.QVBoxLayout(self) vlayout.addWidget(self.button, alignment=QtCore.Qt.AlignHCenter) vlayout.addWidget(self.browser) self.button.clicked.connect(self.show_graph) self.resize(1000,800) def show_graph(self): df = px.data.tips() fig = px.box(df, x="day", y="total_bill", color="smoker") fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default self.browser.setHtml(fig.to_html(include_plotlyjs='cdn'))I have a csv file with data about crypto such as timestamp, open, high, low, close, volume and I wanna display a CandleStick.
I modified the code keeping same structure as the one above and everytime I click the button, my application is closing and I receive this error: Process finished with exit code -1073740791 (0xC0000409)
from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets import plotly.graph_objects as go import pandas as pd class CandlestickTab(QtWidgets.QWidget): def __init__(self, parent=None): super().__init__(parent) self.button = QtWidgets.QPushButton('Show Candlestick Chart', self) self.browser = QtWebEngineWidgets.QWebEngineView(self) vlayout = QtWidgets.QVBoxLayout(self) vlayout.addWidget(self.button, alignment=QtCore.Qt.AlignHCenter) vlayout.addWidget(self.browser) self.button.clicked.connect(self.show_candlestick_chart) self.resize(1000, 800) def show_candlestick_chart(self): df = pd.read_csv('crypto.csv') if not df.empty: fig = go.Figure(data=[go.Candlestick(x=df['timestamp'], open=df['open'], high=df['high'], low=df['low'], close=df['close'])]) self.browser.setHtml(fig.to_html(include_plotlyjs='cdn')) else: self.browser.setHtml("<p>No data available for plotting.</p>")This is the main:
import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QTabWidget from home import HomeTab from candlestick import CandlestickTab from analiza_tehnica import AnalizaTehnicaTab from sentiment_analysis import SentimentAnalysisTab from alpha_get_data import AlphaGetData # from news import NewsTab class MainApp(QMainWindow): def __init__(self): super().__init__() self.init_ui() def init_ui(self): self.setWindowTitle('Aplicația Mea cu Tab-uri') self.setGeometry(100, 100, 800, 600) tabs = QTabWidget() tabs.addTab(HomeTab(),"Home") tabs.addTab(AnalizaTehnicaTab(), "Analiza Tehnica") tabs.addTab(CandlestickTab(),"CandleStick") tabs.addTab(SentimentAnalysisTab(), "Sentiment Analysis") self.setCentralWidget(tabs) if __name__ == '__main__': app = QApplication(sys.argv) window = MainApp() window.show() sys.exit(app.exec_()) app.setQuitOnLastWindowClosed(False)Can someone help me with this, please?