diff options
Diffstat (limited to 'silx/sx/__init__.py')
-rw-r--r-- | silx/sx/__init__.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/silx/sx/__init__.py b/silx/sx/__init__.py index e3641c8..97a3460 100644 --- a/silx/sx/__init__.py +++ b/silx/sx/__init__.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2018 European Synchrotron Radiation Facility +# Copyright (c) 2016-2019 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -75,6 +75,10 @@ else: _IS_NOTEBOOK = False +# Placeholder for QApplication +_qapp = None + + def enable_gui(): """Populate silx.sx module with silx.gui features and initialise Qt""" if _NO_DISPLAY: # Missing DISPLAY under linux @@ -82,18 +86,21 @@ def enable_gui(): 'Not loading silx.gui features: No DISPLAY available') return - global qt, qapp + global qt, _qapp if _IS_NOTEBOOK: _get_ipython().enable_pylab(gui='qt', import_all=False) from silx.gui import qt - qapp = qt.QApplication.instance() or qt.QApplication([]) + # Create QApplication and keep reference only if needed + if not qt.QApplication.instance(): + _qapp = qt.QApplication([]) if hasattr(_sys, 'ps1'): # If from console, change windows icon # Change windows default icon from silx.gui import icons - qapp.setWindowIcon(icons.getQIcon('silx')) + app = qt.QApplication.instance() + app.setWindowIcon(icons.getQIcon('silx')) global ImageView, PlotWidget, PlotWindow, Plot1D global Plot2D, StackView, ScatterView, TickMode |