#! /usr/bin/env python
##########################################################################
# CAPSUL - Copyright (C) CEA, 2013
# Distributed under the terms of the CeCILL-B license, as published by
# the CEA-CNRS-INRIA. Refer to the LICENSE file or to
# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
# for details.
##########################################################################

# System import
import logging
import sys

# Capsul import
from capsul.apps_qt import qt_backend
# TODO: add option to set backend befor importing QtCore
#qt_backend.set_qt_backend("PyQt4")
#qt_backend.init_matplotlib_backend()
from capsul.apps_qt.qt_backend import QtCore

try :
    from capsul.apps_qt.pipeline_viewer_app import PipelineViewerApp
    app = PipelineViewerApp()

except :
    import sys
    import traceback

    exc_info = sys.exc_info()
    trace = "".join(traceback.format_exception(*exc_info))

    logging.error(trace)

else :
    QtCore.QObject.connect(app, QtCore.SIGNAL('lastWindowClosed()'), 
                           app, QtCore.SLOT('quit()'))
    sys.exit(app.exec_())

