DOI-BOR / PyForecast

PyForecast is a statistical modeling tool used by Reclamation water managers and reservoir operators to train and build predictive models for seasonal inflows and streamflows. PyForecast allows users to make current water-year forecasts using models developed with the program.
Other
28 stars 12 forks source link

Propose refactoring of the GUI code #3

Open tjrocha opened 5 years ago

tjrocha commented 5 years ago

Should we try to refactor the GUI code in PyForecast_GUI.py? We could split up the TABs to have their own code file by GUI elements (summaryTabGui.py, dataTabGui.py, etc). This will allow us to also split up the application.py code file based on which GUI element they support (summaryTabCode.py, dataTabCode.py, etc.).

Doing this should allow us to more easily trace which functions/methods support which GUI operation and perhaps allow us to identify places where we can share/optimize functions/methods.

Thoughts @kevinfol

kevinfol commented 5 years ago

This is a great idea Jon. I've actually started refactoring the code in a separate development version: https://github.com/kevinfol/NextFlow_development

The directory structure over there is:

│   main.py
└─── resources
    │   application.py
    ├─── GUI
        │   NextFlowGUI.py
        ├─── Tabs
        │       DatasetsTab.py
        │       DataTab.py
        ├─── CustomWidgets
        │       DatasetBoxView.py

I propose we do a similar structure to that where we also put all the subclassed widgets in their own folder.

Splitting up the application.py file could be bit trickier. Some functions would then have to call functions from other scripts, for example:

def deleteDatasetFromDataTable(self, colName):
     ...
     self.stationsTab.stationsInfoPane.stationTable.deleteFromTable(option='customrow', rowID=index)
     ...

all while maintaining the correct inheritance and OOP functionality.