moved function createAction to the widgets module (reused in additional widget)
bugfix: on Linux systems os.getlogin raises an exception (reimplementation: getLogin)
This commit is contained in:
@@ -4,9 +4,9 @@ from pylot.core.util.errors import OptionsError, FormatError, DatastructureError
|
||||
from pylot.core.util.layouts import layoutStationButtons
|
||||
from pylot.core.util.utils import fnConstructor, createArrival, createEvent,\
|
||||
createPick, createAmplitude, createOrigin, createMagnitude, getOwner, \
|
||||
getHash
|
||||
getHash, getLogin
|
||||
from pylot.core.util.widgets import PickDlg, HelpForm, FilterOptionsDialog,\
|
||||
PropertiesDlg, NewEventDlg, MPLWidget
|
||||
PropertiesDlg, NewEventDlg, MPLWidget, createAction
|
||||
from pylot.core.util.version import get_git_version as _getVersionString
|
||||
|
||||
|
||||
|
||||
@@ -23,9 +23,11 @@ def fnConstructor(s):
|
||||
return fn
|
||||
|
||||
|
||||
def getLogin():
|
||||
return pwd.getpwuid(os.getuid())[0]
|
||||
|
||||
def getHash(time):
|
||||
'''
|
||||
|
||||
:param time: time object for which a hash should be calculated
|
||||
:type time: :class: `~obspy.core.utcdatetime.UTCDateTime` object
|
||||
:return: str
|
||||
|
||||
@@ -43,6 +43,24 @@ from pylot.core.read import FilterOptions
|
||||
from pylot.core.util.defaults import OUTPUTFORMATS
|
||||
|
||||
|
||||
def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||
tip=None, checkable=False):
|
||||
"""
|
||||
:rtype : ~PySide.QtGui.QAction
|
||||
"""
|
||||
action = QAction(text, parent)
|
||||
if icon is not None:
|
||||
action.setIcon(icon)
|
||||
if shortcut is not None:
|
||||
action.setShortcut(shortcut)
|
||||
if tip is not None:
|
||||
action.setToolTip(tip)
|
||||
if slot is not None:
|
||||
action.triggered.connect(slot)
|
||||
if checkable:
|
||||
action.setCheckable(True)
|
||||
return action
|
||||
|
||||
class MPLWidget(FigureCanvas):
|
||||
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
|
||||
Reference in New Issue
Block a user