corrected for some python 3 compatibility issues; added a new delete picks button to the picking window

This commit is contained in:
Sebastian Wehling-Benatelli 2015-09-25 09:03:59 +02:00
parent b391f5e082
commit 33164d4d1f
5 changed files with 22 additions and 16 deletions

View File

@ -3,6 +3,7 @@
<file>icons/pylot.ico</file>
<file>icons/pylot.png</file>
<file>icons/printer.png</file>
<file>icons/delete.png</file>
<file>icons/key_E.png</file>
<file>icons/key_N.png</file>
<file>icons/key_P.png</file>

BIN
icons/delete.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,7 @@ class AutoPickParameter(object):
self.__filename = fnin
parFileCont = {}
# read from parsed arguments alternatively
for key, val in kwargs.iteritems():
for key, val in kwargs.items():
parFileCont[key] = val
if self.__filename is not None:
@ -57,7 +57,7 @@ class AutoPickParameter(object):
for line in lines:
parspl = line.split('\t')[:2]
parFileCont[parspl[0].strip()] = parspl[1]
except Exception, e:
except Exception as e:
self._printParameterError(e)
inputFile.seek(0)
lines = inputFile.readlines()
@ -65,7 +65,7 @@ class AutoPickParameter(object):
if not line.startswith(('#', '%', '\n', ' ')):
parspl = line.split('#')[:2]
parFileCont[parspl[1].strip()] = parspl[0].strip()
for key, value in parFileCont.iteritems():
for key, value in parFileCont.items():
try:
val = int(value)
except:
@ -121,7 +121,7 @@ class AutoPickParameter(object):
return len(self.__parameter.keys())
def iteritems(self):
for key, value in self.__parameter.iteritems():
for key, value in self.__parameter.items():
yield key, value
def hasParam(self, parameter):
@ -134,22 +134,22 @@ class AutoPickParameter(object):
for param in args:
try:
return self.__getitem__(param)
except KeyError, e:
except KeyError as e:
self._printParameterError(e)
except TypeError:
try:
return self.__getitem__(args)
except KeyError, e:
except KeyError as e:
self._printParameterError(e)
def setParam(self, **kwargs):
for param, value in kwargs.iteritems():
for param, value in kwargs.items():
self.__setitem__(param, value)
print self
print(self)
@staticmethod
def _printParameterError(errmsg):
print 'ParameterError:\n non-existent parameter %s' % errmsg
print('ParameterError:\n non-existent parameter %s' % errmsg)
def export2File(self, fnout):
fid_out = open(fnout, 'w')

View File

@ -187,7 +187,7 @@ class PickDlg(QDialog):
try:
data = parent.getData().getWFData().copy()
self.data = data.select(station=station)
except AttributeError, e:
except AttributeError as e:
errmsg = 'You either have to put in a data or an appropriate ' \
'parent (PyLoT MainWindow) object: {0}'.format(e)
raise Exception(errmsg)
@ -239,6 +239,8 @@ class PickDlg(QDialog):
zoom_icon.addPixmap(QPixmap(':/icons/zoom_in.png'))
home_icon = QIcon()
home_icon.addPixmap(QPixmap(':/icons/zoom_0.png'))
del_icon = QIcon()
del_icon.addPixmap(QPixmap(':/icon/delete.png'))
# create actions
self.filterAction = createAction(parent=self, text='Filter',
@ -251,9 +253,12 @@ class PickDlg(QDialog):
slot=self.zoom, icon=zoom_icon,
tip='Zoom into waveform',
checkable=True)
self.resetAction = createAction(parent=self, text='Home',
self.resetZoomAction = createAction(parent=self, text='Home',
slot=self.resetZoom, icon=home_icon,
tip='Reset zoom to original limits')
self.resetPicksAction = createAction(parent=self, text='Delete Picks',
slot=self.delPicks, icon=del_icon,
tip='Delete current picks.')
# create other widget elements
self.selectPhase = QComboBox()
@ -269,7 +274,7 @@ class PickDlg(QDialog):
_dialtoolbar.addWidget(self.selectPhase)
_dialtoolbar.addAction(self.zoomAction)
_dialtoolbar.addSeparator()
_dialtoolbar.addAction(self.resetAction)
_dialtoolbar.addAction(self.resetZoomAction)
# layout the innermost widget
_innerlayout = QVBoxLayout()