cleaning up main window for first test runs

This commit is contained in:
Sebastian Wehling-Benatelli 2014-11-13 11:27:52 +01:00
parent 86803cdff0
commit 8c66f1823a
4 changed files with 61 additions and 41 deletions

View File

@ -37,6 +37,7 @@ from pylot.core.util import (PickDlg,
PropertiesDlg,
MPLWidget,
HelpForm)
from pylot.core.util import layoutStationButtons
# Version information
__version__ = _getVersionString()
@ -67,6 +68,12 @@ class MainWindow(QMainWindow):
def loadData(self):
self.data = Data()
def getData(self):
return self.data
def getDataWidget(self):
return self.DataPlot
def setupUi(self):
self.setWindowIcon(QIcon(":/pylot.ico"))
@ -79,10 +86,6 @@ class MainWindow(QMainWindow):
ylabel=None,
title=plottitle)
filterDlg = FilterOptionsDialog(titleString="Filter Options",
parent=self,
filterOptions=self.filteroptions)
self.eventLabel = QLabel()
self.eventLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
status = self.statusBar()
@ -90,23 +93,33 @@ class MainWindow(QMainWindow):
status.addPermanentWidget(self.eventLabel)
status.showMessage("Ready", 5000)
statLayout = self.layoutStationButtons(self.numStations)
dataLayout = MPLWidget()
statLayout = layoutStationButtons(self.getData(), self.getComponent())
dataLayout = self.getDataWidget()
maingrid = QGridLayout()
maingrid.setSpacing(10)
maingrid.addLayout(statLayout, 0, 0)
maingrid.addLayout(dataLayout, 1, 0)
maingrid.setCentralWidget(self.DataPlot)
maingrid.setCentralWidget(dataLayout)
def plotData(self):
self.data.plotData(self.DataPlot)
def adjustFilterOptions(self):
filterDlg = FilterOptionsDialog(titleString="Filter Options",
fstring = "Filter Options ({0})".format(self.getSeismicPhase())
filterDlg = FilterOptionsDialog(titleString=fstring,
parent=self,
filterOptions=self.filteroptions)
filterDlg.connect()
filterOptions=self.getFilterOptions())
filterDlg.accepted.connect(filterDlg.getFilterOptions)
def getFilterOptions(self):
return self.filteroptions
def setFilterOptions(self, filterOptions):
cases = {'P':self.filterOptionsP,
'S':self.filterOptionsS}
cases[self.getSeismicPhase()] = filterOptions
self.updateFilterOptions()
def updateFilterOptions(self):
try:
@ -118,27 +131,15 @@ class MainWindow(QMainWindow):
else:
self.updateStatus('Filteroptions succesfully loaded ...')
def getSeismicPhase(self):
return self.seismicPhase
def setSeismicPhase(self, phase):
self.seismicPhase = self.seismicPhaseButton.getValue()
def updateStatus(self, message):
self.statusBar().showMessage(message, 5000)
def layoutStationButtons(self, numStations):
layout = QVBoxLayout()
stationButtons = []
for n in range(numStations):
tr = self.data.select(component=self.dispOptions.comp)
try:
stationButtons[n] = QPushButton('%s'.format(
tr[n].stats.station))
except IndexError:
error = QErrorMessage(self)
errorString = '''Number of stations does not match number of
traces!'''
error.showMessage(errorString)
self.__del__()
layout.addWidget(stationButtons)
return layout
def helpHelp(self):
if checkurl():
form = HelpForm('https://ariadne.geophysik.ruhr-uni-bochum.de/trac/PyLoT/wiki')

View File

@ -1,6 +1,7 @@
from pylot.core.util.connection import checkurl
from pylot.core.util.defaults import FILTERDEFAULTS
from pylot.core.util.errors import OptionsError
from pylot.core.util.layouts import layoutStationButtons
from pylot.core.util.utils import fnConstructor
from pylot.core.util.widgets import PickDlg
from pylot.core.util.widgets import HelpForm
@ -9,3 +10,4 @@ from pylot.core.util.widgets import PropertiesDlg
from pylot.core.util.widgets import MPLWidget
from pylot.core.util.version import get_git_version as _getVersionString

View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
#
# -*- coding: utf-8 -*-
'''
Created on 10.11.2014
@author: sebastianw
'''
from PySide.QtGui import (QVBoxLayout,
QPushButton)
def layoutStationButtons(data, comp):
layout = QVBoxLayout()
stationButtons = []
st = data.select(component=comp)
numStations = len(st)
for n in range(numStations):
stationButtons[n] = QPushButton('%s'.format(
st[n].stats.station))
layout.addWidget(stationButtons)
return layout

View File

@ -206,14 +206,10 @@ class FilterOptionsDialog(QDialog):
self.setLayout(self.layoutEditables)
self.connect(self.freqminSpinBox, SIGNAL("valueChanged(double)"),
self.updateUi)
self.connect(self.freqmaxSpinBox, SIGNAL("valueChanged(double)"),
self.updateUi)
self.connect(self.orderSpinBox, SIGNAL("valueChanged(int)"),
self.updateUi)
self.connect(self.selectTypeCombo, SIGNAL("currentIndexChanged(int)"),
self.updateUi)
self.freqminSpinBox.connect(self.updateUi)
self.freqmaxSpinBox.connect(self.updateUi)
self.orderSpinBox.connect(self.updateUi)
self.selectTypeCombo.connect(self.updateUi)
def updateUi(self):
if self.selectTypeCombo.currentText() not in ['bandpass', 'bandstop']:
@ -241,7 +237,7 @@ class FilterOptionsDialog(QDialog):
freq.append(self.freqmaxSpinBox.value())
self.filterOptions.freq = freq
self.filterOptions.order = self.orderSpinBox.value()
return self.filterOptions
return self.getFilterOptions()
def getFilterOptions(self):
return self.filterOptions
@ -257,7 +253,7 @@ class LoadDataDlg(QDialog):
class HelpForm(QDialog):
def __init__(self, page=QUrl(':/help.html'), parent=None):
def __init__(self, page=QUrl('https://ariadne.geophysik.rub.de/trac/PyLoT'), parent=None):
super(HelpForm, self).__init__(parent)
self.setAttribute(Qt.WA_DeleteOnClose)
self.setAttribute(Qt.WA_GroupLeader)
@ -273,7 +269,7 @@ class HelpForm(QDialog):
toolBar.addAction(homeAction)
toolBar.addWidget(self.pageLabel)
self.webBrowser = QWebView()
self.webBrowser.setHtml(page)
self.webBrowser.load(page)
layout = QVBoxLayout()
layout.addWidget(toolBar)
@ -287,8 +283,6 @@ class HelpForm(QDialog):
self.connect(self.webBrowser, SIGNAL("sourceChanged(QUrl)"),
self.updatePageTitle)
self.webBrowser.setSearchPaths([":/help"])
self.webBrowser.setSource(QUrl(page))
self.resize(400, 600)
self.setWindowTitle("{0} Help".format(QApplication.applicationName()))