<div dir="ltr"><div>Hello Experts,</div><div>I am Sabari Girish and I joined this mailer list just today. Hence, this is my first query in this forum. Also, I am fairly new to PyQT5.</div><div><u><b><br></b></u></div><div><u><b>What I am trying to do</b></u></div><div>I am trying to build a desktop application in Python to analyze and generate performance reports on a Stock Market Swing Trading Strategy by downloading end of the day data from our Indian Stock Market Exchange (NSE) and using this data to analyze our trading strategy which we have put in an excel. <br></div><div>I have a tabbed view and in each tabs I am trying to display some data in tabular format using QTableView and TableModel.</div><div>As of now, I have 3 tables:</div><div>(1) NSE Data Table - Data changes dynamically based on a date selected from a combo box.</div><div>(2) Swing Data Table -
Data changes dynamically based on a date selected from a combo box. <br></div><div>(3) Swing Filter Data Table -
Data changes dynamically based on a date selected from a combo box.</div><div><br></div><div><u><b>My Issue:</b></u></div><div>(1) NSE Data Table works fine without issues</div><div>(2) Swing Data Table - Program crashes while setting the model.</div><div><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt"><span style="color:rgb(148,85,141)">self</span>._view.swingmaindata_table.setModel(<span style="color:rgb(148,85,141)">self</span>._view.swingmain_model)<br><br></pre><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt">The program abruptly crashes here with the following message:<br>Process finished with exit code -1073740791 (0xC0000409)<br></pre><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt"><u><b>My Environment<br></b></u></pre><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt">Python 3.7.2<br></pre><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt">PyCharm IDE<br></pre><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt">PyQT5</pre>I am looking for help to see where the below issues are and how I can fix them:</div><div>(1) setModel crashing the program</div><div>(2) How to dynamically update data in a table? (Replace entire data with a different set of data)<br></div><div><br></div><div><u><b>Code Snip</b></u></div><div>I am trying to use the MVC architecture.</div><div><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt"><span style="color:rgb(204,120,50)">class </span><span style="color:rgb(255,255,255)">DbtMain</span>(QMainWindow):<br> <span style="color:rgb(126,195,230)"># DBT's View (GUI) Initializer<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(178,0,178)">__init__</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(136,136,198)">super</span>().<span style="color:rgb(178,0,178)">__init__</span>()<br><br> <span style="color:rgb(126,195,230)"># Set main window properties<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.__set_main_window_properties__()<br><br> <span style="color:rgb(126,195,230)"># Set the central widget, layout<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.__set_central_widget_and_layout__()<br><br> <span style="color:rgb(126,195,230)"># Set Tabs in the layout<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.__set_tabs_in_layout__()<br><br> <span style="color:rgb(84,179,62)">'''<br></span><span style="color:rgb(84,179,62)"> Set main window properties<br></span><span style="color:rgb(84,179,62)"> '''<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">__set_main_window_properties__</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(148,85,141)">self</span>.title = <span style="color:rgb(84,179,62)">'DELIVERY BASED SWING TRADING'<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(148,85,141)">self</span>.left = <span style="color:rgb(51,204,255);font-weight:bold">0<br></span><span style="color:rgb(51,204,255);font-weight:bold"> </span><span style="color:rgb(148,85,141)">self</span>.top = <span style="color:rgb(51,204,255);font-weight:bold">0<br></span><span style="color:rgb(51,204,255);font-weight:bold"> </span><span style="color:rgb(148,85,141)">self</span>.width = <span style="color:rgb(51,204,255);font-weight:bold">1300<br></span><span style="color:rgb(51,204,255);font-weight:bold"> </span><span style="color:rgb(148,85,141)">self</span>.height = <span style="color:rgb(51,204,255);font-weight:bold">700<br></span><span style="color:rgb(51,204,255);font-weight:bold"> </span><span style="color:rgb(148,85,141)">self</span>.setWindowTitle(<span style="color:rgb(148,85,141)">self</span>.title)<br> <span style="color:rgb(148,85,141)">self</span>.setGeometry(<span style="color:rgb(148,85,141)">self</span>.left<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(148,85,141)">self</span>.top<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(148,85,141)">self</span>.width<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(148,85,141)">self</span>.height)<br><br> <span style="color:rgb(84,179,62)">'''<br></span><span style="color:rgb(84,179,62)"> Set central widget and layout<br></span><span style="color:rgb(84,179,62)"> '''<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">__set_central_widget_and_layout__</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(148,85,141)">self</span>.layout = QVBoxLayout(<span style="color:rgb(148,85,141)">self</span>)<br> <span style="color:rgb(148,85,141)">self</span>._dbt = QWidget(<span style="color:rgb(148,85,141)">self</span>)<br> <span style="color:rgb(148,85,141)">self</span>.setCentralWidget(<span style="color:rgb(148,85,141)">self</span>._dbt)<br> <span style="color:rgb(148,85,141)">self</span>._dbt.setLayout(<span style="color:rgb(148,85,141)">self</span>.layout)<br><br> <span style="color:rgb(84,179,62)">'''<br></span><span style="color:rgb(84,179,62)"> Set tabs in layout.<br></span><span style="color:rgb(84,179,62)"> Create and add tabs to the DBT central widget layout.<br></span><span style="color:rgb(84,179,62)"> 1. DBT App configuration tab<br></span><span style="color:rgb(84,179,62)"> 2. NSE Data downloader and view tab<br></span><span style="color:rgb(84,179,62)"> 3. Swing file upload tab<br></span><span style="color:rgb(84,179,62)"> 4. Charts tab<br></span><span style="color:rgb(84,179,62)"> '''<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">__set_tabs_in_layout__</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(126,195,230)"># Main tab widget<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.tabs = QTabWidget()<br> <span style="color:rgb(148,85,141)">self</span>.tabs.resize(<span style="color:rgb(51,204,255);font-weight:bold">1000</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">600</span>)<br><br> <span style="color:rgb(126,195,230)"># Create configure tab and add to main tab widget<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>._configure_ui()<br><br> <span style="color:rgb(126,195,230)"># Create NSE data download and view tab and add to main tab widget<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>._nsedata_ui()<br><br> <span style="color:rgb(126,195,230)"># Create swing file upload tab and add to main tab widget<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>._upload_swing_ui()<br><br> <span style="color:rgb(126,195,230)"># Add tabs to main DBT layout<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.layout.addWidget(<span style="color:rgb(148,85,141)">self</span>.tabs)<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">label</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">lbl</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">text</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">y</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">x</span>):<br> <span style="color:rgb(255,255,255)">lbl</span>.setText(<span style="color:rgb(255,255,255)">text</span>)<br> <span style="color:rgb(255,255,255)">lbl</span>.move(<span style="color:rgb(255,255,255)">y</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">x</span>)<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">format_text</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">txt</span>):<br> txt = <span style="color:rgb(84,179,62)">f"<P><b><FONT COLOR='#ff0000' FONT SIZE = 4></span><span style="color:rgb(237,134,74)">{</span><span style="color:rgb(255,255,255)">txt</span><span style="color:rgb(237,134,74)">}</span><span style="color:rgb(84,179,62)"></b></P></br>"<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(204,120,50)">return </span><span style="color:rgb(255,255,255)">txt<br></span><span style="color:rgb(255,255,255)"><br></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_nsedata_ui</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(126,195,230)"># Create the NSE data tab<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.nsedata_tab = QWidget()<br> <span style="color:rgb(148,85,141)">self</span>.tabs.addTab(<span style="color:rgb(148,85,141)">self</span>.nsedata_tab<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(84,179,62)">"NSE EoD Data"</span>)<br><br> <span style="color:rgb(126,195,230)"># Add the drop down box<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.dc_label = QLabel(<span style="color:rgb(148,85,141)">self</span>.nsedata_tab)<br> txt = <span style="color:rgb(148,85,141)">self</span>.format_text(<span style="color:rgb(84,179,62)">"NSE data available dates"</span>)<br> <span style="color:rgb(126,195,230)"># txt = "<P><b><FONT COLOR='#ff0000' FONT SIZE = 4>NSE data available dates</b></P></br>"<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.label(<span style="color:rgb(148,85,141)">self</span>.dc_label<span style="color:rgb(237,134,74);font-weight:bold">, </span>txt<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">5</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">20</span>)<br> <span style="color:rgb(148,85,141)">self</span>.nsedata_dates = QComboBox(<span style="color:rgb(148,85,141)">self</span>.nsedata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.nsedata_dates.addItems(NseData.data.keys())<br> <span style="color:rgb(148,85,141)">self</span>.nsedata_dates.move(<span style="color:rgb(51,204,255);font-weight:bold">10</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">50</span>)<br><br> <span style="color:rgb(126,195,230)"># Add the QTableView<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.nsetbl_label = QLabel(<span style="color:rgb(148,85,141)">self</span>.nsedata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.nsedata_table = QTableView(<span style="color:rgb(148,85,141)">self</span>.nsedata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.nsedata_table.resize(<span style="color:rgb(51,204,255);font-weight:bold">1050</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">550</span>)<br> <span style="color:rgb(148,85,141)">self</span>.nsedata_table.move(<span style="color:rgb(51,204,255);font-weight:bold">200</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">50</span>)<br><br><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_configure_ui</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(148,85,141)">self</span>.configure_tab = QWidget()<br> <span style="color:rgb(148,85,141)">self</span>.tabs.addTab(<span style="color:rgb(148,85,141)">self</span>.configure_tab<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(84,179,62)">"Configuration"</span>)<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_upload_swing_ui</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(148,85,141)">self</span>.swingdata_tab = QWidget()<br> <span style="color:rgb(148,85,141)">self</span>.tabs.addTab(<span style="color:rgb(148,85,141)">self</span>.swingdata_tab<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(84,179,62)">"Swing File Upload"</span>)<br><br> <span style="color:rgb(126,195,230)"># Add the drop down box<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.swing_dc_label = QLabel(<span style="color:rgb(148,85,141)">self</span>.swingdata_tab)<br> txt = <span style="color:rgb(148,85,141)">self</span>.format_text(<span style="color:rgb(84,179,62)">"Swing data available dates"</span>)<br> <span style="color:rgb(148,85,141)">self</span>.label(<span style="color:rgb(148,85,141)">self</span>.swing_dc_label<span style="color:rgb(237,134,74);font-weight:bold">, </span>txt<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">5</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">20</span>)<br> <span style="color:rgb(148,85,141)">self</span>.swingdata_dates = QComboBox(<span style="color:rgb(148,85,141)">self</span>.swingdata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.swingdata_dates.addItems(SwingFile.data.keys())<br> <span style="color:rgb(148,85,141)">self</span>.swingdata_dates.move(<span style="color:rgb(51,204,255);font-weight:bold">10</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">50</span>)<br><br> <span style="color:rgb(126,195,230)"># Add the QTableView for Main swing data<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.swingmaintbl_label = QLabel(<span style="color:rgb(148,85,141)">self</span>.swingdata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.swingmain_table = QTableView(<span style="color:rgb(148,85,141)">self</span>.swingdata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.swingmain_table.resize(<span style="color:rgb(51,204,255);font-weight:bold">1050</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">250</span>)<br> <span style="color:rgb(148,85,141)">self</span>.swingmain_table.move(<span style="color:rgb(51,204,255);font-weight:bold">200</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">50</span>)<br><br> <span style="color:rgb(126,195,230)"># Add the QTableView for Filter swing data<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>.swingfiltertbl_label = QLabel(<span style="color:rgb(148,85,141)">self</span>.swingdata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.swingfilter_table = QTableView(<span style="color:rgb(148,85,141)">self</span>.swingdata_tab)<br> <span style="color:rgb(148,85,141)">self</span>.swingfilter_table.resize(<span style="color:rgb(51,204,255);font-weight:bold">1050</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">250</span>)<br> <span style="color:rgb(148,85,141)">self</span>.swingfilter_table.move(<span style="color:rgb(51,204,255);font-weight:bold">200</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">400</span>)<br><br><span style="color:rgb(204,120,50)">class </span><span style="color:rgb(255,255,255)">DbtController</span>:<br> <span style="color:rgb(126,195,230)"># Controller initializer<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(178,0,178)">__init__</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">view</span>):<br> <span style="color:rgb(148,85,141)">self</span>._view = <span style="color:rgb(255,255,255)">view<br></span><span style="color:rgb(255,255,255)"><br></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(126,195,230)"># Default to 1st date of download<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>._show_nse_data(<span style="color:rgb(148,85,141)">self</span>._view.nsedata_dates.currentText())<br><br> <span style="color:rgb(126,195,230)"># Connect signals and slots<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>._connect_signals()<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_refresh_nse_data</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(179,179,179)">i</span>):<br> <span style="color:rgb(148,85,141)">self</span>._show_nse_data(<span style="color:rgb(148,85,141)">self</span>._view.nsedata_dates.currentText())<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_show_nse_data</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">dt</span>=datetime.date.today().strftime(<span style="color:rgb(84,179,62)">"%d-%b-%Y"</span>)):<br> <span style="color:rgb(148,85,141)">self</span>._view.nsedata_model = TableModel(NseData.data[<span style="color:rgb(255,255,255)">dt</span>])<br> <span style="color:rgb(148,85,141)">self</span>._view.nsedata_table.setModel(<span style="color:rgb(148,85,141)">self</span>._view.nsedata_model)<br> txt = <span style="color:rgb(84,179,62)">f"<P><b><FONT COLOR='#ff0000' FONT SIZE = 4>NSE Data for </span><span style="color:rgb(237,134,74)">{</span><span style="color:rgb(255,255,255)">dt</span><span style="color:rgb(237,134,74)">}</span><span style="color:rgb(84,179,62)"></b></P></br>"<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(148,85,141)">self</span>._view.label(<span style="color:rgb(148,85,141)">self</span>._view.nsetbl_label<span style="color:rgb(237,134,74);font-weight:bold">, </span>txt<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">300</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">20</span>)<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_refresh_swing_data</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">i</span>):<br> <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(84,179,62)">f"REFRESH SWING - </span><span style="color:rgb(237,134,74)">{</span><span style="color:rgb(255,255,255)">i</span><span style="color:rgb(237,134,74)">}</span><span style="color:rgb(84,179,62)">, </span><span style="color:rgb(237,134,74)">{</span><span style="color:rgb(148,85,141)">self</span>._view.swingdata_dates.currentText()<span style="color:rgb(237,134,74)">}</span><span style="color:rgb(84,179,62)">"</span>)<br> <span style="color:rgb(126,195,230)"># self._show_swing_data(self._view.swingdata_dates.currentText())<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(148,85,141)">self</span>._view.swingmain_model.update(<span style="color:rgb(148,85,141)">self</span>._view.swingdata_dates.currentText())<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_show_swing_data</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">dt</span>=datetime.date.today().strftime(<span style="color:rgb(84,179,62)">"%d-%b-%Y"</span>)):<br> <span style="color:rgb(204,120,50)">if </span><span style="color:rgb(255,255,255)">dt </span>== datetime.date.today().strftime(<span style="color:rgb(84,179,62)">"%d-%b-%Y"</span>):<br> dt = <span style="color:rgb(136,136,198)">max</span>(SwingFile.datesobj).strftime(<span style="color:rgb(84,179,62)">"%d-%b-%Y"</span>)<br><br> <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(84,179,62)">f"SHOW SWING - </span><span style="color:rgb(237,134,74)">{</span><span style="color:rgb(255,255,255)">dt</span><span style="color:rgb(237,134,74)">}</span><span style="color:rgb(84,179,62)">"</span>)<br> <span style="color:rgb(148,85,141)">self</span>._view.swingmain_model = TableModel(SwingFile.data[<span style="color:rgb(255,255,255)">dt</span>][<span style="color:rgb(84,179,62)">'main'</span>])<br> <span style="color:rgb(136,136,198)">print</span>(SwingFile.data[<span style="color:rgb(255,255,255)">dt</span>][<span style="color:rgb(84,179,62)">'main'</span>])<br> <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(84,179,62)">"MOD-1"</span>)<br> <span style="color:rgb(148,85,141)">self</span>._view.swingmaindata_table.setModel(<span style="color:rgb(148,85,141)">self</span>._view.swingmain_model) # <--- <b>PROGRAM CRASHES HERE</b><br> <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(84,179,62)">"MOD-1.1"</span>)<br> txt = <span style="color:rgb(84,179,62)">f"<P><b><FONT COLOR='#ff0000' FONT SIZE = 4>Swing Main Data for </span><span style="color:rgb(237,134,74)">{</span><span style="color:rgb(255,255,255)">dt</span><span style="color:rgb(237,134,74)">}</span><span style="color:rgb(84,179,62)"></b></P></br>"<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(148,85,141)">self</span>._view.label(<span style="color:rgb(148,85,141)">self</span>._view.swingmaintbl_label<span style="color:rgb(237,134,74);font-weight:bold">, </span>txt<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">300</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">20</span>)<br><br> <span style="color:rgb(148,85,141)">self</span>._view.swingfilter_model = TableModel(SwingFile.data[<span style="color:rgb(255,255,255)">dt</span>][<span style="color:rgb(84,179,62)">'filter'</span>])<br> <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(84,179,62)">"MOD-2"</span>)<br> <span style="color:rgb(148,85,141)">self</span>._view.swingfilterdata_table.setModel(<span style="color:rgb(148,85,141)">self</span>._view.swingfilter_model)<br> <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(84,179,62)">"MOD-2.1"</span>)<br> txt = <span style="color:rgb(84,179,62)">f"<P><b><FONT COLOR='#ff0000' FONT SIZE = 4>Swing Filter Data for </span><span style="color:rgb(237,134,74)">{</span><span style="color:rgb(255,255,255)">dt</span><span style="color:rgb(237,134,74)">}</span><span style="color:rgb(84,179,62)"></b></P></br>"<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(148,85,141)">self</span>._view.label(<span style="color:rgb(148,85,141)">self</span>._view.swingfiltertbl_label<span style="color:rgb(237,134,74);font-weight:bold">, </span>txt<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">300</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(51,204,255);font-weight:bold">400</span>)<br><br> <span style="color:rgb(84,179,62)">'''<br></span><span style="color:rgb(84,179,62)"> Connect "Choose date from drop down box signal" with respective slots<br></span><span style="color:rgb(84,179,62)"> '''<br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">_connect_signals</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(148,85,141)">self</span>._view.nsedata_dates.activated.connect(partial(<span style="color:rgb(148,85,141)">self</span>._refresh_nse_data))<br> <span style="color:rgb(148,85,141)">self</span>._view.swingdata_dates.activated.connect(partial(<span style="color:rgb(148,85,141)">self</span>._refresh_swing_data))<br> <span style="color:rgb(126,195,230)"># self._view.buttons['Update'].clicked.connect(self._refresh_nse_data)<br><br><span style="color:rgb(204,120,50)">class </span><span style="color:rgb(255,255,255)">TableModel</span>(QtCore.QAbstractTableModel):<br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(178,0,178)">__init__</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">data</span>):<br> <span style="color:rgb(136,136,198)">super</span>(TableModel<span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(148,85,141)">self</span>).<span style="color:rgb(178,0,178)">__init__</span>()<br> <span style="color:rgb(148,85,141)">self</span>._data = <span style="color:rgb(255,255,255)">data<br></span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(148,85,141)">self</span>.header_labels = <span style="color:rgb(255,255,255)">data</span>[<span style="color:rgb(51,204,255);font-weight:bold">0</span>]<br> <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(255,255,255)">data</span>[<span style="color:rgb(51,204,255);font-weight:bold">0</span>])<br> <span style="color:rgb(148,85,141)">self</span>._data.remove(<span style="color:rgb(255,255,255)">data</span>[<span style="color:rgb(51,204,255);font-weight:bold">0</span>])<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">headerData</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">section</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">orientation</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">role</span>=Qt.DisplayRole):<br> <span style="color:rgb(204,120,50)">if </span><span style="color:rgb(255,255,255)">role </span>== Qt.DisplayRole <span style="color:rgb(204,120,50)">and </span><span style="color:rgb(255,255,255)">orientation </span>== Qt.Horizontal:<br> <span style="color:rgb(204,120,50)">return </span><span style="color:rgb(148,85,141)">self</span>.header_labels[<span style="color:rgb(255,255,255)">section</span>]<br> <span style="color:rgb(204,120,50)">return </span>QAbstractTableModel.headerData(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">section</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">orientation</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">role</span>)<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">update</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">datain</span>):<br> <span style="color:rgb(148,85,141)">self</span>._data = <span style="color:rgb(255,255,255)">datain<br></span><span style="color:rgb(255,255,255)"><br></span><span style="color:rgb(84,179,62)"> </span><span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">data</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">index</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">role</span>):<br> <span style="color:rgb(204,120,50)">if </span><span style="color:rgb(255,255,255)">role </span>== Qt.DisplayRole:<br> <span style="color:rgb(126,195,230)"># See below for the nested-list data structure.<br></span><span style="color:rgb(126,195,230)"> # .row() indexes into the outer list,<br></span><span style="color:rgb(126,195,230)"> # .column() indexes into the sub-list<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(204,120,50)">return </span><span style="color:rgb(148,85,141)">self</span>._data[<span style="color:rgb(255,255,255)">index</span>.row()][<span style="color:rgb(255,255,255)">index</span>.column()]<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">rowCount</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">index</span>):<br> <span style="color:rgb(126,195,230)"># The length of the outer list.<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(204,120,50)">return </span><span style="color:rgb(136,136,198)">len</span>(<span style="color:rgb(148,85,141)">self</span>._data)<br><br> <span style="color:rgb(204,120,50)">def </span><span style="color:rgb(255,207,64)">columnCount</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">index</span>):<br> <span style="color:rgb(126,195,230)"># The following takes the first sub-list, and returns<br></span><span style="color:rgb(126,195,230)"> # the length (only works if all rows are an equal length)<br></span><span style="color:rgb(126,195,230)"> </span><span style="color:rgb(204,120,50)">return </span><span style="color:rgb(136,136,198)">len</span>(<span style="color:rgb(148,85,141)">self</span>._data[<span style="color:rgb(51,204,255);font-weight:bold">0</span>])<br></span></pre><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt"><span style="color:rgb(126,195,230)">Thanks all in advance.<br></span></pre><pre style="background-color:rgb(19,19,20);color:rgb(235,235,235);font-family:"Courier New";font-size:9pt"><span style="color:rgb(126,195,230)">J.S.Girish<br></span></pre></div></div>