emphasize modular structure by outsourcing widgets and errors

This commit is contained in:
Sebastian Wehling-Benatelli 2014-03-28 05:25:46 +01:00
parent dac3be5110
commit 90936bd47a

View File

@ -23,23 +23,34 @@ class MainWindow(QMainWindow):
def __init__(self, parent=None): def __init__(self, parent=None):
super(MainWindow, self).__init__(parent) super(MainWindow, self).__init__(parent)
self.setWindowIcon(QIcon("PyLoT.ico"))
# create central matplotlib figure widget
setupPlot()
self.setCentralWidget(self.DataPlot)
filterOptionsP = FILTERDEFAULTS['P'] filterOptionsP = FILTERDEFAULTS['P']
filterOptionsS = FILTERDEFAULTS['S'] filterOptionsS = FILTERDEFAULTS['S']
self.filterOptionsP = FilterOptions(**filterOptionsP) self.filterOptionsP = FilterOptions(**filterOptionsP)
self.filterOptionsS = FilterOptions(**filterOptionsS) self.filterOptionsS = FilterOptions(**filterOptionsS)
filteroptions = [self.filterOptionsP if not self.seismicPhase == 'S' self.loadData()
else self.filterOptionsS]
self.updateFilterOptions()
self.setupUi()
def setupUi(self):
self.setWindowIcon(QIcon("PyLoT.ico"))
# create central matplotlib figure widget
dataLayout = setupPlot()
filterDockWidget = FilterOptionsDock(titleString="Filter Options", filterDockWidget = FilterOptionsDock(titleString="Filter Options",
parent=self, parent=self,
filterOptions=filteroptions) filterOptions=filteroptions)
statLayout = self.layoutStationButtons()
maingrid = QGridLayout()
maingrid.setSpacing(10)
maingrid.addLayout(statLayout, 0, 0)
maingrid.addWidget()
def setupPlot(self): def setupPlot(self):
# create a matplotlib widget # create a matplotlib widget
self.DataPlot = MPLWidget() self.DataPlot = MPLWidget()
@ -47,44 +58,15 @@ class MainWindow(QMainWindow):
layout = QtGui.QVBoxLayout(self.ui.widget_PlotArea) layout = QtGui.QVBoxLayout(self.ui.widget_PlotArea)
layout.addWidget(self.DataPlot, 1) layout.addWidget(self.DataPlot, 1)
return layout
def plotData(self, data): def plotData(self, data):
if data is not None and isinstance(data, Stream): if data is not None and isinstance(data, Stream):
self.DataPlot.height self.DataPlot.height
def updateFilterOptions(self):
class PickWindow(QDialog): self.filteroptions = [self.filterOptionsP if not self.seismicPhase == 'S'
else self.filterOptionsS]
def __init__(self, station=None, parent=None):
super(PickWindow, self).__init__(parent)
filterDockWidget = FilterOptionsDock(titleString="Filter Options",
parent=self,
filterOptions=filteroptions)
class PropertiesWindow(QDialog):
def __init__(self, parent=None):
super(PropertiesWindow, self).__init__(parent)
class FilterOptionsDock(QDockWidget):
def __init__(self, parent=None, titleString="Filter options",
filterOptions=None):
super(FilterOptionsDock, self).__init__()
if filterOptions and not isinstance(filterOptions, FilterOptions):
try:
fOptions = FilterOptions(**filterOptions)
filterOptions = fOptions
except e:
raise OptionsError('%s' % e)
class OptionsError(Exception):
pass
if __name__ == '__main__': if __name__ == '__main__':
# Creating a Qt application # Creating a Qt application