def __init__(self, session, parent=None, widget=None): super(TableWidget, self).__init__(session, parent) self.ui = load_ui('viewer_widget.ui', directory=os.path.dirname(__file__)) self.setCentralWidget(self.ui) hdr = self.ui.table.horizontalHeader() hdr.setStretchLastSection(True) if is_pyqt5(): hdr.setSectionResizeMode(hdr.Interactive) else: hdr.setResizeMode(hdr.Interactive) hdr = self.ui.table.verticalHeader() if is_pyqt5(): hdr.setSectionResizeMode(hdr.Interactive) else: hdr.setResizeMode(hdr.Interactive) self.ui.table.clicked.connect(self._clicked) self.model = None self.subset = None self.selected_rows = []
def retranslateUi(self, LayerTree): if is_pyqt5(): LayerTree.setWindowTitle( QtGui.QApplication.translate("LayerTree", "Form", None)) self.layerAddButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Load a new data set", None)) self.newSubsetButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Create a new empty subset", None)) self.layerRemoveButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Delete Layer", None)) self.linkButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Link data", None)) else: LayerTree.setWindowTitle( QtGui.QApplication.translate("LayerTree", "Form", None, QtGui.QApplication.UnicodeUTF8)) self.layerAddButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Load a new data set", None, QtGui.QApplication.UnicodeUTF8)) self.newSubsetButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Create a new empty subset", None, QtGui.QApplication.UnicodeUTF8)) self.layerRemoveButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Delete Layer", None, QtGui.QApplication.UnicodeUTF8)) self.linkButton.setToolTip( QtGui.QApplication.translate("LayerTree", "Link data", None, QtGui.QApplication.UnicodeUTF8))
def test_flags(): model, _ = setup_model(1) expected = (Qt.ItemIsEditable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable) if is_pyqt5(): expected |= Qt.ItemNeverHasChildren assert model.flags(model.index(0)) == expected
def test_flags(): model, _ = setup_model(1) expected = ( Qt.ItemIsEditable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable ) if is_pyqt5(): expected |= Qt.ItemNeverHasChildren assert model.flags(model.index(0)) == expected
def __init__(self, data_collection, parent=None): QtCore.QAbstractItemModel.__init__(self, parent) HubListener.__init__(self) self.data_collection = data_collection self.root = DataCollectionItem(data_collection) self._items = {} # map hashes of Model pointers to model items # without this reference, PySide clobbers instance # data of model items self.register_to_hub(self.data_collection.hub) if not is_pyqt5(): self.setSupportedDragActions(Qt.CopyAction)
def retranslateUi(self, LayerTree): if is_pyqt5(): LayerTree.setWindowTitle(QtGui.QApplication.translate("LayerTree", "Form", None)) self.layerAddButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Load a new data set", None)) self.newSubsetButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Create a new empty subset", None)) self.layerRemoveButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Delete Layer", None)) self.linkButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Link data", None)) else: LayerTree.setWindowTitle(QtGui.QApplication.translate("LayerTree", "Form", None, QtGui.QApplication.UnicodeUTF8)) self.layerAddButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Load a new data set", None, QtGui.QApplication.UnicodeUTF8)) self.newSubsetButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Create a new empty subset", None, QtGui.QApplication.UnicodeUTF8)) self.layerRemoveButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Delete Layer", None, QtGui.QApplication.UnicodeUTF8)) self.linkButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Link data", None, QtGui.QApplication.UnicodeUTF8))
def set_mpl_backend(): from matplotlib import rcParams, rcdefaults # standardize mpl setup rcdefaults() from glue.external.qt import is_pyqt5 if is_pyqt5(): rcParams['backend'] = 'Qt5Agg' else: rcParams['backend'] = 'Qt4Agg' # The following is a workaround for the fact that Matplotlib checks the # rcParams at import time, not at run-time. I have opened an issue with # Matplotlib here: https://github.com/matplotlib/matplotlib/issues/5513 from matplotlib import get_backend from matplotlib import backends backends.backend = get_backend()
def invalidate(self): self.root = DataCollectionItem(self.data_collection) self._items.clear() if not is_pyqt5(): self.reset() self.layoutChanged.emit()
#!/usr/bin/env python from __future__ import absolute_import, division, print_function from functools import wraps import matplotlib from matplotlib.figure import Figure from glue.external.qt.QtCore import Qt from glue.external.qt import QtGui, QtCore, is_pyqt5 from glue.utils import DeferredMethod if is_pyqt5(): from matplotlib.backends.backend_qt5 import FigureManagerQT as FigureManager from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas else: try: from matplotlib.backends.backend_qt4agg import FigureManagerQT as FigureManager except ImportError: # mpl < 1.4 from matplotlib.backends.backend_qt4agg import FigureManagerQTAgg as FigureManager from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas def defer_draw(func): """ Decorator that globally defers all MplCanvas draw requests until function exit. If an MplCanvas instance's draw method is invoked multiple times, it will only be called once after the wrapped function returns.
#!/usr/bin/env python from __future__ import absolute_import, division, print_function from functools import wraps import matplotlib from matplotlib.figure import Figure from glue.external.qt.QtCore import Qt from glue.external.qt import QtGui, QtCore, is_pyqt5 from glue.utils import DeferredMethod from glue.config import settings if is_pyqt5(): from matplotlib.backends.backend_qt5 import FigureManagerQT as FigureManager from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas else: try: from matplotlib.backends.backend_qt4agg import FigureManagerQT as FigureManager except ImportError: # mpl < 1.4 from matplotlib.backends.backend_qt4agg import FigureManagerQTAgg as FigureManager from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas def defer_draw(func): """ Decorator that globally defers all MplCanvas draw requests until function exit. If an MplCanvas instance's draw method is invoked multiple times,