mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-09 19:58:02 +08:00
+13
-3
@@ -1,11 +1,10 @@
|
||||
has_qt = True
|
||||
|
||||
try:
|
||||
from matplotlib.backends.qt_compat import QtGui, QtCore, QtWidgets
|
||||
from matplotlib.backends.qt_compat import QtGui, QtCore, QtWidgets, QT_RC_MAJOR_VERSION as has_qt
|
||||
except ImportError:
|
||||
try:
|
||||
from matplotlib.backends.qt4_compat import QtGui, QtCore
|
||||
QtWidgets = QtGui
|
||||
has_qt = 4
|
||||
except ImportError:
|
||||
# Mock objects
|
||||
class QtGui_cls(object):
|
||||
@@ -28,5 +27,16 @@ except ImportError:
|
||||
|
||||
has_qt = False
|
||||
|
||||
if has_qt == 5:
|
||||
from matplotlib.backends.backend_qt5 import FigureManagerQT
|
||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
|
||||
elif has_qt == 4:
|
||||
from matplotlib.backends.backend_qt4 import FigureManagerQT
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
|
||||
else:
|
||||
assert not has_qt, 'Unsupported Qt version {0}'.format(has_qt)
|
||||
FigureManagerQT = object
|
||||
FigureCanvasQTAgg = object
|
||||
|
||||
Qt = QtCore.Qt
|
||||
Signal = QtCore.Signal
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
from skimage.viewer.qt import QtGui, has_qt
|
||||
from skimage.viewer.qt import QtWidgets, has_qt, FigureManagerQT, FigureCanvasQTAgg
|
||||
import matplotlib as mpl
|
||||
from matplotlib.figure import Figure
|
||||
from matplotlib import _pylab_helpers
|
||||
from matplotlib.colors import LinearSegmentedColormap
|
||||
|
||||
if has_qt:
|
||||
from matplotlib.backends.backend_qt4 import FigureManagerQT
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
|
||||
if 'agg' not in mpl.get_backend().lower():
|
||||
warnings.warn("Recommended matplotlib backend is `Agg` for full "
|
||||
"skimage.viewer functionality.")
|
||||
else:
|
||||
FigureManagerQT = object
|
||||
FigureCanvasQTAgg = object
|
||||
if has_qt and 'agg' not in mpl.get_backend().lower():
|
||||
warnings.warn("Recommended matplotlib backend is `Agg` for full "
|
||||
"skimage.viewer functionality.")
|
||||
|
||||
|
||||
__all__ = ['init_qtapp', 'start_qtapp', 'RequiredAttr', 'figimage',
|
||||
@@ -32,9 +26,9 @@ def init_qtapp():
|
||||
The QApplication needs to be initialized before creating any QWidgets
|
||||
"""
|
||||
global QApp
|
||||
QApp = QtGui.QApplication.instance()
|
||||
QApp = QtWidgets.QApplication.instance()
|
||||
if QApp is None:
|
||||
QApp = QtGui.QApplication([])
|
||||
QApp = QtWidgets.QApplication([])
|
||||
return QApp
|
||||
|
||||
|
||||
@@ -121,8 +115,8 @@ class FigureCanvas(FigureCanvasQTAgg):
|
||||
self.fig = figure
|
||||
FigureCanvasQTAgg.__init__(self, self.fig)
|
||||
FigureCanvasQTAgg.setSizePolicy(self,
|
||||
QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Expanding)
|
||||
QtWidgets.QSizePolicy.Expanding,
|
||||
QtWidgets.QSizePolicy.Expanding)
|
||||
FigureCanvasQTAgg.updateGeometry(self)
|
||||
|
||||
def resizeEvent(self, event):
|
||||
|
||||
Reference in New Issue
Block a user