I'm writing an application using PyQt4 to analyze data as it acquired from our data acquisition software. The application will consist of a few widgets:
- a widget to display what files have been imported (and what data channels are in those files); this widget will also contain the file watcher that is looking for data files as they are generated
- a widget that will plot certain data channels as they are imported
- multiple other widgets that perform different analysis and display the results of that analysis
All of these widgets would be contained within a QMainWindow
So basically, the main routine will be: file generated (external to application) -> file imported into pandas dataframe -> data plotted / analyzed
What I'm unclear about is where in the application would be the best place to actually run the import function (and therefore where the actual pandas dataframes will be held).
The two places that make sense to me are either in the first widget mentioned (that one that is doing the file watching / displaying of what has been imported) or the actual QMainWindow itself.
I understand how to tell all the widgets currently in the QMainWindow that a file has been imported using signals / slots. So, for example, the file watcher widget will emit a signal every time a file is imported. This would be connected to slots in the other widgets that would tell them to update the current plot, or run some analysis, or whatever.
But the point of uncertainty I'm running in to how to make the data that is imported available to all of the widgets currently in the QMainWindow. Which is what I mean by asking where the import function should actually be run.
Hopefully what I'm asking is clear; if not let me know.
Edit:
Reading a bit more about MVC design in Qt, it's unclear to me whether it's appropriate here. I would like to make the parts of the application as independent as possible, so the idea behind using MVC is very appealing, but I'm having trouble understanding how it would be implemented in my case. All of the examples that I have been able to find seem to deal with updating, for example, a TreeWidget and a ComboBox so that when the data for one is edited it remains in sync with the data for the other (i.e. they both change since the data is held in one place).
In my case the data itself is never modified by anything after it has been imported. Analysis may be run on it, but that would be independent to each widget and would have no effect on the actual raw data that has been imported into the application. Each widget is essentially independent, with anything occurring within that widget having no effect on any other widget in the application. Every widget currently active in the main application simply needs to have access to the data that has been imported, and needs to know when a new piece of data has been added (this is envisioned as a dictionary of file names matched to pandas dataframes)
As suggested, keeps the data in the main application and connecting to each of the widgets to indicate that a new piece of data is now available is straightforward, so I get how that would work.
I'm just very unclear about what I would gain by going to MVC route.