Commit 9b215a0d authored by Elisa Kanaki's avatar Elisa Kanaki

Correct __main__.py

parent 8020cfd2
......@@ -18,36 +18,64 @@ You should have received a copy of the GNU General Public License
along with this program, see COPYING.
If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import logging.handlers
import traceback
import os
from io import StringIO
from typing import List
from PyQt5 import QtCore, QtWidgets, QtGui
from .sampleview import SampleView
from .scalebar import ScaleBar
from .ramancom.ramancontrol import defaultPath
from .ramancom.ramanSwitch import RamanSwitch
from .analysis.colorlegend import ColorLegend
from .gui.scalebar import ScaleBar
from .instrumentcom.instrumentConfig import defaultPath
from .instrumentcom.lightModeSwitch import LightModeSwitch
from .gui.colorlegend import ColorLegend
from .gepardlogging import setDefaultLoggingConfig
from .workmodes import ModeHandler
from .unittests.test_gepard import testGepard
from .helperfunctions import getAppFolder
from gepard import __version__
def excepthook(excType, excValue, tracebackobj):
"""
Global function to catch unhandled exceptions.
@param excType exception type
@param excValue exception value
@param tracebackobj traceback object
:return:
"""
tbinfofile = StringIO()
traceback.print_tb(tracebackobj, None, tbinfofile)
tbinfofile.seek(0)
tbinfo = tbinfofile.read()
logging.critical("Fatal error in program execution!")
logging.critical(tbinfo)
from .errors import showErrorMessageAsWidget
showErrorMessageAsWidget(tbinfo)
class GEPARDMainWindow(QtWidgets.QMainWindow):
def __init__(self, logpath):
def __init__(self, logger):
super(GEPARDMainWindow, self).__init__()
self.setWindowTitle("GEPARD " + __version__)
self.fname: str = ''
self.resize(900, 700)
self.view = SampleView(logpath)
self.view.imparent = self
self.view.ScalingChanged.connect(self.scalingChanged)
self.scalebar = ScaleBar(self)
self.legend = ColorLegend(self)
self.ramanSwitch = RamanSwitch(self)
self.lightModeSwitch = LightModeSwitch(self)
self.view = SampleView(self, logger)
self.view.ScalingChanged.connect(self.scalingChanged)
self.view.ScalingChanged.connect(self.scalebar.updateScale)
mdiarea = QtWidgets.QMdiArea(self)
mdiarea.addSubWindow(self.scalebar)
mdiarea.addSubWindow(self.legend)
mdiarea.addSubWindow(self.ramanSwitch)
mdiarea.addSubWindow(self.lightModeSwitch)
self.legend.hide()
self.ramanSwitch.hide()
self.lightModeSwitch.hide()
subview = mdiarea.addSubWindow(self.view)
subview.showMaximized()
......@@ -123,8 +151,16 @@ class GEPARDMainWindow(QtWidgets.QMainWindow):
@QtCore.pyqtSlot()
def about(self):
QtWidgets.QMessageBox.about(self, 'GEPARD', "Developed by Complex Fiber Structures GmbH "
"on behalf of Leibniz-IPF Dresden")
devbranch = None
fname = os.path.join(os.path.split(__file__)[0],
os.path.join('.git', 'HEAD'))
if os.path.exists(fname):
with open(fname, 'r') as fp:
cont = fp.read()
devbranch = cont.rsplit('/', maxsplit=1)[1]
QtWidgets.QMessageBox.about(self, 'GEPARD',
'Gepard-Enabled PARticle Detection for Raman and FTIR microscopes. \nVersion:' + \
__version__ + '' if devbranch is None else ('\nDevelopment branch: ' + devbranch))
def getParticleRelevantActs(self) -> List[QtWidgets.QAction]:
return [self.noOverlayAct, self.selOverlayAct, self.fullOverlayAct, self.hideLabelAct, self.transpAct, self.darkenAct, self.seedAct]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment