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:
Sebastian Wehling
2015-03-04 11:52:04 +01:00
parent b23c9d1104
commit 0dbcca1c6f
4 changed files with 30 additions and 27 deletions

View File

@@ -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'):